-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move QueryParametersToBodyInterceptor to front of interceptor chain (#…
…4109) * Move QueryParametersToBodyInterceptor to front of interceptor chain * Move customization.config interceptors to front of interceptor chain - for query protocols * Refactoring * Add codegen tests * Refactoring * Refactoring
- Loading branch information
Showing
10 changed files
with
261 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...test/java/software/amazon/awssdk/codegen/internal/QueryProtocolCustomTestInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package software.amazon.awssdk.codegen.internal; | ||
|
||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.codegen.poet.builder.BuilderClassTest; | ||
|
||
/** | ||
* Empty no-op test interceptor for query protocols to view generated code in test-query-sync-client-builder-class.java and | ||
* test-query-async-client-builder-class.java and validate in {@link BuilderClassTest}. | ||
*/ | ||
@SdkInternalApi | ||
public class QueryProtocolCustomTestInterceptor { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...es/software/amazon/awssdk/codegen/poet/builder/test-query-async-client-builder-class.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package software.amazon.awssdk.services.query; | ||
|
||
import java.net.URI; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import software.amazon.awssdk.annotations.Generated; | ||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.auth.token.credentials.SdkTokenProvider; | ||
import software.amazon.awssdk.awscore.client.config.AwsClientOption; | ||
import software.amazon.awssdk.codegen.internal.QueryProtocolCustomTestInterceptor; | ||
import software.amazon.awssdk.core.client.config.SdkClientConfiguration; | ||
import software.amazon.awssdk.core.client.config.SdkClientOption; | ||
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; | ||
import software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor; | ||
import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider; | ||
import software.amazon.awssdk.utils.CollectionUtils; | ||
|
||
/** | ||
* Internal implementation of {@link QueryAsyncClientBuilder}. | ||
*/ | ||
@Generated("software.amazon.awssdk:codegen") | ||
@SdkInternalApi | ||
final class DefaultQueryAsyncClientBuilder extends DefaultQueryBaseClientBuilder<QueryAsyncClientBuilder, QueryAsyncClient> | ||
implements QueryAsyncClientBuilder { | ||
@Override | ||
public DefaultQueryAsyncClientBuilder endpointProvider(QueryEndpointProvider endpointProvider) { | ||
clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER, endpointProvider); | ||
return this; | ||
} | ||
|
||
@Override | ||
public DefaultQueryAsyncClientBuilder tokenProvider(SdkTokenProvider tokenProvider) { | ||
clientConfiguration.option(AwsClientOption.TOKEN_PROVIDER, tokenProvider); | ||
return this; | ||
} | ||
|
||
@Override | ||
protected final QueryAsyncClient buildClient() { | ||
SdkClientConfiguration clientConfiguration = super.asyncClientConfiguration(); | ||
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(); | ||
this.validateClientOptions(clientConfiguration); | ||
URI endpointOverride = null; | ||
if (clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) != null | ||
&& Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN))) { | ||
endpointOverride = clientConfiguration.option(SdkClientOption.ENDPOINT); | ||
} | ||
QueryServiceClientConfiguration serviceClientConfiguration = QueryServiceClientConfiguration.builder() | ||
.overrideConfiguration(overrideConfiguration()).region(clientConfiguration.option(AwsClientOption.AWS_REGION)) | ||
.endpointOverride(endpointOverride).build(); | ||
return new DefaultQueryAsyncClient(serviceClientConfiguration, clientConfiguration); | ||
} | ||
} |
Oops, something went wrong.