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

Pre-requisite Changes Enable smithy query + rest-xml clients #3321

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sbera87
Copy link
Contributor

@sbera87 sbera87 commented Feb 28, 2025

Issue #, if available:

Description of changes:
This PR includes

  • changes needed to enable xml, query protocol clients and special customized client like RDS
  • changes for multi auth support across all protocols (Refactor to minimize code/logic duplication in Java codegen classes)
  • backwards compatible changes for generate presign url APIs
  • Examples of changes on clients from different protocols.

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 s3query branch 3 times, most recently from 27ab711 to e788a0f Compare March 6, 2025 16:51
@sbera87 sbera87 force-pushed the s3query branch 3 times, most recently from c5622a1 to 80a1146 Compare March 11, 2025 20:37
@@ -176,7 +177,7 @@ protected List<SdkFileEntry> generateClientSourceFile( List<ServiceModel> servic
{
if(serviceModels.get(index).isUseSmithyClient() && !serviceModels.get(index).hasEventStreamingRequestShapes())
{
return GenerateSmithyClientSourceFile(serviceModels.get(index), index);
return GenerateSmithyClientSourceFile(serviceModels.get(index), index, Optional.empty());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reuse base class function

for (int i = 0; i < serviceModels.size(); i++) {
Template template = velocityEngine.getTemplate("/com/amazonaws/util/awsclientgenerator/velocity/cpp/queryxml/QueryXmlServiceClientSource.vm", StandardCharsets.UTF_8.name());

List<Integer> serviceModelsIndices = IntStream.range(0, serviceModels.size()).boxed().collect(Collectors.toList());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactor to use base class function to avoid duplicate logic

Template template;
if (serviceModel.isUseSmithyClient())
{
template = velocityEngine.getTemplate("/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientHeader.vm", StandardCharsets.UTF_8.name());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactor to use base class function to avoid duplicate code and logic

@sbera87 sbera87 changed the title Enable S3 query + rest-xml clients [Work in Progress] Pre-requisite Changes Enable S3 query + rest-xml clients Mar 12, 2025
@sbera87 sbera87 marked this pull request as ready for review March 12, 2025 14:50
@@ -62,7 +63,7 @@ protected List<SdkFileEntry> generateClientSourceFile(List<ServiceModel> service
serviceModelsIndices.stream().forEach(index -> {
if(serviceModels.get(index).isUseSmithyClient())
{
smithyClients.add(GenerateSmithyClientSourceFile(serviceModels.get(index), index));
smithyClients.add(GenerateSmithyClientSourceFile(serviceModels.get(index), index,Optional.empty()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make API reusable, accommodate interface change

@@ -40,6 +40,9 @@
, "lexv2-runtime"
, "qbusiness"
, "transcribestreaming"
, "s3-crt"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In exclusion list because s3 was addressed in separate PR, and S3-crt,s3control pending

@sbera87 sbera87 changed the title Pre-requisite Changes Enable S3 query + rest-xml clients Pre-requisite Changes Enable smithy query + Rest-xml clients Mar 12, 2025
@sbera87 sbera87 changed the title Pre-requisite Changes Enable smithy query + Rest-xml clients Pre-requisite Changes Enable smithy query + rest-xml clients Mar 12, 2025
@@ -284,6 +284,49 @@ namespace client
return {};
}

Aws::String GeneratePresignedUrl(
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a to duplicate this method body?

@@ -100,6 +100,186 @@ namespace client
}

AwsLegacyClientT() = default;

Copy link
Contributor

Choose a reason for hiding this comment

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

ah the joys of backwards compatibility

@@ -284,6 +284,49 @@ namespace client
return {};
}

Aws::String GeneratePresignedUrl(
Copy link
Contributor

Choose a reason for hiding this comment

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

having four generate presigned URL methods seems excessive and that we are creating bloat in this class. can we do something similar to how we did AwsLegacyClientT and move this into a PresignMixinT then invoke a single smithy client method?

In fact we already do this on the old client but have it as a signer to look up. lets just add it as a mix in.

else
{
throw new RuntimeException(String.format("authSchemes '%s'",serviceModel.getAuthSchemes().stream().collect(Collectors.toList())
));
Copy link
Contributor

Choose a reason for hiding this comment

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

fix these trailing params, put them on the same line as everything else, it reads weird

{
context.put("AuthSchemeResolver", ResolverMapping.get(firstAuthScheme.get()));
context.put("AuthSchemeResolver", "SigV4MultiAuthSchemeResolver");
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we hard coding it to sigv4 and no the the first auth scheme? we should be using the first in the list, hard coding it seems wrong

}
else
{
throw new RuntimeException(String.format("authSchemes '%s'",serviceModel.getAuthSchemes().stream().collect(Collectors.toList())
));
Optional<String> firstAuthScheme = serviceModel.getAuthSchemes().stream().filter(entry->ResolverMapping.containsKey(entry)).findFirst();
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the third time this has been copied so likely it should be broken off. into its own function

if (serviceModel.isUseSmithyClient())
{
template = velocityEngine.getTemplate("/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientHeader.vm", StandardCharsets.UTF_8.name());
if(serviceModel.getAuthSchemes().size() > 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

this same block appears all of the place, we need to move it to a single place to avoid code duplicaiton

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.

3 participants