Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Move QueryParametersToBodyInterceptor to pipeline stage #4561

Merged
merged 14 commits into from
Oct 23, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public Map<String, OperationModel> constructOperations() {
OperationModel operationModel = new OperationModel();

operationModel.setOperationName(operationName);
operationModel.setServiceProtocol(serviceModel.getMetadata().getProtocol());
operationModel.setDeprecated(op.isDeprecated());
operationModel.setDeprecatedMessage(op.getDeprecatedMessage());
operationModel.setDocumentation(op.getDocumentation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class OperationModel extends DocumentationModel {

private String operationName;

private String serviceProtocol;

private boolean deprecated;

private String deprecatedMessage;
Expand Down Expand Up @@ -93,6 +95,14 @@ public String getMethodName() {
return Utils.unCapitalize(operationName);
}

public String getServiceProtocol() {
return serviceProtocol;
}

public void setServiceProtocol(String serviceProtocol) {
this.serviceProtocol = serviceProtocol;
}

public boolean isDeprecated() {
return deprecated;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.identity.spi.TokenIdentity;
import software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor;
import software.amazon.awssdk.utils.AttributeMap;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.StringUtils;
Expand Down Expand Up @@ -343,17 +342,6 @@ private MethodSpec finalizeServiceConfigurationMethod() {

builder.addCode("interceptors = $T.mergeLists(interceptors, config.option($T.EXECUTION_INTERCEPTORS));\n",
CollectionUtils.class, SdkClientOption.class);

if (model.getMetadata().isQueryProtocol()) {
TypeName listType = ParameterizedTypeName.get(List.class, ExecutionInterceptor.class);
builder.addStatement("$T protocolInterceptors = $T.singletonList(new $T())",
listType,
Collections.class,
QueryParametersToBodyInterceptor.class);
builder.addStatement("interceptors = $T.mergeLists(interceptors, protocolInterceptors)",
CollectionUtils.class);
}

if (model.getEndpointOperation().isPresent()) {
builder.beginControlFlow("if (!endpointDiscoveryEnabled)")
.addStatement("$1T chain = new $1T(config)", DefaultEndpointDiscoveryProviderChain.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public CodeBlock executionHandler(OperationModel opModel) {
.add("\n\nreturn clientHandler.execute(new $T<$T, $T>()\n",
ClientExecutionParams.class, requestType, responseType)
.add(".withOperationName(\"$N\")\n", opModel.getOperationName())
.add(".withServiceProtocol($S)\n", opModel.getServiceProtocol())
.add(".withResponseHandler(responseHandler)\n")
.add(".withErrorResponseHandler(errorResponseHandler)\n")
.add(hostPrefixExpression(opModel))
Expand Down Expand Up @@ -254,6 +255,7 @@ public CodeBlock asyncExecutionHandler(IntermediateModel intermediateModel, Oper
.add(opModel.getEndpointDiscovery() != null ? "endpointFuture.thenCompose(cachedEndpoint -> " : "")
.add("clientHandler.execute(new $T<$T, $T>()\n", ClientExecutionParams.class, requestType, responseType)
.add(".withOperationName(\"$N\")\n", opModel.getOperationName())
.add(".withServiceProtocol($S)\n", opModel.getServiceProtocol())
.add(".withMarshaller($L)\n", asyncMarshaller(model, opModel, marshaller, protocolFactory))
.add(asyncRequestBody(opModel))
.add(fullDuplex(opModel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public CodeBlock executionHandler(OperationModel opModel) {
.add("\n\nreturn clientHandler.execute(new $T<$T, $T>()",
ClientExecutionParams.class, requestType, responseType)
.add(".withOperationName($S)\n", opModel.getOperationName())
.add(".withServiceProtocol($S)\n", opModel.getServiceProtocol())
.add(".withResponseHandler(responseHandler)\n")
.add(".withErrorResponseHandler(errorResponseHandler)\n")
.add(hostPrefixExpression(opModel))
Expand Down Expand Up @@ -152,6 +153,7 @@ public CodeBlock asyncExecutionHandler(IntermediateModel intermediateModel, Oper
CompletableFuture.class, executeFutureValueType, ClientExecutionParams.class,
requestType, pojoResponseType)
.add(".withOperationName(\"$N\")\n", opModel.getOperationName())
.add(".withServiceProtocol($S)\n", opModel.getServiceProtocol())
.add(".withMarshaller($L)\n",
asyncMarshaller(intermediateModel, opModel, marshaller, "protocolFactory"))
.add(".withResponseHandler(responseHandler)\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public CodeBlock executionHandler(OperationModel opModel) {
.add("\n\nreturn clientHandler.execute(new $T<$T, $T>()\n",
ClientExecutionParams.class, requestType, responseType)
.add(".withOperationName($S)\n", opModel.getOperationName())
.add(".withServiceProtocol($S)\n", opModel.getServiceProtocol())
.add(".withCombinedResponseHandler(responseHandler)\n")
.add(".withMetricCollector(apiCallMetricCollector)\n" +
hostPrefixExpression(opModel) +
Expand Down Expand Up @@ -204,6 +205,7 @@ public CodeBlock asyncExecutionHandler(IntermediateModel intermediateModel, Oper
ClientExecutionParams.class, requestType, pojoResponseType)
.add(".withOperationName(\"$N\")\n", opModel.getOperationName())
.add(".withRequestConfiguration(clientConfiguration)")
.add(".withServiceProtocol($S)\n", opModel.getServiceProtocol())
.add(".withMarshaller($L)\n", asyncMarshaller(intermediateModel, opModel, marshaller, "protocolFactory"));

if (opModel.hasEventStreamOutput()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.identity.spi.TokenIdentity;
import software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor;
import software.amazon.awssdk.services.query.auth.scheme.QueryAuthSchemeProvider;
import software.amazon.awssdk.services.query.auth.scheme.internal.QueryAuthSchemeInterceptor;
import software.amazon.awssdk.services.query.endpoints.QueryClientContextParams;
Expand Down Expand Up @@ -76,8 +75,6 @@ protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientCon
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
List<ExecutionInterceptor> protocolInterceptors = Collections.singletonList(new QueryParametersToBodyInterceptor());
interceptors = CollectionUtils.mergeLists(interceptors, protocolInterceptors);
SdkClientConfiguration.Builder builder = config.toBuilder();
IdentityProvider<? extends TokenIdentity> identityProvider = config.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (identityProvider != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.identity.spi.TokenIdentity;
import software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor;
import software.amazon.awssdk.services.query.auth.scheme.QueryAuthSchemeProvider;
import software.amazon.awssdk.services.query.auth.scheme.internal.QueryAuthSchemeInterceptor;
import software.amazon.awssdk.services.query.endpoints.QueryClientContextParams;
Expand Down Expand Up @@ -75,8 +74,6 @@ protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientCon
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
List<ExecutionInterceptor> protocolInterceptors = Collections.singletonList(new QueryParametersToBodyInterceptor());
interceptors = CollectionUtils.mergeLists(interceptors, protocolInterceptors);
SdkClientConfiguration.Builder builder = config.toBuilder();
IdentityProvider<? extends TokenIdentity> identityProvider = config.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (identityProvider != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package software.amazon.awssdk.services.query;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
Expand All @@ -21,7 +20,6 @@
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.identity.spi.TokenIdentity;
import software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor;
import software.amazon.awssdk.services.query.endpoints.QueryClientContextParams;
import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider;
import software.amazon.awssdk.services.query.endpoints.internal.QueryRequestSetEndpointInterceptor;
Expand Down Expand Up @@ -68,8 +66,6 @@ protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientCon
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
List<ExecutionInterceptor> protocolInterceptors = Collections.singletonList(new QueryParametersToBodyInterceptor());
interceptors = CollectionUtils.mergeLists(interceptors, protocolInterceptors);
SdkClientConfiguration.Builder builder = config.toBuilder();
IdentityProvider<? extends TokenIdentity> identityProvider = config.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (identityProvider != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.endpoints.EndpointProvider;
import software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor;
import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider;
import software.amazon.awssdk.utils.CollectionUtils;

Expand Down Expand Up @@ -42,11 +41,8 @@ protected final QueryAsyncClient buildClient() {
this.validateClientOptions(clientConfiguration);
QueryServiceClientConfiguration serviceClientConfiguration = initializeServiceClientConfig(clientConfiguration);
List<ExecutionInterceptor> interceptors = clientConfiguration.option(SdkClientOption.EXECUTION_INTERCEPTORS);
List<ExecutionInterceptor> queryParamsToBodyInterceptor = Collections
.singletonList(new QueryParametersToBodyInterceptor());
List<ExecutionInterceptor> customizationInterceptors = new ArrayList<>();
customizationInterceptors.add(new QueryProtocolCustomTestInterceptor());
interceptors = CollectionUtils.mergeLists(queryParamsToBodyInterceptor, interceptors);
interceptors = CollectionUtils.mergeLists(customizationInterceptors, interceptors);
clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors)
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package software.amazon.awssdk.services.query;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
Expand All @@ -21,7 +20,6 @@
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.identity.spi.TokenIdentity;
import software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor;
import software.amazon.awssdk.services.query.endpoints.QueryClientContextParams;
import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider;
import software.amazon.awssdk.services.query.endpoints.internal.QueryRequestSetEndpointInterceptor;
Expand Down Expand Up @@ -68,8 +66,6 @@ protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientCon
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
List<ExecutionInterceptor> protocolInterceptors = Collections.singletonList(new QueryParametersToBodyInterceptor());
interceptors = CollectionUtils.mergeLists(interceptors, protocolInterceptors);
SdkClientConfiguration.Builder builder = config.toBuilder();
IdentityProvider<? extends TokenIdentity> identityProvider = config.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (identityProvider != null) {
Expand Down
Loading
Loading