From 897e1b8eb6ee6080da8bf8f079361b6337f1727c Mon Sep 17 00:00:00 2001 From: Saranya Somepalli Date: Tue, 14 Jul 2026 20:00:31 -0700 Subject: [PATCH 1/3] Fix constant pool overflow issue --- .../codegen/poet/client/AsyncClientClass.java | 4 +-- .../codegen/poet/client/ClientClassUtils.java | 33 +++++++++++-------- .../codegen/poet/client/SyncClientClass.java | 4 +-- .../poet/client/specs/JsonProtocolSpec.java | 12 +++---- .../poet/client/specs/QueryProtocolSpec.java | 12 +++---- .../poet/client/specs/XmlProtocolSpec.java | 12 +++---- .../test-aws-json-async-client-class.java | 13 +++++--- ...ry-compatible-json-async-client-class.java | 13 +++++--- ...ery-compatible-json-sync-client-class.java | 13 +++++--- .../poet/client/test-batchmanager-async.java | 13 +++++--- .../client/test-cbor-async-client-class.java | 13 +++++--- .../poet/client/test-cbor-client-class.java | 13 +++++--- ...tom-context-params-async-client-class.java | 13 +++++--- ...stom-context-params-sync-client-class.java | 13 +++++--- .../poet/client/test-custompackage-async.java | 13 +++++--- .../poet/client/test-custompackage-sync.java | 13 +++++--- .../test-customservicemetadata-async.java | 13 +++++--- .../test-customservicemetadata-sync.java | 13 +++++--- .../client/test-endpoint-discovery-async.java | 13 +++++--- .../client/test-endpoint-discovery-sync.java | 13 +++++--- .../client/test-json-async-client-class.java | 13 +++++--- .../poet/client/test-json-client-class.java | 13 +++++--- .../poet/client/test-presignedurl-async.java | 13 +++++--- .../client/test-query-async-client-class.java | 13 +++++--- .../poet/client/test-query-client-class.java | 13 +++++--- .../client/test-rpcv2-async-client-class.java | 13 +++++--- .../codegen/poet/client/test-rpcv2-sync.java | 13 +++++--- ...gned-payload-trait-async-client-class.java | 13 +++++--- ...igned-payload-trait-sync-client-class.java | 13 +++++--- .../client/test-xml-async-client-class.java | 13 +++++--- .../poet/client/test-xml-client-class.java | 13 +++++--- core/sdk-core/pom.xml | 11 +++++++ .../core/http/auth/AuthSchemeResolver.java | 2 +- .../stages/AuthSchemeResolutionStage.java | 2 +- .../identity/AuthSchemeOptionsResolver.java | 4 ++- .../stages/AuthSchemeResolutionStageTest.java | 17 +++++----- .../s3/internal/s3express/S3ExpressUtils.java | 2 +- 37 files changed, 259 insertions(+), 181 deletions(-) diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java index 045040d12f45..da4ec3d60ae8 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java @@ -173,9 +173,7 @@ protected void addAdditionalMethods(TypeSpec.Builder type) { .addMethod(protocolSpec.initProtocolFactory(model)) .addMethod(resolveMetricPublishersMethod()) .addMethod(ClientClassUtils.resolveAuthSchemeOptionsMethod(authSchemeSpecUtils, endpointRulesSpecUtils)) - .addMethod(ClientClassUtils.resolveEndpointMethod(authSchemeSpecUtils, endpointRulesSpecUtils)) - .addMethod(ClientClassUtils.authSchemeResolverFactoryMethod()) - .addMethod(ClientClassUtils.endpointResolverFactoryMethod()); + .addMethod(ClientClassUtils.resolveEndpointMethod(authSchemeSpecUtils, endpointRulesSpecUtils)); type.addMethod(ClientClassUtils.updateRetryStrategyClientConfigurationMethod()); type.addMethod(updateSdkClientConfigurationMethod(configurationUtils.serviceClientConfigurationBuilderClassName(), diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/ClientClassUtils.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/ClientClassUtils.java index 5b0f5ab6ae98..af80ed574c5b 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/ClientClassUtils.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/ClientClassUtils.java @@ -62,6 +62,7 @@ import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.signer.Signer; @@ -368,11 +369,12 @@ static MethodSpec resolveAuthSchemeOptionsMethod(AuthSchemeSpecUtils authSchemeS .addModifiers(PRIVATE) .returns(ParameterizedTypeName.get(ClassName.get(List.class), ClassName.get(AuthSchemeOption.class))) .addParameter(SdkRequest.class, "request") - .addParameter(String.class, "operationName") - .addParameter(SdkClientConfiguration.class, "clientConfiguration"); + .addParameter(ExecutionAttributes.class, "executionAttributes"); ClassName providerInterface = authSchemeSpecUtils.providerInterfaceName(); + builder.addStatement("String operationName = executionAttributes.getAttribute($T.OPERATION_NAME)", SdkExecutionAttribute.class); + // Check for request-level authSchemeProvider override builder.addStatement("$T requestAuthSchemeProvider = request.overrideConfiguration()" + ".flatMap(c -> c.authSchemeProvider())" @@ -446,24 +448,24 @@ private static void addEndpointBasedAuthSchemeResolution(MethodSpec.Builder buil ClassName sdkInternalExecutionAttribute = ClassName.get("software.amazon.awssdk.core.interceptor", "SdkInternalExecutionAttribute"); - builder.addStatement("$T executionAttributes = new $T()", executionAttributesClass, executionAttributesClass); - builder.addStatement("executionAttributes.putAttribute($T.AWS_REGION, clientConfiguration.option($T.AWS_REGION))", + builder.addStatement("$T endpointAttrs = new $T()", executionAttributesClass, executionAttributesClass); + builder.addStatement("endpointAttrs.putAttribute($T.AWS_REGION, clientConfiguration.option($T.AWS_REGION))", awsExecutionAttribute, awsClientOption); - builder.addStatement("executionAttributes.putAttribute($T.DUALSTACK_ENDPOINT_ENABLED, " + builder.addStatement("endpointAttrs.putAttribute($T.DUALSTACK_ENDPOINT_ENABLED, " + "clientConfiguration.option($T.DUALSTACK_ENDPOINT_ENABLED))", awsExecutionAttribute, awsClientOption); - builder.addStatement("executionAttributes.putAttribute($T.FIPS_ENDPOINT_ENABLED, " + builder.addStatement("endpointAttrs.putAttribute($T.FIPS_ENDPOINT_ENABLED, " + "clientConfiguration.option($T.FIPS_ENDPOINT_ENABLED))", awsExecutionAttribute, awsClientOption); - builder.addStatement("executionAttributes.putAttribute($T.OPERATION_NAME, operationName)", sdkExecutionAttribute); - builder.addStatement("executionAttributes.putAttribute($T.CLIENT_ENDPOINT_PROVIDER, " + builder.addStatement("endpointAttrs.putAttribute($T.OPERATION_NAME, operationName)", sdkExecutionAttribute); + builder.addStatement("endpointAttrs.putAttribute($T.CLIENT_ENDPOINT_PROVIDER, " + "clientConfiguration.option($T.CLIENT_ENDPOINT_PROVIDER))", sdkInternalExecutionAttribute, SdkClientOption.class); - builder.addStatement("executionAttributes.putAttribute($T.CLIENT_CONTEXT_PARAMS, " + builder.addStatement("endpointAttrs.putAttribute($T.CLIENT_CONTEXT_PARAMS, " + "clientConfiguration.option($T.CLIENT_CONTEXT_PARAMS))", sdkInternalExecutionAttribute, SdkClientOption.class); - builder.addStatement("$T endpointParams = $T.ruleParams(request, executionAttributes)", + builder.addStatement("$T endpointParams = $T.ruleParams(request, endpointAttrs)", endpointParamsClass, endpointResolverUtils); builder.addStatement("$T.Builder paramsBuilder = $T.builder()", paramsInterface, paramsInterface); @@ -497,8 +499,10 @@ private static void addEndpointBasedAuthSchemeResolution(MethodSpec.Builder buil ClassName endpointProviderInterface = endpointRulesSpecUtils.providerInterfaceName(); builder.beginControlFlow("if (paramsBuilder instanceof $T)", paramsBuilderClass); - builder.addStatement("$T endpointProvider = clientConfiguration.option($T.ENDPOINT_PROVIDER)", - ClassName.get("software.amazon.awssdk.endpoints", "EndpointProvider"), SdkClientOption.class); + builder.addStatement("$T endpointProvider = ($T) executionAttributes.getAttribute($T.ENDPOINT_PROVIDER)", + ClassName.get("software.amazon.awssdk.endpoints", "EndpointProvider"), + ClassName.get("software.amazon.awssdk.endpoints", "EndpointProvider"), + sdkInternalExecutionAttribute); builder.beginControlFlow("if (endpointProvider instanceof $T)", endpointProviderInterface); builder.addStatement("(($T) paramsBuilder).endpointProvider(($T) endpointProvider)", paramsBuilderClass, endpointProviderInterface); @@ -555,8 +559,9 @@ static MethodSpec resolveEndpointMethod(AuthSchemeSpecUtils authSchemeSpecUtils, .addModifiers(PRIVATE) .returns(Endpoint.class) .addParameter(SdkRequest.class, "request") - .addParameter(ExecutionAttributes.class, "executionAttributes") - .addParameter(String.class, "operationName"); + .addParameter(ExecutionAttributes.class, "executionAttributes"); + + b.addStatement("String operationName = executionAttributes.getAttribute($T.OPERATION_NAME)", SdkExecutionAttribute.class); b.addStatement("$1T provider = ($1T) executionAttributes.getAttribute($2T.ENDPOINT_PROVIDER)", providerInterface, SdkInternalExecutionAttribute.class); diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/SyncClientClass.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/SyncClientClass.java index 99e37ea13aea..0d33e441bc40 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/SyncClientClass.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/SyncClientClass.java @@ -141,9 +141,7 @@ protected void addAdditionalMethods(TypeSpec.Builder type) { .addMethods(protocolSpec.additionalMethods()) .addMethod(resolveMetricPublishersMethod()) .addMethod(ClientClassUtils.resolveAuthSchemeOptionsMethod(authSchemeSpecUtils, endpointRulesSpecUtils)) - .addMethod(ClientClassUtils.resolveEndpointMethod(authSchemeSpecUtils, endpointRulesSpecUtils)) - .addMethod(ClientClassUtils.authSchemeResolverFactoryMethod()) - .addMethod(ClientClassUtils.endpointResolverFactoryMethod()); + .addMethod(ClientClassUtils.resolveEndpointMethod(authSchemeSpecUtils, endpointRulesSpecUtils)); protocolSpec.createErrorResponseHandler().ifPresent(type::addMethod); type.addMethod(ClientClassUtils.updateRetryStrategyClientConfigurationMethod()); diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/JsonProtocolSpec.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/JsonProtocolSpec.java index d5937678ac21..765b47da8f9c 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/JsonProtocolSpec.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/JsonProtocolSpec.java @@ -224,10 +224,8 @@ public CodeBlock executionHandler(OperationModel opModel) { .add(".withRequestConfiguration(clientConfiguration)") .add(".withInput($L)\n", opModel.getInput().getVariableName()) .add(".withMetricCollector(apiCallMetricCollector)\n") - .add(".withAuthSchemeOptionsResolver(authSchemeResolver($S, clientConfiguration))\n", - opModel.getOperationName()) - .add(".withEndpointResolver(endpointResolver($S))\n", - opModel.getOperationName()) + .add(".withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions)\n") + .add(".withEndpointResolver(this::resolveEndpoint)\n") .add(HttpChecksumRequiredTrait.putHttpChecksumAttribute(opModel)) .add(HttpChecksumTrait.create(opModel)); @@ -302,10 +300,8 @@ public CodeBlock asyncExecutionHandler(IntermediateModel intermediateModel, Oper .add(".withErrorResponseHandler(errorResponseHandler)\n") .add(".withRequestConfiguration(clientConfiguration)") .add(".withMetricCollector(apiCallMetricCollector)\n") - .add(".withAuthSchemeOptionsResolver(authSchemeResolver($S, clientConfiguration))\n", - opModel.getOperationName()) - .add(".withEndpointResolver(endpointResolver($S))\n", - opModel.getOperationName()) + .add(".withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions)\n") + .add(".withEndpointResolver(this::resolveEndpoint)\n") .add(hostPrefixExpression(opModel)) .add(discoveredEndpoint(opModel)) .add(credentialType(opModel, model)) diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/QueryProtocolSpec.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/QueryProtocolSpec.java index 302b99c9cec4..1bb28ebbd706 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/QueryProtocolSpec.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/QueryProtocolSpec.java @@ -116,10 +116,8 @@ public CodeBlock executionHandler(OperationModel opModel) { .add(".withRequestConfiguration(clientConfiguration)") .add(".withInput($L)", opModel.getInput().getVariableName()) .add(".withMetricCollector(apiCallMetricCollector)") - .add(".withAuthSchemeOptionsResolver(authSchemeResolver($S, clientConfiguration))\n", - opModel.getOperationName()) - .add(".withEndpointResolver(endpointResolver($S))\n", - opModel.getOperationName()) + .add(".withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions)\n") + .add(".withEndpointResolver(this::resolveEndpoint)\n") .add(HttpChecksumRequiredTrait.putHttpChecksumAttribute(opModel)) .add(HttpChecksumTrait.create(opModel)); @@ -159,10 +157,8 @@ public CodeBlock asyncExecutionHandler(IntermediateModel intermediateModel, Oper .add(credentialType(opModel, intermediateModel)) .add(".withRequestConfiguration(clientConfiguration)") .add(".withMetricCollector(apiCallMetricCollector)\n") - .add(".withAuthSchemeOptionsResolver(authSchemeResolver($S, clientConfiguration))\n", - opModel.getOperationName()) - .add(".withEndpointResolver(endpointResolver($S))\n", - opModel.getOperationName()) + .add(".withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions)\n") + .add(".withEndpointResolver(this::resolveEndpoint)\n") .add(HttpChecksumRequiredTrait.putHttpChecksumAttribute(opModel)) .add(HttpChecksumTrait.create(opModel)); diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/XmlProtocolSpec.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/XmlProtocolSpec.java index fb421b0ccb77..73527ce73ac8 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/XmlProtocolSpec.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/XmlProtocolSpec.java @@ -135,10 +135,8 @@ public CodeBlock executionHandler(OperationModel opModel) { .add(credentialType(opModel, model)) .add(".withRequestConfiguration(clientConfiguration)") .add(".withInput($L)", opModel.getInput().getVariableName()) - .add(".withAuthSchemeOptionsResolver(authSchemeResolver($S, clientConfiguration))\n", - opModel.getOperationName()) - .add(".withEndpointResolver(endpointResolver($S))\n", - opModel.getOperationName()) + .add(".withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions)\n") + .add(".withEndpointResolver(this::resolveEndpoint)\n") .add(HttpChecksumRequiredTrait.putHttpChecksumAttribute(opModel)) .add(HttpChecksumTrait.create(opModel)); @@ -217,10 +215,8 @@ public CodeBlock asyncExecutionHandler(IntermediateModel intermediateModel, Oper builder.add(hostPrefixExpression(opModel)) .add(credentialType(opModel, model)) .add(".withMetricCollector(apiCallMetricCollector)\n") - .add(".withAuthSchemeOptionsResolver(authSchemeResolver($S, clientConfiguration))\n", - opModel.getOperationName()) - .add(".withEndpointResolver(endpointResolver($S))\n", - opModel.getOperationName()) + .add(".withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions)\n") + .add(".withEndpointResolver(this::resolveEndpoint)\n") .add(asyncRequestBody(opModel)) .add(HttpChecksumRequiredTrait.putHttpChecksumAttribute(opModel)) .add(HttpChecksumTrait.create(opModel)); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-json-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-json-async-client-class.java index 33f5c7b612e0..53fb1bfaf719 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-json-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-json-async-client-class.java @@ -50,6 +50,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; @@ -1455,8 +1456,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -1472,7 +1474,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonEndpointProvider provider = (JsonEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -1504,11 +1507,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-async-client-class.java index de37281ad310..ae7f5aa63782 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-async-client-class.java @@ -35,6 +35,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -201,8 +202,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); QueryToJsonCompatibleAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -219,7 +221,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); QueryToJsonCompatibleEndpointProvider provider = (QueryToJsonCompatibleEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -252,11 +255,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-sync-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-sync-client-class.java index ead8f03c7bfd..7dae6de6b59c 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-sync-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-sync-client-class.java @@ -30,6 +30,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -175,8 +176,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); QueryToJsonCompatibleAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -193,7 +195,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); QueryToJsonCompatibleEndpointProvider provider = (QueryToJsonCompatibleEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -226,11 +229,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-batchmanager-async.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-batchmanager-async.java index a047a35d87d5..fca61faec4b1 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-batchmanager-async.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-batchmanager-async.java @@ -36,6 +36,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -197,8 +198,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); BatchManagerTestAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -215,7 +217,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); BatchManagerTestEndpointProvider provider = (BatchManagerTestEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -248,11 +251,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-async-client-class.java index 56c3e6c6c46a..47cadbf55270 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-async-client-class.java @@ -50,6 +50,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; @@ -1459,8 +1460,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -1476,7 +1478,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonEndpointProvider provider = (JsonEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -1508,11 +1511,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-client-class.java index 3198fa31df25..ee92563199e3 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-client-class.java @@ -30,6 +30,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; @@ -966,8 +967,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -983,7 +985,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonEndpointProvider provider = (JsonEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -1015,11 +1018,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-async-client-class.java index 818e13b3663e..e26ea1e04bab 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-async-client-class.java @@ -36,6 +36,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -192,8 +193,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); FooBarAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -208,7 +210,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); FooBarEndpointProvider provider = (FooBarEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -240,11 +243,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-sync-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-sync-client-class.java index 6e29b234a04a..348d11110353 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-sync-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-sync-client-class.java @@ -31,6 +31,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -168,8 +169,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); FooBarAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -184,7 +186,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); FooBarEndpointProvider provider = (FooBarEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -216,11 +219,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-async.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-async.java index aa23153cdd20..58a4cb4039ce 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-async.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-async.java @@ -46,6 +46,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -191,8 +192,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); ProtocolRestJsonWithCustomPackageAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -209,7 +211,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); ProtocolRestJsonWithCustomPackageEndpointProvider provider = (ProtocolRestJsonWithCustomPackageEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -243,11 +246,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-sync.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-sync.java index 24811ad10405..ad765db19086 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-sync.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-sync.java @@ -41,6 +41,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -165,8 +166,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); ProtocolRestJsonWithCustomPackageAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -183,7 +185,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); ProtocolRestJsonWithCustomPackageEndpointProvider provider = (ProtocolRestJsonWithCustomPackageEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -217,11 +220,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-async.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-async.java index a4956ab331f3..8c27e34bbb64 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-async.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-async.java @@ -35,6 +35,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -191,8 +192,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); ProtocolRestJsonWithCustomContentTypeAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -209,7 +211,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); ProtocolRestJsonWithCustomContentTypeEndpointProvider provider = (ProtocolRestJsonWithCustomContentTypeEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -243,11 +246,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-sync.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-sync.java index 31f56fe814ef..4e1be19ea70d 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-sync.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-sync.java @@ -30,6 +30,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -165,8 +166,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); ProtocolRestJsonWithCustomContentTypeAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -183,7 +185,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); ProtocolRestJsonWithCustomContentTypeEndpointProvider provider = (ProtocolRestJsonWithCustomContentTypeEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -217,11 +220,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java index d043a064e0ee..9563ff7d3ac0 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java @@ -39,6 +39,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -497,8 +498,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); EndpointDiscoveryTestAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -515,7 +517,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); EndpointDiscoveryTestEndpointProvider provider = (EndpointDiscoveryTestEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -548,11 +551,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java index e20ee0df3404..0bdd98491481 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java @@ -35,6 +35,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -413,8 +414,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); EndpointDiscoveryTestAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -431,7 +433,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); EndpointDiscoveryTestEndpointProvider provider = (EndpointDiscoveryTestEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -464,11 +467,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-class.java index 552f5f7056a9..eb9bf60b1768 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-class.java @@ -54,6 +54,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; @@ -1658,8 +1659,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -1675,7 +1677,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonEndpointProvider provider = (JsonEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -1707,11 +1710,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java index a557baa0385d..2366eae28bf2 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java @@ -32,6 +32,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; @@ -1121,8 +1122,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -1138,7 +1140,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonEndpointProvider provider = (JsonEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -1170,11 +1173,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-presignedurl-async.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-presignedurl-async.java index 5e9fdee4bcc6..9b49f8d804dd 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-presignedurl-async.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-presignedurl-async.java @@ -35,6 +35,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -201,8 +202,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -218,7 +220,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonEndpointProvider provider = (JsonEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -250,11 +253,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-async-client-class.java index 0a6706911756..bd1211a534ae 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-async-client-class.java @@ -41,6 +41,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; @@ -1251,8 +1252,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); QueryAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -1267,7 +1269,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); QueryEndpointProvider provider = (QueryEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -1299,11 +1302,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java index 004e8f563a94..f7ee672b074f 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java @@ -32,6 +32,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; @@ -1071,8 +1072,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); QueryAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -1087,7 +1089,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); QueryEndpointProvider provider = (QueryEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -1119,11 +1122,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-async-client-class.java index dddf865558a1..c3e94c0cf84a 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-async-client-class.java @@ -35,6 +35,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -1158,8 +1159,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); SmithyRpcV2ProtocolAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -1176,7 +1178,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); SmithyRpcV2ProtocolEndpointProvider provider = (SmithyRpcV2ProtocolEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -1209,11 +1212,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-sync.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-sync.java index 8beb520ef006..b905359a09d7 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-sync.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-sync.java @@ -30,6 +30,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -1019,8 +1020,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); SmithyRpcV2ProtocolAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -1037,7 +1039,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); SmithyRpcV2ProtocolEndpointProvider provider = (SmithyRpcV2ProtocolEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -1070,11 +1073,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-async-client-class.java index 12bceafed07b..646fddc2c0ae 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-async-client-class.java @@ -37,6 +37,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -1023,8 +1024,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); DatabaseAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -1043,7 +1045,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); DatabaseEndpointProvider provider = (DatabaseEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -1084,11 +1087,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-sync-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-sync-client-class.java index 299f08752a84..3c2b2586018a 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-sync-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-sync-client-class.java @@ -31,6 +31,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; @@ -908,8 +909,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); DatabaseAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() .flatMap(c -> c.authSchemeProvider()) @@ -928,7 +930,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); DatabaseEndpointProvider provider = (DatabaseEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -969,11 +972,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-async-client-class.java index 55a64c1b706a..55b15053ca03 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-async-client-class.java @@ -46,6 +46,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; @@ -946,8 +947,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); XmlAuthSchemeProvider requestAuthSchemeProvider = request.overrideConfiguration().flatMap(c -> c.authSchemeProvider()) .map(p -> Validate.isInstanceOf(XmlAuthSchemeProvider.class, p, "Expected an instance of XmlAuthSchemeProvider")) .orElse(null); @@ -960,7 +962,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); XmlEndpointProvider provider = (XmlEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -992,11 +995,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-client-class.java index 4e48a80ee74f..dbd6992da9f8 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-client-class.java @@ -32,6 +32,7 @@ import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; @@ -711,8 +712,9 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, String operationName, - SdkClientConfiguration clientConfiguration) { + private List resolveAuthSchemeOptions(SdkRequest request, + ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); XmlAuthSchemeProvider requestAuthSchemeProvider = request.overrideConfiguration().flatMap(c -> c.authSchemeProvider()) .map(p -> Validate.isInstanceOf(XmlAuthSchemeProvider.class, p, "Expected an instance of XmlAuthSchemeProvider")) .orElse(null); @@ -725,7 +727,8 @@ private List resolveAuthSchemeOptions(SdkRequest request, Stri return options; } - private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes, String operationName) { + private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executionAttributes) { + String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); XmlEndpointProvider provider = (XmlEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { @@ -757,11 +760,11 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return r -> resolveAuthSchemeOptions(r, operationName, clientConfiguration); + return this::resolveAuthSchemeOptions; } private EndpointResolver endpointResolver(String operationName) { - return (r, a) -> resolveEndpoint(r, a, operationName); + return this::resolveEndpoint; } private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { diff --git a/core/sdk-core/pom.xml b/core/sdk-core/pom.xml index 5a65a6f231d5..6880d4fa54a9 100644 --- a/core/sdk-core/pom.xml +++ b/core/sdk-core/pom.xml @@ -294,6 +294,17 @@ + + com.github.siom79.japicmp + japicmp-maven-plugin + + + + software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver#resolve(software.amazon.awssdk.core.SdkRequest) + + + + diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/http/auth/AuthSchemeResolver.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/http/auth/AuthSchemeResolver.java index ac795a34c494..1b5d64324c61 100644 --- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/http/auth/AuthSchemeResolver.java +++ b/core/sdk-core/src/main/java/software/amazon/awssdk/core/http/auth/AuthSchemeResolver.java @@ -82,7 +82,7 @@ public static SelectedAuthScheme resolveAuthScheme( identityProviders = resolver.resolve(request, identityProviders, executionAttributes); } - List authOptions = optionsResolver.resolve(request); + List authOptions = optionsResolver.resolve(request, executionAttributes); return selectAuthScheme(authOptions, authSchemes, identityProviders, null); } diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/AuthSchemeResolutionStage.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/AuthSchemeResolutionStage.java index 831340b29d16..4c1f5d3b4f8d 100644 --- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/AuthSchemeResolutionStage.java +++ b/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/AuthSchemeResolutionStage.java @@ -114,7 +114,7 @@ private List resolveAuthSchemeOptions(ExecutionAttributes exec if (resolver == null) { return null; } - return resolver.resolve(request); + return resolver.resolve(request, executionAttributes); } /** diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/spi/identity/AuthSchemeOptionsResolver.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/spi/identity/AuthSchemeOptionsResolver.java index 7a37d7c3dd6b..8ff1ceedb2ab 100644 --- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/spi/identity/AuthSchemeOptionsResolver.java +++ b/core/sdk-core/src/main/java/software/amazon/awssdk/core/spi/identity/AuthSchemeOptionsResolver.java @@ -18,6 +18,7 @@ import java.util.List; import software.amazon.awssdk.annotations.SdkProtectedApi; import software.amazon.awssdk.core.SdkRequest; +import software.amazon.awssdk.core.interceptor.ExecutionAttributes; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; /** @@ -33,7 +34,8 @@ public interface AuthSchemeOptionsResolver { * Resolves auth scheme options for the given request. * * @param request The request (after interceptors have modified it) + * @param executionAttributes The execution attributes for the current request execution * @return List of auth scheme options in priority order */ - List resolve(SdkRequest request); + List resolve(SdkRequest request, ExecutionAttributes executionAttributes); } diff --git a/core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/http/pipeline/stages/AuthSchemeResolutionStageTest.java b/core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/http/pipeline/stages/AuthSchemeResolutionStageTest.java index 6ab7325a3093..bb20a3b571b3 100644 --- a/core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/http/pipeline/stages/AuthSchemeResolutionStageTest.java +++ b/core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/http/pipeline/stages/AuthSchemeResolutionStageTest.java @@ -17,6 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -100,7 +101,7 @@ void execute_noResolver_returnsRequestUnchanged() throws Exception { void execute_resolverReturnsEmpty_returnsRequestUnchanged() throws Exception { executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEMES, createAuthSchemes()); executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEME_OPTIONS_RESOLVER, - (AuthSchemeOptionsResolver) req -> Collections.emptyList()); + (AuthSchemeOptionsResolver) (req, attrs) -> Collections.emptyList()); SdkHttpFullRequest.Builder result = stage.execute(httpRequestBuilder, context); @@ -126,7 +127,7 @@ void execute_resolverReceivesRequestFromInterceptorContext() throws Exception { .build(); AuthSchemeOptionsResolver resolver = mock(AuthSchemeOptionsResolver.class); - doReturn(createAuthOptions()).when(resolver).resolve(modifiedRequest); + doReturn(createAuthOptions()).when(resolver).resolve(eq(modifiedRequest), any(ExecutionAttributes.class)); executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEMES, createAuthSchemes()); executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEME_OPTIONS_RESOLVER, resolver); @@ -135,7 +136,7 @@ void execute_resolverReceivesRequestFromInterceptorContext() throws Exception { stage.execute(httpRequestBuilder, context); // Verify resolver was called with the MODIFIED request, not originalRequest - verify(resolver).resolve(modifiedRequest); + verify(resolver).resolve(eq(modifiedRequest), any(ExecutionAttributes.class)); } @Test @@ -156,7 +157,7 @@ void execute_withRequestIdentityProviderResolver_callsUpdaterWithRequest() throw executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEMES, authSchemes); executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEME_OPTIONS_RESOLVER, - (AuthSchemeOptionsResolver) req -> createAuthOptions()); + (AuthSchemeOptionsResolver) (req, attrs) -> createAuthOptions()); executionAttributes.putAttribute(SdkInternalExecutionAttribute.IDENTITY_PROVIDERS, baseProviders); executionAttributes.putAttribute(SdkInternalExecutionAttribute.IDENTITY_PROVIDER_RESOLVER, resolver); @@ -169,7 +170,7 @@ void execute_withRequestIdentityProviderResolver_callsUpdaterWithRequest() throw void execute_withoutRequestIdentityProviderResolver_doesNotFail() throws Exception { executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEMES, createAuthSchemes()); executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEME_OPTIONS_RESOLVER, - (AuthSchemeOptionsResolver) req -> createAuthOptions()); + (AuthSchemeOptionsResolver) (req, attrs) -> createAuthOptions()); executionAttributes.putAttribute(SdkInternalExecutionAttribute.IDENTITY_PROVIDERS, createIdentityProviders()); // No IDENTITY_PROVIDER_RESOLVER set @@ -183,7 +184,7 @@ void execute_withoutRequestIdentityProviderResolver_doesNotFail() throws Excepti void execute_happyPath_setsSelectedAuthScheme() throws Exception { executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEMES, createAuthSchemes()); executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEME_OPTIONS_RESOLVER, - (AuthSchemeOptionsResolver) req -> createAuthOptions()); + (AuthSchemeOptionsResolver) (req, attrs) -> createAuthOptions()); executionAttributes.putAttribute(SdkInternalExecutionAttribute.IDENTITY_PROVIDERS, createIdentityProviders()); SdkHttpFullRequest.Builder result = stage.execute(httpRequestBuilder, context); @@ -240,7 +241,7 @@ void execute_authSchemeAlreadyResolved_skipsResolution() throws Exception { executionAttributes.putAttribute(SdkInternalExecutionAttribute.SELECTED_AUTH_SCHEME, alreadyResolved); executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEMES, createAuthSchemes()); executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEME_OPTIONS_RESOLVER, - (AuthSchemeOptionsResolver) req -> createAuthOptions()); + (AuthSchemeOptionsResolver) (req, attrs) -> createAuthOptions()); executionAttributes.putAttribute(SdkInternalExecutionAttribute.IDENTITY_PROVIDERS, createIdentityProviders()); SdkHttpFullRequest.Builder result = stage.execute(httpRequestBuilder, context); @@ -262,7 +263,7 @@ void execute_authSchemeUnset_proceedsWithResolution() throws Exception { executionAttributes.putAttribute(SdkInternalExecutionAttribute.SELECTED_AUTH_SCHEME, unsetPlaceholder); executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEMES, createAuthSchemes()); executionAttributes.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEME_OPTIONS_RESOLVER, - (AuthSchemeOptionsResolver) req -> createAuthOptions()); + (AuthSchemeOptionsResolver) (req, attrs) -> createAuthOptions()); executionAttributes.putAttribute(SdkInternalExecutionAttribute.IDENTITY_PROVIDERS, createIdentityProviders()); stage.execute(httpRequestBuilder, context); diff --git a/services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/s3express/S3ExpressUtils.java b/services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/s3express/S3ExpressUtils.java index 42c7928db434..adddf4270c22 100644 --- a/services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/s3express/S3ExpressUtils.java +++ b/services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/s3express/S3ExpressUtils.java @@ -55,7 +55,7 @@ public static boolean isS3ExpressAuthRequest(SdkRequest request, ExecutionAttrib AuthSchemeOptionsResolver resolver = executionAttributes.getAttribute(SdkInternalExecutionAttribute.AUTH_SCHEME_OPTIONS_RESOLVER); if (resolver != null) { - List options = resolver.resolve(request); + List options = resolver.resolve(request, executionAttributes); return options.stream().anyMatch(o -> S3ExpressAuthScheme.SCHEME_ID.equals(o.schemeId())); } return false; From f081727b1bdb85809ac3ac750032eadfb7e9c3a5 Mon Sep 17 00:00:00 2001 From: Saranya Somepalli Date: Tue, 14 Jul 2026 21:09:47 -0700 Subject: [PATCH 2/3] Update codegen fixture files --- .../codegen/poet/client/ClientClassUtils.java | 3 +- .../test-aws-json-async-client-class.java | 73 ++++----- ...ry-compatible-json-async-client-class.java | 14 +- ...ery-compatible-json-sync-client-class.java | 14 +- .../poet/client/test-batchmanager-async.java | 14 +- .../client/test-cbor-async-client-class.java | 73 ++++----- .../poet/client/test-cbor-client-class.java | 59 +++----- ...tom-context-params-async-client-class.java | 14 +- ...stom-context-params-sync-client-class.java | 14 +- .../poet/client/test-custompackage-async.java | 14 +- .../poet/client/test-custompackage-sync.java | 14 +- .../test-customservicemetadata-async.java | 14 +- .../test-customservicemetadata-sync.java | 14 +- .../client/test-endpoint-discovery-async.java | 29 +--- .../client/test-endpoint-discovery-sync.java | 27 +--- .../client/test-json-async-client-class.java | 139 +++++++----------- .../poet/client/test-json-client-class.java | 67 ++++----- .../poet/client/test-presignedurl-async.java | 14 +- .../client/test-query-async-client-class.java | 80 ++++------ .../poet/client/test-query-client-class.java | 80 ++++------ .../client/test-rpcv2-async-client-class.java | 62 ++++---- .../codegen/poet/client/test-rpcv2-sync.java | 62 ++++---- ...gned-payload-trait-async-client-class.java | 58 +++----- ...igned-payload-trait-sync-client-class.java | 58 +++----- .../client/test-xml-async-client-class.java | 56 +++---- .../poet/client/test-xml-client-class.java | 52 +++---- 26 files changed, 395 insertions(+), 723 deletions(-) diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/ClientClassUtils.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/ClientClassUtils.java index af80ed574c5b..5308c1e41885 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/ClientClassUtils.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/ClientClassUtils.java @@ -373,7 +373,8 @@ static MethodSpec resolveAuthSchemeOptionsMethod(AuthSchemeSpecUtils authSchemeS ClassName providerInterface = authSchemeSpecUtils.providerInterfaceName(); - builder.addStatement("String operationName = executionAttributes.getAttribute($T.OPERATION_NAME)", SdkExecutionAttribute.class); + builder.addStatement("String operationName = executionAttributes.getAttribute($T.OPERATION_NAME)", + SdkExecutionAttribute.class); // Check for request-level authSchemeProvider override builder.addStatement("$T requestAuthSchemeProvider = request.overrideConfiguration()" diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-json-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-json-async-client-class.java index 53fb1bfaf719..8139867d4e48 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-json-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-json-async-client-class.java @@ -46,7 +46,6 @@ import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.AttachHttpMetadataResponseHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -58,7 +57,6 @@ import software.amazon.awssdk.core.protocol.VoidSdkResponse; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -239,8 +237,8 @@ public CompletableFuture aPostOperation(APostOperationRe .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -319,8 +317,8 @@ public CompletableFuture aPostOperationWithOut .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperationWithOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperationWithOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(aPostOperationWithOutputRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -429,8 +427,8 @@ public CompletableFuture eventStreamOperation(EventStreamOperationRequest .withInitialRequestEvent(true).withResponseHandler(voidResponseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("EventStreamOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("EventStreamOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(eventStreamOperationRequest), asyncResponseTransformer); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { @@ -526,9 +524,8 @@ public CompletableFuture eventStreamO .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("EventStreamOperationWithOnlyInput", clientConfiguration)) - .withEndpointResolver(endpointResolver("EventStreamOperationWithOnlyInput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(eventStreamOperationWithOnlyInputRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -635,9 +632,8 @@ public CompletableFuture eventStreamOperationWithOnlyOutput( .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("EventStreamOperationWithOnlyOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("EventStreamOperationWithOnlyOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(eventStreamOperationWithOnlyOutputRequest), asyncResponseTransformer); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { @@ -724,8 +720,8 @@ public CompletableFuture getWithoutRequiredMe .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetWithoutRequiredMembers", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetWithoutRequiredMembers")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(getWithoutRequiredMembersRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -803,9 +799,8 @@ public CompletableFuture operationWithChe .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithChecksumRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithChecksumRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { @@ -880,8 +875,8 @@ public CompletableFuture operationWithNoneAut .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithNoneAuthType", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithNoneAuthType")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(operationWithNoneAuthTypeRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -959,9 +954,8 @@ public CompletableFuture operationWithR .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithRequestCompression", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithRequestCompression")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); @@ -1041,9 +1035,8 @@ public CompletableFuture paginatedOpera .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("PaginatedOperationWithResultKey", clientConfiguration)) - .withEndpointResolver(endpointResolver("PaginatedOperationWithResultKey")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(paginatedOperationWithResultKeyRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -1121,9 +1114,8 @@ public CompletableFuture paginatedOp .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("PaginatedOperationWithoutResultKey", clientConfiguration)) - .withEndpointResolver(endpointResolver("PaginatedOperationWithoutResultKey")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(paginatedOperationWithoutResultKeyRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -1206,8 +1198,8 @@ public CompletableFuture streamingInputOperatio .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingInputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOperation")).withAsyncRequestBody(requestBody) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -1304,9 +1296,8 @@ public CompletableFuture streamingInputOutputOperation( .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("StreamingInputOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withAsyncRequestBody(requestBody).withAsyncResponseTransformer(asyncResponseTransformer) .withInput(streamingInputOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer finalAsyncResponseTransformer = asyncResponseTransformer; @@ -1401,8 +1392,8 @@ public CompletableFuture streamingOutputOperation( .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withAsyncResponseTransformer(asyncResponseTransformer).withInput(streamingOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer finalAsyncResponseTransformer = asyncResponseTransformer; @@ -1506,14 +1497,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-async-client-class.java index ae7f5aa63782..cd856e6db56a 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-async-client-class.java @@ -31,7 +31,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -39,7 +38,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -157,8 +155,8 @@ public CompletableFuture aPostOperation(APostOperationRe .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -254,14 +252,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-sync-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-sync-client-class.java index 7dae6de6b59c..6bc6ff1df942 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-sync-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-sync-client-class.java @@ -26,7 +26,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -34,7 +33,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -148,8 +146,8 @@ public APostOperationResponse aPostOperation(APostOperationRequest aPostOperatio .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -228,14 +226,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) { return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-batchmanager-async.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-batchmanager-async.java index fca61faec4b1..c41403c27d28 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-batchmanager-async.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-batchmanager-async.java @@ -32,7 +32,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -40,7 +39,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -149,8 +147,8 @@ public CompletableFuture sendRequest(SendRequestRequest sen .withMarshaller(new SendRequestRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("SendRequest", clientConfiguration)) - .withEndpointResolver(endpointResolver("SendRequest")).withInput(sendRequestRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(sendRequestRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -250,14 +248,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-async-client-class.java index 47cadbf55270..7a01aaf36212 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-async-client-class.java @@ -46,7 +46,6 @@ import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.AttachHttpMetadataResponseHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -58,7 +57,6 @@ import software.amazon.awssdk.core.protocol.VoidSdkResponse; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -243,8 +241,8 @@ public CompletableFuture aPostOperation(APostOperationRe .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -323,8 +321,8 @@ public CompletableFuture aPostOperationWithOut .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperationWithOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperationWithOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(aPostOperationWithOutputRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -433,8 +431,8 @@ public CompletableFuture eventStreamOperation(EventStreamOperationRequest .withInitialRequestEvent(true).withResponseHandler(voidResponseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("EventStreamOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("EventStreamOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(eventStreamOperationRequest), asyncResponseTransformer); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { @@ -530,9 +528,8 @@ public CompletableFuture eventStreamO .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("EventStreamOperationWithOnlyInput", clientConfiguration)) - .withEndpointResolver(endpointResolver("EventStreamOperationWithOnlyInput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(eventStreamOperationWithOnlyInputRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -639,9 +636,8 @@ public CompletableFuture eventStreamOperationWithOnlyOutput( .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("EventStreamOperationWithOnlyOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("EventStreamOperationWithOnlyOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(eventStreamOperationWithOnlyOutputRequest), asyncResponseTransformer); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { @@ -728,8 +724,8 @@ public CompletableFuture getWithoutRequiredMe .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetWithoutRequiredMembers", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetWithoutRequiredMembers")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(getWithoutRequiredMembersRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -807,9 +803,8 @@ public CompletableFuture operationWithChe .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithChecksumRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithChecksumRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { @@ -884,8 +879,8 @@ public CompletableFuture operationWithNoneAut .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithNoneAuthType", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithNoneAuthType")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(operationWithNoneAuthTypeRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -963,9 +958,8 @@ public CompletableFuture operationWithR .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithRequestCompression", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithRequestCompression")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); @@ -1045,9 +1039,8 @@ public CompletableFuture paginatedOpera .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("PaginatedOperationWithResultKey", clientConfiguration)) - .withEndpointResolver(endpointResolver("PaginatedOperationWithResultKey")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(paginatedOperationWithResultKeyRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -1125,9 +1118,8 @@ public CompletableFuture paginatedOp .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("PaginatedOperationWithoutResultKey", clientConfiguration)) - .withEndpointResolver(endpointResolver("PaginatedOperationWithoutResultKey")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(paginatedOperationWithoutResultKeyRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -1210,8 +1202,8 @@ public CompletableFuture streamingInputOperatio .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingInputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOperation")).withAsyncRequestBody(requestBody) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -1308,9 +1300,8 @@ public CompletableFuture streamingInputOutputOperation( .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("StreamingInputOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withAsyncRequestBody(requestBody).withAsyncResponseTransformer(asyncResponseTransformer) .withInput(streamingInputOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer finalAsyncResponseTransformer = asyncResponseTransformer; @@ -1405,8 +1396,8 @@ public CompletableFuture streamingOutputOperation( .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withAsyncResponseTransformer(asyncResponseTransformer).withInput(streamingOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer finalAsyncResponseTransformer = asyncResponseTransformer; @@ -1510,14 +1501,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-client-class.java index ee92563199e3..d1e5c410eff4 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-cbor-client-class.java @@ -26,7 +26,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -37,7 +36,6 @@ import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.endpoints.Endpoint; @@ -187,8 +185,8 @@ public APostOperationResponse aPostOperation(APostOperationRequest aPostOperatio .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -258,8 +256,8 @@ public APostOperationWithOutputResponse aPostOperationWithOutput( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperationWithOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperationWithOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -328,8 +326,8 @@ public GetWithoutRequiredMembersResponse getWithoutRequiredMembers( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(getWithoutRequiredMembersRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetWithoutRequiredMembers", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetWithoutRequiredMembers")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -397,9 +395,8 @@ public OperationWithChecksumRequiredResponse operationWithChecksumRequired( .withRequestConfiguration(clientConfiguration) .withInput(operationWithChecksumRequiredRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithChecksumRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithChecksumRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))); @@ -466,8 +463,8 @@ public OperationWithNoneAuthTypeResponse operationWithNoneAuthType( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(operationWithNoneAuthTypeRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithNoneAuthType", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithNoneAuthType")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -535,9 +532,8 @@ public OperationWithRequestCompressionResponse operationWithRequestCompression( .withRequestConfiguration(clientConfiguration) .withInput(operationWithRequestCompressionRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithRequestCompression", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithRequestCompression")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))); @@ -607,9 +603,8 @@ public PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey( .withRequestConfiguration(clientConfiguration) .withInput(paginatedOperationWithResultKeyRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("PaginatedOperationWithResultKey", clientConfiguration)) - .withEndpointResolver(endpointResolver("PaginatedOperationWithResultKey")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -677,9 +672,8 @@ public PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResul .withRequestConfiguration(clientConfiguration) .withInput(paginatedOperationWithoutResultKeyRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("PaginatedOperationWithoutResultKey", clientConfiguration)) - .withEndpointResolver(endpointResolver("PaginatedOperationWithoutResultKey")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -757,8 +751,8 @@ public StreamingInputOperationResponse streamingInputOperation(StreamingInputOpe .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingInputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() @@ -849,9 +843,8 @@ public ReturnT streamingInputOutputOperation( .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("StreamingInputOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withResponseTransformer(responseTransformer) .withRequestBody(requestBody) .withMarshaller( @@ -930,8 +923,8 @@ public ReturnT streamingOutputOperation(StreamingOutputOperationReques .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withResponseTransformer(responseTransformer) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer); } finally { @@ -1017,14 +1010,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) { return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-async-client-class.java index e26ea1e04bab..be31fa2ad73a 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-async-client-class.java @@ -32,7 +32,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -40,7 +39,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -150,8 +148,8 @@ public CompletableFuture getDatabaseVersion(GetDatab .withMarshaller(new GetDatabaseVersionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetDatabaseVersion", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetDatabaseVersion")).withInput(getDatabaseVersionRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(getDatabaseVersionRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -242,14 +240,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-sync-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-sync-client-class.java index 348d11110353..be6cb2ea23b5 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-sync-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custom-context-params-sync-client-class.java @@ -27,7 +27,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -35,7 +34,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -141,8 +139,8 @@ public GetDatabaseVersionResponse getDatabaseVersion(GetDatabaseVersionRequest g .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(getDatabaseVersionRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetDatabaseVersion", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetDatabaseVersion")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new GetDatabaseVersionRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -218,14 +216,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) { return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-async.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-async.java index 58a4cb4039ce..f5a16493b5f0 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-async.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-async.java @@ -42,7 +42,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -50,7 +49,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -147,8 +145,8 @@ public CompletableFuture oneOperation(OneOperationRequest .withMarshaller(new OneOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OneOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("OneOperation")).withInput(oneOperationRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(oneOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -245,14 +243,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-sync.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-sync.java index ad765db19086..3f8ca1f64223 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-sync.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-custompackage-sync.java @@ -37,7 +37,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -45,7 +44,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -138,8 +136,8 @@ public OneOperationResponse oneOperation(OneOperationRequest oneOperationRequest .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(oneOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OneOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("OneOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OneOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -219,14 +217,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) { return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-async.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-async.java index 8c27e34bbb64..40f921c632b4 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-async.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-async.java @@ -31,7 +31,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -39,7 +38,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -147,8 +145,8 @@ public CompletableFuture oneOperation(OneOperationRequest .withMarshaller(new OneOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OneOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("OneOperation")).withInput(oneOperationRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(oneOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -245,14 +243,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-sync.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-sync.java index 4e1be19ea70d..81b91d1edba8 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-sync.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-sync.java @@ -26,7 +26,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -34,7 +33,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -138,8 +136,8 @@ public OneOperationResponse oneOperation(OneOperationRequest oneOperationRequest .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(oneOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OneOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("OneOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OneOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -219,14 +217,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) { return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java index 9563ff7d3ac0..6b7b9721d28f 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java @@ -33,7 +33,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRefreshCache; import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRequest; import software.amazon.awssdk.core.exception.SdkClientException; @@ -43,7 +42,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity; @@ -163,8 +161,8 @@ public CompletableFuture describeEndpoints(DescribeEn .withMarshaller(new DescribeEndpointsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("DescribeEndpoints", clientConfiguration)) - .withEndpointResolver(endpointResolver("DescribeEndpoints")).withInput(describeEndpointsRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(describeEndpointsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -262,9 +260,8 @@ public CompletableFuture testDiscovery .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("TestDiscoveryIdentifiersRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("TestDiscoveryIdentifiersRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .discoveredEndpoint(cachedEndpoint).withInput(testDiscoveryIdentifiersRequiredRequest))); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -353,9 +350,8 @@ public CompletableFuture testDiscoveryOptional( .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("TestDiscoveryOptional", clientConfiguration)) - .withEndpointResolver(endpointResolver("TestDiscoveryOptional")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .discoveredEndpoint(cachedEndpoint).withInput(testDiscoveryOptionalRequest))); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -452,9 +448,8 @@ public CompletableFuture testDiscoveryRequired( .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("TestDiscoveryRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("TestDiscoveryRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .discoveredEndpoint(cachedEndpoint).withInput(testDiscoveryRequiredRequest))); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -550,14 +545,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java index 0bdd98491481..f367ed07f9e3 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java @@ -29,7 +29,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRefreshCache; import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRequest; import software.amazon.awssdk.core.exception.SdkClientException; @@ -39,7 +38,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity; @@ -156,8 +154,8 @@ public DescribeEndpointsResponse describeEndpoints(DescribeEndpointsRequest desc .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(describeEndpointsRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("DescribeEndpoints", clientConfiguration)) - .withEndpointResolver(endpointResolver("DescribeEndpoints")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new DescribeEndpointsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -239,9 +237,8 @@ public TestDiscoveryIdentifiersRequiredResponse testDiscoveryIdentifiersRequired .withRequestConfiguration(clientConfiguration) .withInput(testDiscoveryIdentifiersRequiredRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("TestDiscoveryIdentifiersRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("TestDiscoveryIdentifiersRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new TestDiscoveryIdentifiersRequiredRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -309,8 +306,8 @@ public TestDiscoveryOptionalResponse testDiscoveryOptional(TestDiscoveryOptional .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .discoveredEndpoint(cachedEndpoint).withRequestConfiguration(clientConfiguration) .withInput(testDiscoveryOptionalRequest).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("TestDiscoveryOptional", clientConfiguration)) - .withEndpointResolver(endpointResolver("TestDiscoveryOptional")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new TestDiscoveryOptionalRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -386,8 +383,8 @@ public TestDiscoveryRequiredResponse testDiscoveryRequired(TestDiscoveryRequired .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .discoveredEndpoint(cachedEndpoint).withRequestConfiguration(clientConfiguration) .withInput(testDiscoveryRequiredRequest).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("TestDiscoveryRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("TestDiscoveryRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new TestDiscoveryRequiredRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -466,14 +463,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) { return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-class.java index eb9bf60b1768..7534713aa4e7 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-class.java @@ -50,7 +50,6 @@ import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.AttachHttpMetadataResponseHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -63,7 +62,6 @@ import software.amazon.awssdk.core.protocol.VoidSdkResponse; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -250,9 +248,9 @@ public CompletableFuture aPostOperation(APostOperationRe .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")) - .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).hostPrefixExpression(resolvedHostExpression) + .withInput(aPostOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -326,9 +324,8 @@ public CompletableFuture aPostOperationWithOut .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperationWithOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperationWithOutput")) - .withInput(aPostOperationWithOutputRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(aPostOperationWithOutputRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -398,8 +395,8 @@ public CompletableFuture bearerAuthOperation( .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("BearerAuthOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("BearerAuthOperation")).credentialType(CredentialType.TOKEN) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).credentialType(CredentialType.TOKEN) .withInput(bearerAuthOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -514,9 +511,9 @@ public CompletableFuture eventStreamOperation(EventStreamOperationRequest .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("EventStreamOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("EventStreamOperation")) - .withInput(eventStreamOperationRequest), restAsyncResponseTransformer); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(eventStreamOperationRequest), + restAsyncResponseTransformer); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { try { @@ -599,18 +596,13 @@ public CompletableFuture eventStreamO CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() - .withOperationName("EventStreamOperationWithOnlyInput") - .withProtocolMetadata(protocolMetadata) + .withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory)) - .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)) - .withResponseHandler(responseHandler) - .withErrorResponseHandler(errorResponseHandler) - .withRequestConfiguration(clientConfiguration) + .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withResponseHandler(responseHandler) + .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("EventStreamOperationWithOnlyInput", clientConfiguration)) - .withEndpointResolver(endpointResolver("EventStreamOperationWithOnlyInput")) - .withInput(eventStreamOperationWithOnlyInputRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(eventStreamOperationWithOnlyInputRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -720,13 +712,10 @@ public CompletableFuture eventStreamOperationWithOnlyOutput( .withOperationName("EventStreamOperationWithOnlyOutput") .withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationWithOnlyOutputRequestMarshaller(protocolFactory)) - .withResponseHandler(responseHandler) - .withErrorResponseHandler(errorResponseHandler) - .withRequestConfiguration(clientConfiguration) - .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("EventStreamOperationWithOnlyOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("EventStreamOperationWithOnlyOutput")) + .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) + .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(eventStreamOperationWithOnlyOutputRequest), restAsyncResponseTransformer); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { @@ -809,8 +798,8 @@ public CompletableFuture getOperationWithCheck .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true).isRequestStreaming(false) @@ -890,9 +879,8 @@ public CompletableFuture getWithoutRequiredMe .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetWithoutRequiredMembers", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetWithoutRequiredMembers")) - .withInput(getWithoutRequiredMembersRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(getWithoutRequiredMembersRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -966,9 +954,8 @@ public CompletableFuture operationWithChe .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithChecksumRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithChecksumRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { @@ -1044,9 +1031,8 @@ public CompletableFuture operationWithR .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithRequestCompression", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithRequestCompression")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); @@ -1116,17 +1102,12 @@ public CompletableFuture paginatedOpera CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() - .withOperationName("PaginatedOperationWithResultKey") - .withProtocolMetadata(protocolMetadata) + .withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata) .withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory)) - .withResponseHandler(responseHandler) - .withErrorResponseHandler(errorResponseHandler) - .withRequestConfiguration(clientConfiguration) - .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("PaginatedOperationWithResultKey", clientConfiguration)) - .withEndpointResolver(endpointResolver("PaginatedOperationWithResultKey")) - .withInput(paginatedOperationWithResultKeyRequest)); + .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) + .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(paginatedOperationWithResultKeyRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -1193,17 +1174,12 @@ public CompletableFuture paginatedOp CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() - .withOperationName("PaginatedOperationWithoutResultKey") - .withProtocolMetadata(protocolMetadata) + .withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata) .withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory)) - .withResponseHandler(responseHandler) - .withErrorResponseHandler(errorResponseHandler) - .withRequestConfiguration(clientConfiguration) - .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("PaginatedOperationWithoutResultKey", clientConfiguration)) - .withEndpointResolver(endpointResolver("PaginatedOperationWithoutResultKey")) - .withInput(paginatedOperationWithoutResultKeyRequest)); + .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) + .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(paginatedOperationWithoutResultKeyRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -1302,8 +1278,8 @@ public CompletableFuture putOperationWithChecksum( .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("PutOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("PutOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withAsyncRequestBody(requestBody) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, @@ -1410,8 +1386,8 @@ public CompletableFuture streamingInputOperatio .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingInputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOperation")).withAsyncRequestBody(requestBody) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -1501,14 +1477,11 @@ public CompletableFuture streamingInputOutputOperation( .delegateMarshaller( new StreamingInputOutputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).transferEncoding(true).build()) - .withResponseHandler(responseHandler) - .withErrorResponseHandler(errorResponseHandler) - .withRequestConfiguration(clientConfiguration) - .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("StreamingInputOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOutputOperation")) - .withAsyncRequestBody(requestBody).withAsyncResponseTransformer(asyncResponseTransformer) + .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) + .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withAsyncRequestBody(requestBody) + .withAsyncResponseTransformer(asyncResponseTransformer) .withInput(streamingInputOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { @@ -1599,10 +1572,9 @@ public CompletableFuture streamingOutputOperation( .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingOutputOperation")) - .withAsyncResponseTransformer(asyncResponseTransformer).withInput(streamingOutputOperationRequest), - asyncResponseTransformer); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withAsyncResponseTransformer(asyncResponseTransformer) + .withInput(streamingOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { @@ -1659,8 +1631,7 @@ private static List resolveMetricPublishers(SdkClientConfigurat return publishers; } - private List resolveAuthSchemeOptions(SdkRequest request, - ExecutionAttributes executionAttributes) { + private List resolveAuthSchemeOptions(SdkRequest request, ExecutionAttributes executionAttributes) { String operationName = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); JsonAuthSchemeProvider requestAuthSchemeProvider = request .overrideConfiguration() @@ -1709,14 +1680,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); @@ -1763,4 +1726,4 @@ private HttpResponseHandler createErrorResponseHandler(Base public void close() { clientHandler.close(); } -} +} \ No newline at end of file diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java index 2366eae28bf2..a4703d2fc939 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java @@ -28,7 +28,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -40,7 +39,6 @@ import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.endpoints.Endpoint; @@ -192,8 +190,8 @@ public APostOperationResponse aPostOperation(APostOperationRequest aPostOperatio .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -259,8 +257,8 @@ public APostOperationWithOutputResponse aPostOperationWithOutput( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperationWithOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperationWithOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -320,8 +318,8 @@ public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationReques .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withInput(bearerAuthOperationRequest).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("BearerAuthOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("BearerAuthOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -386,8 +384,8 @@ public GetOperationWithChecksumResponse getOperationWithChecksum( .withRequestConfiguration(clientConfiguration) .withInput(getOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true).isRequestStreaming(false) @@ -458,8 +456,8 @@ public GetWithoutRequiredMembersResponse getWithoutRequiredMembers( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(getWithoutRequiredMembersRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetWithoutRequiredMembers", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetWithoutRequiredMembers")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -524,9 +522,8 @@ public OperationWithChecksumRequiredResponse operationWithChecksumRequired( .withRequestConfiguration(clientConfiguration) .withInput(operationWithChecksumRequiredRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithChecksumRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithChecksumRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))); @@ -593,9 +590,8 @@ public OperationWithRequestCompressionResponse operationWithRequestCompression( .withRequestConfiguration(clientConfiguration) .withInput(operationWithRequestCompressionRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithRequestCompression", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithRequestCompression")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))); @@ -662,9 +658,8 @@ public PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey( .withRequestConfiguration(clientConfiguration) .withInput(paginatedOperationWithResultKeyRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("PaginatedOperationWithResultKey", clientConfiguration)) - .withEndpointResolver(endpointResolver("PaginatedOperationWithResultKey")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -729,9 +724,8 @@ public PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResul .withRequestConfiguration(clientConfiguration) .withInput(paginatedOperationWithoutResultKeyRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("PaginatedOperationWithoutResultKey", clientConfiguration)) - .withEndpointResolver(endpointResolver("PaginatedOperationWithoutResultKey")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -822,8 +816,8 @@ public ReturnT putOperationWithChecksum(PutOperationWithChecksumReques .withRequestConfiguration(clientConfiguration) .withInput(putOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("PutOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("PutOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum @@ -918,8 +912,8 @@ public StreamingInputOperationResponse streamingInputOperation(StreamingInputOpe .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingInputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() @@ -1007,9 +1001,8 @@ public ReturnT streamingInputOutputOperation( .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("StreamingInputOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withResponseTransformer(responseTransformer) .withRequestBody(requestBody) .withMarshaller( @@ -1085,8 +1078,8 @@ public ReturnT streamingOutputOperation(StreamingOutputOperationReques .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withResponseTransformer(responseTransformer) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer); } finally { @@ -1172,14 +1165,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) { return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-presignedurl-async.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-presignedurl-async.java index 9b49f8d804dd..ba36ff5d4c1e 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-presignedurl-async.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-presignedurl-async.java @@ -31,7 +31,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -39,7 +38,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -154,8 +152,8 @@ public CompletableFuture aPostOperation(APostOperationRe .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")).withInput(aPostOperationRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(aPostOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -252,14 +250,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-async-client-class.java index bd1211a534ae..73dfda7afe68 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-async-client-class.java @@ -37,7 +37,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -49,7 +48,6 @@ import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -197,8 +195,8 @@ public CompletableFuture aPostOperation(APostOperationRe .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -259,8 +257,8 @@ public CompletableFuture aPostOperationWithOut .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperationWithOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperationWithOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(aPostOperationWithOutputRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -318,8 +316,8 @@ public CompletableFuture bearerAuthOperation( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("BearerAuthOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("BearerAuthOperation")).withInput(bearerAuthOperationRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(bearerAuthOperationRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -378,8 +376,8 @@ public CompletableFuture getOperationWithCheck .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true).isRequestStreaming(false) @@ -445,9 +443,8 @@ public CompletableFuture operationWithChe .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithChecksumRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithChecksumRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture whenCompleteFuture = null; @@ -505,8 +502,8 @@ public CompletableFuture operationWithContext .withMarshaller(new OperationWithContextParamRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithContextParam", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithContextParam")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(operationWithContextParamRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -564,8 +561,8 @@ public CompletableFuture operationWithCustomM .withMarshaller(new OperationWithCustomMemberRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithCustomMember", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithCustomMember")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(operationWithCustomMemberRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -627,9 +624,8 @@ public CompletableFuture o .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithCustomizedOperationContextParam", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithCustomizedOperationContextParam")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(operationWithCustomizedOperationContextParamRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -691,9 +687,8 @@ public CompletableFuture operatio .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithMapOperationContextParam", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithMapOperationContextParam")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(operationWithMapOperationContextParamRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -750,8 +745,8 @@ public CompletableFuture operationWithNoneAut .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithNoneAuthType", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithNoneAuthType")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(operationWithNoneAuthTypeRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -813,9 +808,8 @@ public CompletableFuture operationWi .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithOperationContextParam", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithOperationContextParam")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(operationWithOperationContextParamRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -876,9 +870,8 @@ public CompletableFuture operationWithR .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithRequestCompression", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithRequestCompression")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); @@ -941,9 +934,8 @@ public CompletableFuture operationWith .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithStaticContextParams", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithStaticContextParams")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(operationWithStaticContextParamsRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -1029,8 +1021,8 @@ public CompletableFuture putOperationWithChecksum( .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("PutOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("PutOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum @@ -1120,8 +1112,8 @@ public CompletableFuture streamingInputOperatio .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingInputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOperation")).withAsyncRequestBody(requestBody) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -1188,8 +1180,8 @@ public CompletableFuture streamingOutputOperation( .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withAsyncResponseTransformer(asyncResponseTransformer).withInput(streamingOutputOperationRequest), asyncResponseTransformer); CompletableFuture whenCompleteFuture = null; @@ -1301,14 +1293,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java index f7ee672b074f..f55b6b271a6a 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java @@ -28,7 +28,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -40,7 +39,6 @@ import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.endpoints.Endpoint; @@ -182,8 +180,8 @@ public APostOperationResponse aPostOperation(APostOperationRequest aPostOperatio .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -235,8 +233,8 @@ public APostOperationWithOutputResponse aPostOperationWithOutput( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperationWithOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperationWithOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -282,8 +280,8 @@ public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationReques .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withInput(bearerAuthOperationRequest).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("BearerAuthOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("BearerAuthOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -334,8 +332,8 @@ public GetOperationWithChecksumResponse getOperationWithChecksum( .withRequestConfiguration(clientConfiguration) .withInput(getOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true).isRequestStreaming(false) @@ -391,9 +389,8 @@ public OperationWithChecksumRequiredResponse operationWithChecksumRequired( .withRequestConfiguration(clientConfiguration) .withInput(operationWithChecksumRequiredRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithChecksumRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithChecksumRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))); @@ -443,8 +440,8 @@ public OperationWithContextParamResponse operationWithContextParam( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(operationWithContextParamRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithContextParam", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithContextParam")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OperationWithContextParamRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -493,8 +490,8 @@ public OperationWithCustomMemberResponse operationWithCustomMember( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(operationWithCustomMemberRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithCustomMember", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithCustomMember")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OperationWithCustomMemberRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -546,9 +543,8 @@ public OperationWithCustomizedOperationContextParamResponse operationWithCustomi .withRequestConfiguration(clientConfiguration) .withInput(operationWithCustomizedOperationContextParamRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithCustomizedOperationContextParam", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithCustomizedOperationContextParam")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OperationWithCustomizedOperationContextParamRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -600,9 +596,8 @@ public OperationWithMapOperationContextParamResponse operationWithMapOperationCo .withRequestConfiguration(clientConfiguration) .withInput(operationWithMapOperationContextParamRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithMapOperationContextParam", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithMapOperationContextParam")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OperationWithMapOperationContextParamRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -650,8 +645,8 @@ public OperationWithNoneAuthTypeResponse operationWithNoneAuthType( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(operationWithNoneAuthTypeRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithNoneAuthType", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithNoneAuthType")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -703,9 +698,8 @@ public OperationWithOperationContextParamResponse operationWithOperationContextP .withRequestConfiguration(clientConfiguration) .withInput(operationWithOperationContextParamRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithOperationContextParam", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithOperationContextParam")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OperationWithOperationContextParamRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -756,9 +750,8 @@ public OperationWithRequestCompressionResponse operationWithRequestCompression( .withRequestConfiguration(clientConfiguration) .withInput(operationWithRequestCompressionRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithRequestCompression", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithRequestCompression")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))); @@ -811,9 +804,8 @@ public OperationWithStaticContextParamsResponse operationWithStaticContextParams .withRequestConfiguration(clientConfiguration) .withInput(operationWithStaticContextParamsRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithStaticContextParams", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithStaticContextParams")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OperationWithStaticContextParamsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -890,8 +882,8 @@ public ReturnT putOperationWithChecksum(PutOperationWithChecksumReques .withRequestConfiguration(clientConfiguration) .withInput(putOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("PutOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("PutOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum @@ -970,8 +962,8 @@ public StreamingInputOperationResponse streamingInputOperation(StreamingInputOpe .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingInputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() @@ -1030,8 +1022,8 @@ public ReturnT streamingOutputOperation(StreamingOutputOperationReques .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withResponseTransformer(responseTransformer) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer); } finally { @@ -1121,14 +1113,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-async-client-class.java index c3e94c0cf84a..b00674af953c 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-async-client-class.java @@ -31,7 +31,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -39,7 +38,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -193,8 +191,8 @@ public CompletableFuture emptyInputOutput(EmptyInputOu .withMarshaller(new EmptyInputOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("EmptyInputOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("EmptyInputOutput")).withInput(emptyInputOutputRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(emptyInputOutputRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -267,8 +265,8 @@ public CompletableFuture float16(Float16Request float16Request) .withProtocolMetadata(protocolMetadata).withMarshaller(new Float16RequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("Float16", clientConfiguration)) - .withEndpointResolver(endpointResolver("Float16")).withInput(float16Request)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(float16Request)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -343,8 +341,8 @@ public CompletableFuture fractionalSeconds(Fractional .withMarshaller(new FractionalSecondsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("FractionalSeconds", clientConfiguration)) - .withEndpointResolver(endpointResolver("FractionalSeconds")).withInput(fractionalSecondsRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(fractionalSecondsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -421,8 +419,8 @@ public CompletableFuture greetingWithErrors(Greeting .withMarshaller(new GreetingWithErrorsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GreetingWithErrors", clientConfiguration)) - .withEndpointResolver(endpointResolver("GreetingWithErrors")).withInput(greetingWithErrorsRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(greetingWithErrorsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -496,8 +494,8 @@ public CompletableFuture noInputOutput(NoInputOutputReque .withMarshaller(new NoInputOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("NoInputOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("NoInputOutput")).withInput(noInputOutputRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(noInputOutputRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -574,8 +572,8 @@ public CompletableFuture operationWithDefaults( .withMarshaller(new OperationWithDefaultsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithDefaults", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithDefaults")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(operationWithDefaultsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -652,8 +650,8 @@ public CompletableFuture optionalInputOutput( .withMarshaller(new OptionalInputOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OptionalInputOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("OptionalInputOutput")).withInput(optionalInputOutputRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(optionalInputOutputRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -728,8 +726,8 @@ public CompletableFuture recursiveShapes(RecursiveShape .withMarshaller(new RecursiveShapesRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("RecursiveShapes", clientConfiguration)) - .withEndpointResolver(endpointResolver("RecursiveShapes")).withInput(recursiveShapesRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(recursiveShapesRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -805,8 +803,8 @@ public CompletableFuture rpcV2CborDenseMaps(RpcV2Cbo .withMarshaller(new RpcV2CborDenseMapsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("RpcV2CborDenseMaps", clientConfiguration)) - .withEndpointResolver(endpointResolver("RpcV2CborDenseMaps")).withInput(rpcV2CborDenseMapsRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(rpcV2CborDenseMapsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -881,8 +879,8 @@ public CompletableFuture rpcV2CborLists(RpcV2CborListsRe .withMarshaller(new RpcV2CborListsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("RpcV2CborLists", clientConfiguration)) - .withEndpointResolver(endpointResolver("RpcV2CborLists")).withInput(rpcV2CborListsRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(rpcV2CborListsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -959,8 +957,8 @@ public CompletableFuture rpcV2CborSparseMaps( .withMarshaller(new RpcV2CborSparseMapsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("RpcV2CborSparseMaps", clientConfiguration)) - .withEndpointResolver(endpointResolver("RpcV2CborSparseMaps")).withInput(rpcV2CborSparseMapsRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(rpcV2CborSparseMapsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -1036,8 +1034,8 @@ public CompletableFuture simpleScalarProperties( .withMarshaller(new SimpleScalarPropertiesRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("SimpleScalarProperties", clientConfiguration)) - .withEndpointResolver(endpointResolver("SimpleScalarProperties")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(simpleScalarPropertiesRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -1114,8 +1112,8 @@ public CompletableFuture sparseNullsOperation( .withMarshaller(new SparseNullsOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("SparseNullsOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("SparseNullsOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(sparseNullsOperationRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -1211,14 +1209,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-sync.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-sync.java index b905359a09d7..cde52df725a5 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-sync.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-rpcv2-sync.java @@ -26,7 +26,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -34,7 +33,6 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -184,8 +182,8 @@ public EmptyInputOutputResponse emptyInputOutput(EmptyInputOutputRequest emptyIn .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(emptyInputOutputRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("EmptyInputOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("EmptyInputOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new EmptyInputOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -249,8 +247,8 @@ public Float16Response float16(Float16Request float16Request) throws AwsServiceE .withOperationName("Float16").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withInput(float16Request).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("Float16", clientConfiguration)) - .withEndpointResolver(endpointResolver("Float16")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new Float16RequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -316,8 +314,8 @@ public FractionalSecondsResponse fractionalSeconds(FractionalSecondsRequest frac .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(fractionalSecondsRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("FractionalSeconds", clientConfiguration)) - .withEndpointResolver(endpointResolver("FractionalSeconds")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new FractionalSecondsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -386,8 +384,8 @@ public GreetingWithErrorsResponse greetingWithErrors(GreetingWithErrorsRequest g .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(greetingWithErrorsRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GreetingWithErrors", clientConfiguration)) - .withEndpointResolver(endpointResolver("GreetingWithErrors")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new GreetingWithErrorsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -452,8 +450,8 @@ public NoInputOutputResponse noInputOutput(NoInputOutputRequest noInputOutputReq .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(noInputOutputRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("NoInputOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("NoInputOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new NoInputOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -520,8 +518,8 @@ public OperationWithDefaultsResponse operationWithDefaults(OperationWithDefaults .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(operationWithDefaultsRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithDefaults", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithDefaults")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OperationWithDefaultsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -587,8 +585,8 @@ public OptionalInputOutputResponse optionalInputOutput(OptionalInputOutputReques .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(optionalInputOutputRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OptionalInputOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("OptionalInputOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OptionalInputOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -654,8 +652,8 @@ public RecursiveShapesResponse recursiveShapes(RecursiveShapesRequest recursiveS .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(recursiveShapesRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("RecursiveShapes", clientConfiguration)) - .withEndpointResolver(endpointResolver("RecursiveShapes")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new RecursiveShapesRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -722,8 +720,8 @@ public RpcV2CborDenseMapsResponse rpcV2CborDenseMaps(RpcV2CborDenseMapsRequest r .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(rpcV2CborDenseMapsRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("RpcV2CborDenseMaps", clientConfiguration)) - .withEndpointResolver(endpointResolver("RpcV2CborDenseMaps")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new RpcV2CborDenseMapsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -789,8 +787,8 @@ public RpcV2CborListsResponse rpcV2CborLists(RpcV2CborListsRequest rpcV2CborList .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(rpcV2CborListsRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("RpcV2CborLists", clientConfiguration)) - .withEndpointResolver(endpointResolver("RpcV2CborLists")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new RpcV2CborListsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -857,8 +855,8 @@ public RpcV2CborSparseMapsResponse rpcV2CborSparseMaps(RpcV2CborSparseMapsReques .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(rpcV2CborSparseMapsRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("RpcV2CborSparseMaps", clientConfiguration)) - .withEndpointResolver(endpointResolver("RpcV2CborSparseMaps")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new RpcV2CborSparseMapsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -925,8 +923,8 @@ public SimpleScalarPropertiesResponse simpleScalarProperties(SimpleScalarPropert .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(simpleScalarPropertiesRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("SimpleScalarProperties", clientConfiguration)) - .withEndpointResolver(endpointResolver("SimpleScalarProperties")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new SimpleScalarPropertiesRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -992,8 +990,8 @@ public SparseNullsOperationResponse sparseNullsOperation(SparseNullsOperationReq .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(sparseNullsOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("SparseNullsOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("SparseNullsOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new SparseNullsOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -1072,14 +1070,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) { return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-async-client-class.java index 646fddc2c0ae..f3139c1e33a6 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-async-client-class.java @@ -33,7 +33,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -42,7 +41,6 @@ import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.aws.scheme.AwsV4aAuthScheme; import software.amazon.awssdk.http.auth.aws.signer.AwsV4aHttpSigner; @@ -189,8 +187,8 @@ public CompletableFuture deleteRow(DeleteRowRequest deleteRow .withMarshaller(new DeleteRowRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("DeleteRow", clientConfiguration)) - .withEndpointResolver(endpointResolver("DeleteRow")).withInput(deleteRowRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(deleteRowRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -261,8 +259,8 @@ public CompletableFuture getRow(GetRowRequest getRowRequest) { .withProtocolMetadata(protocolMetadata).withMarshaller(new GetRowRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetRow", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetRow")).withInput(getRowRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(getRowRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -341,9 +339,8 @@ public CompletableFuture opWithSigv .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("opWithSigv4AndSigv4aUnSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4AndSigv4aUnSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(opWithSigv4AndSigv4AUnSignedPayloadRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -418,8 +415,8 @@ public CompletableFuture opWithSigv4SignedPayl .withMarshaller(new OpWithSigv4SignedPayloadRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("opWithSigv4SignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4SignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(opWithSigv4SignedPayloadRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -494,8 +491,8 @@ public CompletableFuture opWithSigv4UnSigned .withMarshaller(new OpWithSigv4UnSignedPayloadRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("opWithSigv4UnSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4UnSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(opWithSigv4UnSignedPayloadRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -586,9 +583,8 @@ public CompletableFuture opWithS .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("opWithSigv4UnSignedPayloadAndStreaming", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4UnSignedPayloadAndStreaming")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withAsyncRequestBody(requestBody).withInput(opWithSigv4UnSignedPayloadAndStreamingRequest)); CompletableFuture whenCompleted = executeFuture .whenComplete((r, e) -> { @@ -664,8 +660,8 @@ public CompletableFuture opWithSigv4aSignedPa .withMarshaller(new OpWithSigv4ASignedPayloadRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("opWithSigv4aSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4aSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(opWithSigv4ASignedPayloadRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -743,8 +739,8 @@ public CompletableFuture opWithSigv4aUnSign .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("opWithSigv4aUnSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4aUnSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(opWithSigv4AUnSignedPayloadRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -824,9 +820,8 @@ public CompletableFuture opsWithSigv .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("opsWithSigv4andSigv4aSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opsWithSigv4andSigv4aSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(opsWithSigv4AndSigv4ASignedPayloadRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -898,8 +893,8 @@ public CompletableFuture putRow(PutRowRequest putRowRequest) { .withProtocolMetadata(protocolMetadata).withMarshaller(new PutRowRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("PutRow", clientConfiguration)) - .withEndpointResolver(endpointResolver("PutRow")).withInput(putRowRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(putRowRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); @@ -978,9 +973,8 @@ public CompletableFuture secon .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("secondOpsWithSigv4andSigv4aSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("secondOpsWithSigv4andSigv4aSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(secondOpsWithSigv4AndSigv4ASignedPayloadRequest)); CompletableFuture whenCompleted = executeFuture .whenComplete((r, e) -> { @@ -1086,14 +1080,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-sync-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-sync-client-class.java index 3c2b2586018a..ff744cbe5358 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-sync-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-unsigned-payload-trait-sync-client-class.java @@ -27,7 +27,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -36,7 +35,6 @@ import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.aws.scheme.AwsV4aAuthScheme; @@ -179,8 +177,8 @@ public DeleteRowResponse deleteRow(DeleteRowRequest deleteRowRequest) throws Inv .withOperationName("DeleteRow").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withInput(deleteRowRequest).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("DeleteRow", clientConfiguration)) - .withEndpointResolver(endpointResolver("DeleteRow")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new DeleteRowRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -242,8 +240,8 @@ public GetRowResponse getRow(GetRowRequest getRowRequest) throws InvalidInputExc .withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withInput(getRowRequest).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetRow", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetRow")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new GetRowRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -305,8 +303,8 @@ public PutRowResponse putRow(PutRowRequest putRowRequest) throws InvalidInputExc .withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withInput(putRowRequest).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("PutRow", clientConfiguration)) - .withEndpointResolver(endpointResolver("PutRow")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new PutRowRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -376,9 +374,8 @@ public OpWithSigv4AndSigv4AUnSignedPayloadResponse opWithSigv4AndSigv4aUnSignedP .withRequestConfiguration(clientConfiguration) .withInput(opWithSigv4AndSigv4AUnSignedPayloadRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("opWithSigv4AndSigv4aUnSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4AndSigv4aUnSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OpWithSigv4AndSigv4AUnSignedPayloadRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -444,8 +441,8 @@ public OpWithSigv4SignedPayloadResponse opWithSigv4SignedPayload( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(opWithSigv4SignedPayloadRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("opWithSigv4SignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4SignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OpWithSigv4SignedPayloadRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -511,8 +508,8 @@ public OpWithSigv4UnSignedPayloadResponse opWithSigv4UnSignedPayload( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(opWithSigv4UnSignedPayloadRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("opWithSigv4UnSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4UnSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OpWithSigv4UnSignedPayloadRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -593,9 +590,8 @@ public OpWithSigv4UnSignedPayloadAndStreamingResponse opWithSigv4UnSignedPayload .withRequestConfiguration(clientConfiguration) .withInput(opWithSigv4UnSignedPayloadAndStreamingRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("opWithSigv4UnSignedPayloadAndStreaming", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4UnSignedPayloadAndStreaming")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller @@ -667,8 +663,8 @@ public OpWithSigv4ASignedPayloadResponse opWithSigv4aSignedPayload( .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(opWithSigv4ASignedPayloadRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("opWithSigv4aSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4aSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OpWithSigv4ASignedPayloadRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -737,8 +733,8 @@ public OpWithSigv4AUnSignedPayloadResponse opWithSigv4aUnSignedPayload( .withRequestConfiguration(clientConfiguration) .withInput(opWithSigv4AUnSignedPayloadRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("opWithSigv4aUnSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opWithSigv4aUnSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OpWithSigv4AUnSignedPayloadRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -808,9 +804,8 @@ public OpsWithSigv4AndSigv4ASignedPayloadResponse opsWithSigv4andSigv4aSignedPay .withRequestConfiguration(clientConfiguration) .withInput(opsWithSigv4AndSigv4ASignedPayloadRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("opsWithSigv4andSigv4aSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("opsWithSigv4andSigv4aSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OpsWithSigv4AndSigv4ASignedPayloadRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -880,9 +875,8 @@ public SecondOpsWithSigv4AndSigv4ASignedPayloadResponse secondOpsWithSigv4andSig .withRequestConfiguration(clientConfiguration) .withInput(secondOpsWithSigv4AndSigv4ASignedPayloadRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("secondOpsWithSigv4andSigv4aSignedPayload", clientConfiguration)) - .withEndpointResolver(endpointResolver("secondOpsWithSigv4andSigv4aSignedPayload")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new SecondOpsWithSigv4AndSigv4ASignedPayloadRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -971,14 +965,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) { return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-async-client-class.java index 55b15053ca03..fab57fdc507e 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-async-client-class.java @@ -42,7 +42,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -54,7 +53,6 @@ import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.metrics.MetricCollector; @@ -189,8 +187,8 @@ public CompletableFuture aPostOperation(APostOperationRe .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).hostPrefixExpression(resolvedHostExpression) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")).withInput(aPostOperationRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(aPostOperationRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -250,8 +248,8 @@ public CompletableFuture aPostOperationWithOut .withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperationWithOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperationWithOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(aPostOperationWithOutputRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -309,8 +307,8 @@ public CompletableFuture bearerAuthOperation( .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).credentialType(CredentialType.TOKEN) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("BearerAuthOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("BearerAuthOperation")).withInput(bearerAuthOperationRequest)); + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withInput(bearerAuthOperationRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -384,8 +382,8 @@ public CompletableFuture eventStreamOperation(EventStreamOperationRequest .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("EventStreamOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("EventStreamOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(eventStreamOperationRequest), restAsyncResponseTransformer); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -451,8 +449,8 @@ public CompletableFuture getOperationWithCheck .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true).isRequestStreaming(false) @@ -517,9 +515,8 @@ public CompletableFuture operationWithChe .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithChecksumRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithChecksumRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture whenCompleteFuture = null; @@ -577,8 +574,8 @@ public CompletableFuture operationWithNoneAut .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithNoneAuthType", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithNoneAuthType")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withInput(operationWithNoneAuthTypeRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -638,9 +635,8 @@ public CompletableFuture operationWithR .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithRequestCompression", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithRequestCompression")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); @@ -729,8 +725,8 @@ public CompletableFuture putOperationWithChecksum( .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("PutOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("PutOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum @@ -819,8 +815,8 @@ public CompletableFuture streamingInputOperatio .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()).withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingInputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOperation")).withAsyncRequestBody(requestBody) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { @@ -888,8 +884,8 @@ public CompletableFuture streamingOutputOperation( .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withAsyncResponseTransformer(asyncResponseTransformer).withInput(streamingOutputOperationRequest), asyncResponseTransformer); CompletableFuture whenCompleteFuture = null; @@ -994,14 +990,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-client-class.java index dbd6992da9f8..f322289628f4 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-client-class.java @@ -28,7 +28,6 @@ import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; -import software.amazon.awssdk.core.endpoint.EndpointResolver; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -40,7 +39,6 @@ import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller; -import software.amazon.awssdk.core.spi.identity.AuthSchemeOptionsResolver; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.endpoints.Endpoint; @@ -162,8 +160,8 @@ public APostOperationResponse aPostOperation(APostOperationRequest aPostOperatio .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -213,8 +211,8 @@ public APostOperationWithOutputResponse aPostOperationWithOutput( .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest) - .withAuthSchemeOptionsResolver(authSchemeResolver("APostOperationWithOutput", clientConfiguration)) - .withEndpointResolver(endpointResolver("APostOperationWithOutput")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -259,8 +257,8 @@ public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationReques .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withInput(bearerAuthOperationRequest) - .withAuthSchemeOptionsResolver(authSchemeResolver("BearerAuthOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("BearerAuthOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -309,8 +307,8 @@ public GetOperationWithChecksumResponse getOperationWithChecksum( .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(getOperationWithChecksumRequest) - .withAuthSchemeOptionsResolver(authSchemeResolver("GetOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("GetOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true).isRequestStreaming(false) @@ -364,9 +362,8 @@ public OperationWithChecksumRequiredResponse operationWithChecksumRequired( .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(operationWithChecksumRequiredRequest) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithChecksumRequired", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithChecksumRequired")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))); @@ -414,8 +411,8 @@ public OperationWithNoneAuthTypeResponse operationWithNoneAuthType( .withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration).withInput(operationWithNoneAuthTypeRequest) - .withAuthSchemeOptionsResolver(authSchemeResolver("OperationWithNoneAuthType", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithNoneAuthType")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); @@ -464,9 +461,8 @@ public OperationWithRequestCompressionResponse operationWithRequestCompression( .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(operationWithRequestCompressionRequest) - .withAuthSchemeOptionsResolver( - authSchemeResolver("OperationWithRequestCompression", clientConfiguration)) - .withEndpointResolver(endpointResolver("OperationWithRequestCompression")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))); @@ -545,8 +541,8 @@ public ReturnT putOperationWithChecksum(PutOperationWithChecksumReques .withRequestConfiguration(clientConfiguration) .withInput(putOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("PutOperationWithChecksum", clientConfiguration)) - .withEndpointResolver(endpointResolver("PutOperationWithChecksum")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum @@ -623,8 +619,8 @@ public StreamingInputOperationResponse streamingInputOperation(StreamingInputOpe .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOperationRequest) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingInputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingInputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() @@ -683,8 +679,8 @@ public ReturnT streamingOutputOperation(StreamingOutputOperationReques .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) - .withAuthSchemeOptionsResolver(authSchemeResolver("StreamingOutputOperation", clientConfiguration)) - .withEndpointResolver(endpointResolver("StreamingOutputOperation")) + .withAuthSchemeOptionsResolver(this::resolveAuthSchemeOptions) + .withEndpointResolver(this::resolveEndpoint) .withResponseTransformer(responseTransformer) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer); } finally { @@ -759,14 +755,6 @@ private Endpoint resolveEndpoint(SdkRequest request, ExecutionAttributes executi } } - private AuthSchemeOptionsResolver authSchemeResolver(String operationName, SdkClientConfiguration clientConfiguration) { - return this::resolveAuthSchemeOptions; - } - - private EndpointResolver endpointResolver(String operationName) { - return this::resolveEndpoint; - } - private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); From 9ef62630e344f03a783072cdc9f9342b451406b9 Mon Sep 17 00:00:00 2001 From: Saranya Somepalli Date: Tue, 14 Jul 2026 21:58:18 -0700 Subject: [PATCH 3/3] Fix tests --- .../transform/internal/GeneratePreSignUrlInterceptorTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ec2/src/test/java/software/amazon/awssdk/services/ec2/transform/internal/GeneratePreSignUrlInterceptorTest.java b/services/ec2/src/test/java/software/amazon/awssdk/services/ec2/transform/internal/GeneratePreSignUrlInterceptorTest.java index 3ae2c4dc5c6e..4bc8b2350422 100644 --- a/services/ec2/src/test/java/software/amazon/awssdk/services/ec2/transform/internal/GeneratePreSignUrlInterceptorTest.java +++ b/services/ec2/src/test/java/software/amazon/awssdk/services/ec2/transform/internal/GeneratePreSignUrlInterceptorTest.java @@ -142,7 +142,7 @@ private static void addSraAttributes(ExecutionAttributes attrs, AwsBasicCredenti attrs.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEMES, authSchemes); attrs.putAttribute(SdkInternalExecutionAttribute.IDENTITY_PROVIDERS, identityProviders); attrs.putAttribute(SdkInternalExecutionAttribute.AUTH_SCHEME_OPTIONS_RESOLVER, - request -> Collections.singletonList( + (request, executionAttributes) -> Collections.singletonList( software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption.builder() .schemeId(authScheme.schemeId()) .putSignerProperty(software.amazon.awssdk.http.auth.aws.signer.AwsV4FamilyHttpSigner