feat(io): add VendedCredentialsProvider for S3 credential refresh by gabeiglio · Pull Request #3507 · apache/iceberg-python · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions pyiceberg/catalog/rest/credentials_provider.py
12 changes: 12 additions & 0 deletions pyiceberg/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
from io import SEEK_SET
from types import TracebackType
from typing import (
TYPE_CHECKING,
Protocol,
runtime_checkable,
)

if TYPE_CHECKING:
from pyiceberg.catalog.rest.credentials_provider import VendedCredentialsProvider
from urllib.parse import urlparse

from pyiceberg.typedef import EMPTY_DICT, Properties
Expand All @@ -54,6 +58,7 @@
S3_ACCESS_KEY_ID = "s3.access-key-id"
S3_SECRET_ACCESS_KEY = "s3.secret-access-key"
S3_SESSION_TOKEN = "s3.session-token"
S3_SESSION_TOKEN_EXPIRES_AT_MS = "s3.session-token-expires-at-ms"
S3_REGION = "s3.region"
S3_RESOLVE_REGION = "s3.resolve-region"
S3_PROXY_URI = "s3.proxy-uri"
Expand Down Expand Up @@ -291,6 +296,13 @@ def delete(self, location: str | InputFile | OutputFile) -> None:
FileNotFoundError: When the file at the provided location does not exist.
"""

def set_credentials_provider(self, provider: VendedCredentialsProvider) -> None: # noqa: B027
"""Inject a credentials provider for refreshing vended storage credentials.

Args:
provider (VendedCredentialsProvider): A concrete type of VendedCredentialsProvider (e.g S3VendedCredentialsProvider)
"""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put a TODO and a pass in here? That should be enough to get rid of the noqa: B027. I believe that will be enough to get rid of that type exception.

I actually have no issues with assigning the provider to an internal variable (that isn't yet used)


LOCATION = "location"
WAREHOUSE = "warehouse"
Expand Down
185 changes: 185 additions & 0 deletions tests/catalog/test_credentials_provider.py