Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added support to specify AWS profile through S3 instructions #6130

Merged
merged 18 commits into from
Oct 3, 2024
Merged
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion py/server/deephaven/experimental/s3.py
malhotrashivam marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,26 @@ def __init__(self,
(access_key_id is None and secret_access_key is not None)):
raise DHError("Either both access_key_id and secret_access_key must be provided or neither")

# Only one of the following credentials can be set, otherwise the builder will throw an exception
# Configure the credentials
chipkent marked this conversation as resolved.
Show resolved Hide resolved
credentials_configured = None
if access_key_id is not None:
builder.credentials(_JCredentials.basic(access_key_id, secret_access_key))
credentials_configured = "access_key_id"
if anonymous_access:
if credentials_configured:
self.throw_multiple_credentials_error(credentials_configured, "anonymous_access")
builder.credentials(_JCredentials.anonymous())
credentials_configured = "anonymous_access"
if use_profile_credentials:
if credentials_configured:
self.throw_multiple_credentials_error(credentials_configured, "use_profile_credentials")
builder.credentials(_JCredentials.profile())
credentials_configured = "use_profile_credentials"
if use_default_credentials:
if credentials_configured:
self.throw_multiple_credentials_error(credentials_configured, "use_default_credentials")
builder.credentials(_JCredentials.defaultCredentials())
credentials_configured = "use_default_credentials"

if endpoint_override is not None:
builder.endpointOverride(endpoint_override)
Expand All @@ -187,6 +198,11 @@ def __init__(self,
except Exception as e:
raise DHError(e, "Failed to build S3 instructions") from e

def throw_multiple_credentials_error(self,
credentials1: str,
credentials2: str):
raise DHError(f"Only one set of credentials can be set, but found {credentials1} and {credentials2}")
malhotrashivam marked this conversation as resolved.
Show resolved Hide resolved

@property
def j_object(self) -> jpy.JType:
return self._j_object
Loading