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

Enable S3 smithy client #3317

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Enable S3 smithy client #3317

wants to merge 1 commit into from

Conversation

sbera87
Copy link
Contributor

@sbera87 sbera87 commented Feb 27, 2025

Issue #, if available:

Description of changes:
This set of changes enables Smithy client for S3 with applicable backwards compatible changes.

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@sbera87 sbera87 force-pushed the s3smithyon branch 2 times, most recently from dea11b7 to f0684a4 Compare February 27, 2025 19:50
@@ -290,18 +460,21 @@ void AwsSmithyClientBase::AttemptOneRequestAsync(std::shared_ptr<AwsSmithyClient
return;
}

pRequestCtx->m_interceptorContext->SetTransmitRequest(pRequestCtx->m_httpRequest);
for (const auto& interceptor : m_interceptors)
if (pRequestCtx->m_interceptorContext)
Copy link
Contributor Author

@sbera87 sbera87 Feb 27, 2025

Choose a reason for hiding this comment

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

just added code block under null guard since in requestless cases, this is currently not created in requestless call flow.
This is done to emulate legacy behavior:
with request case:

InterceptorContext context{request};

vs

request less case:

HttpResponseOutcome AWSClient::AttemptOneRequest(const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest,




void AwsSmithyClientBase::MakeRequestAsyncHelper(std::shared_ptr<AwsSmithyClientAsyncRequestContext>& pRequestCtx,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This helper abstracts endpoint resolution into a callback and is invoked contextually by different variations of APIs used for backwards compatibilty

@sbera87 sbera87 force-pushed the s3smithyon branch 3 times, most recently from 3547603 to f03166d Compare February 28, 2025 16:58
Aws::Map<Aws::String, Aws::String> params;
params.emplace("bucketName", bucket);
ServiceSpecificParameters serviceSpecificParameters{params};
auto serviceParams = Aws::MakeShared<ServiceSpecificParameters>(ALLOCATION_TAG, serviceSpecificParameters);
return AWSClient::GeneratePresignedUrl(endpoint, method, customizedHeaders, expirationInSeconds, Aws::Auth::SIGV4_SIGNER,
nullptr, nullptr, serviceParams);
EndpointUpdateCallback endpointCallback = [&](Aws::Endpoint::AWSEndpoint& endpoint){
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes to resolve endpoint after select auth scheme

Aws::Vector<AuthSchemeOption> authSchemeOptions = m_authSchemeResolver->resolveAuthScheme(identityParams);
Aws::Vector<AuthSchemeOption> authSchemeOptions;
/*for backwards compatibility, signer name override is used to filter auth schemes by id equivalent to legacy signer name*/
if(ctx.m_signerNameOverride.has_value())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is added to make the backwards compatible api functional.
In legacy client, signer name passed was used to fetch the signer object via
auto signer = GetSignerByName(signerName);
In smithy design, this name passed is simply re-mapped and used to filter desired auth scheme (with requested signer) from list of supported auth schemes

@@ -240,8 +314,141 @@ namespace client
}
return GeneratePresignedUrl(uri, method, signerRegionOverride, signerServiceNameOverride, expirationInSeconds, customizedHeaders, serviceSpecificParameters);
}

ResponseT MakeRequest(const Aws::Http::URI& uri,
Copy link
Contributor Author

@sbera87 sbera87 Feb 28, 2025

Choose a reason for hiding this comment

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

Legacy APIs that need to be supported as external clients found to use some variations.

using ClientError = AWSError;
using SigningError = AWSError;
using AWSCoreError = Aws::Client::AWSError<CoreErrors>;
using ClientError = AWSCoreError;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed to ensure backwards compatibility . External clients use AwsError as a templated type

std::shared_ptr<Aws::Utils::Threading::Executor> pExecutor
) const;

const std::shared_ptr<Aws::Client::AWSErrorMarshaller>& GetErrorMarshaller() const
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed as External Users use this

@@ -200,7 +237,7 @@ namespace client
Aws::Vector<std::shared_ptr<smithy::interceptor::Interceptor>> m_interceptors{};
std::shared_ptr<smithy::client::UserAgentInterceptor> m_userAgentInterceptor;
private:
void UpdateAuthSchemeFromEndpoint(const Aws::Endpoint::AWSEndpoint& endpoint, AuthSchemeOption& authscheme) const;
void UpdateAuthSchemeFromEndpoint(std::shared_ptr<AwsSmithyClientAsyncRequestContext>& pRequestCtx) const;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interface updated to facilitate legacy API usage where endpoint may not be available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant