index int64 0 0 | repo_id stringlengths 9 205 | file_path stringlengths 31 246 | content stringlengths 1 12.2M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-sync-client-builder-interface.java | /*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.services.json;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.client.builder.AwsSyncClientBuilder;
/**
* A builder for creating an instance of {@link JsonClient}. This can be created with the static
* {@link JsonClient#builder()} method.
*/
@Generated("software.amazon.awssdk:codegen")
public interface JsonClientBuilder extends AwsSyncClientBuilder<JsonClientBuilder, JsonClient>,
JsonBaseClientBuilder<JsonClientBuilder, JsonClient> {
}
| 3,500 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-customcontextparams-sync-client-builder-class.java | package software.amazon.awssdk.services.json;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.auth.token.credentials.SdkTokenProvider;
import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.TokenIdentity;
import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;
/**
* This includes configuration specific to Json Service that is supported by both {@link JsonClientBuilder} and
* {@link JsonAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkPublicApi
public interface JsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsClientBuilder<B, C> {
B serviceConfiguration(ServiceConfiguration serviceConfiguration);
default B serviceConfiguration(Consumer<ServiceConfiguration.Builder> serviceConfiguration) {
return serviceConfiguration(ServiceConfiguration.builder().applyMutation(serviceConfiguration).build());
}
/**
* Set the {@link JsonEndpointProvider} implementation that will be used by the client to determine the endpoint for
* each request. This is optional; if none is provided a default implementation will be used the SDK.
*/
default B endpointProvider(JsonEndpointProvider endpointProvider) {
throw new UnsupportedOperationException();
}
/**
* Set the {@link JsonAuthSchemeProvider} implementation that will be used by the client to resolve the auth scheme
* for each request. This is optional; if none is provided a default implementation will be used the SDK.
*/
default B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) {
throw new UnsupportedOperationException();
}
/**
* Enables this client to use Custom Parameter
*/
B customParameter(Boolean customParameter);
/**
* Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will
* use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}.
* <p>
* If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this
* token provider to retrieve the token to use for authorization.
* <p>
* This provider works in conjunction with the
* {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By
* default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}.
*/
default B tokenProvider(SdkTokenProvider tokenProvider) {
return tokenProvider((IdentityProvider<? extends TokenIdentity>) tokenProvider);
}
/**
* Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will
* use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}.
* <p>
* If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this
* token provider to retrieve the token to use for authorization.
* <p>
* This provider works in conjunction with the
* {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By
* default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}.
*/
default B tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) {
throw new UnsupportedOperationException();
}
}
| 3,501 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-query-async-client-builder-class.java | 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.endpoints.EndpointProvider;
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();
this.validateClientOptions(clientConfiguration);
QueryServiceClientConfiguration serviceClientConfiguration = initializeServiceClientConfig(clientConfiguration);
List<ExecutionInterceptor> interceptors = clientConfiguration.option(SdkClientOption.EXECUTION_INTERCEPTORS);
List<ExecutionInterceptor> customizationInterceptors = new ArrayList<>();
customizationInterceptors.add(new QueryProtocolCustomTestInterceptor());
interceptors = CollectionUtils.mergeLists(customizationInterceptors, interceptors);
clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors)
.build();
QueryAsyncClient client = new DefaultQueryAsyncClient(serviceClientConfiguration, clientConfiguration);
return client;
}
private QueryServiceClientConfiguration initializeServiceClientConfig(SdkClientConfiguration clientConfig) {
URI endpointOverride = null;
EndpointProvider endpointProvider = clientConfig.option(SdkClientOption.ENDPOINT_PROVIDER);
if (clientConfig.option(SdkClientOption.ENDPOINT_OVERRIDDEN) != null
&& Boolean.TRUE.equals(clientConfig.option(SdkClientOption.ENDPOINT_OVERRIDDEN))) {
endpointOverride = clientConfig.option(SdkClientOption.ENDPOINT);
}
return QueryServiceClientConfiguration.builder().overrideConfiguration(overrideConfiguration())
.region(clientConfig.option(AwsClientOption.AWS_REGION)).endpointOverride(endpointOverride)
.endpointProvider(endpointProvider).build();
}
} | 3,502 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-async-client-builder-interface.java | /*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.services.json;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.client.builder.AwsAsyncClientBuilder;
/**
* A builder for creating an instance of {@link JsonAsyncClient}. This can be created with the static
* {@link JsonAsyncClient#builder()} method.
*/
@Generated("software.amazon.awssdk:codegen")
public interface JsonAsyncClientBuilder extends AwsAsyncClientBuilder<JsonAsyncClientBuilder, JsonAsyncClient>,
JsonBaseClientBuilder<JsonAsyncClientBuilder, JsonAsyncClient> {
}
| 3,503 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-composed-async-client-builder-class.java | package software.amazon.awssdk.services.json;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.TokenIdentity;
import software.amazon.awssdk.services.builder.AsyncClientDecorator;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;
/**
* Internal implementation of {@link JsonAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultJsonAsyncClientBuilder extends DefaultJsonBaseClientBuilder<JsonAsyncClientBuilder, JsonAsyncClient> implements
JsonAsyncClientBuilder {
@Override
public DefaultJsonAsyncClientBuilder endpointProvider(JsonEndpointProvider endpointProvider) {
clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER, endpointProvider);
return this;
}
@Override
public DefaultJsonAsyncClientBuilder tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) {
clientConfiguration.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, tokenProvider);
return this;
}
@Override
protected final JsonAsyncClient buildClient() {
SdkClientConfiguration clientConfiguration = super.asyncClientConfiguration();
this.validateClientOptions(clientConfiguration);
JsonAsyncClient client = new DefaultJsonAsyncClient(clientConfiguration);
return new AsyncClientDecorator().decorate(client, clientConfiguration, clientContextParams.copy().build());
}
}
| 3,504 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-client-builder-interface.java | package software.amazon.awssdk.services.json;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.auth.token.credentials.SdkTokenProvider;
import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.TokenIdentity;
import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;
/**
* This includes configuration specific to Json Service that is supported by both {@link JsonClientBuilder} and
* {@link JsonAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkPublicApi
public interface JsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsClientBuilder<B, C> {
B serviceConfiguration(ServiceConfiguration serviceConfiguration);
default B serviceConfiguration(Consumer<ServiceConfiguration.Builder> serviceConfiguration) {
return serviceConfiguration(ServiceConfiguration.builder().applyMutation(serviceConfiguration).build());
}
/**
* Set the {@link JsonEndpointProvider} implementation that will be used by the client to determine the endpoint for
* each request. This is optional; if none is provided a default implementation will be used the SDK.
*/
default B endpointProvider(JsonEndpointProvider endpointProvider) {
throw new UnsupportedOperationException();
}
/**
* Set the {@link JsonAuthSchemeProvider} implementation that will be used by the client to resolve the auth scheme for
* each request. This is optional; if none is provided a default implementation will be used the SDK.
*/
default B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) {
throw new UnsupportedOperationException();
}
/**
* Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will
* use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}.
* <p>
* If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this
* token provider to retrieve the token to use for authorization.
* <p>
* This provider works in conjunction with the
* {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By
* default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}.
*/
default B tokenProvider(SdkTokenProvider tokenProvider) {
return tokenProvider((IdentityProvider<? extends TokenIdentity>) tokenProvider);
}
/**
* Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will
* use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}.
* <p>
* If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this
* token provider to retrieve the token to use for authorization.
* <p>
* This provider works in conjunction with the
* {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By
* default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}.
*/
default B tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) {
throw new UnsupportedOperationException();
}
}
| 3,505 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-client-builder-internal-defaults-class.java | package software.amazon.awssdk.services.json;
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.signer.Aws4Signer;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.core.retry.RetryMode;
import software.amazon.awssdk.core.signer.Signer;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;
import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
/**
* Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> {
@Override
protected final String serviceEndpointPrefix() {
return "json-service-endpoint";
}
@Override
protected final String serviceName() {
return "Json";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkAdvancedClientOption.SIGNER, defaultSigner())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false));
}
@Override
protected final SdkClientConfiguration mergeInternalDefaults(SdkClientConfiguration config) {
return config.merge(c -> {
c.option(SdkClientOption.INTERNAL_USER_AGENT, "md/foobar");
c.option(SdkClientOption.DEFAULT_RETRY_MODE, RetryMode.STANDARD);
});
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new JsonResolveEndpointInterceptor());
endpointInterceptors.add(new JsonRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/json/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
if (credentialsIdentityProvider != null) {
result.putIdentityProvider(credentialsIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors);
return builder.build();
}
private Signer defaultSigner() {
return Aws4Signer.create();
}
@Override
protected final String signingName() {
return "json-service";
}
private JsonEndpointProvider defaultEndpointProvider() {
return JsonEndpointProvider.defaultProvider();
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
Validate.notNull(c.option(SdkAdvancedClientOption.SIGNER),
"The 'overrideConfiguration.advancedOption[SIGNER]' must be configured in the client builder.");
}
}
| 3,506 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-no-auth-ops-client-builder-class.java | package software.amazon.awssdk.services.database;
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.signer.Aws4Signer;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.core.signer.Signer;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.services.database.endpoints.DatabaseEndpointProvider;
import software.amazon.awssdk.services.database.endpoints.internal.DatabaseRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.database.endpoints.internal.DatabaseResolveEndpointInterceptor;
import software.amazon.awssdk.services.database.internal.DatabaseServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
/**
* Internal base class for {@link DefaultDatabaseClientBuilder} and {@link DefaultDatabaseAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultDatabaseBaseClientBuilder<B extends DatabaseBaseClientBuilder<B, C>, C> extends
AwsDefaultClientBuilder<B, C> {
@Override
protected final String serviceEndpointPrefix() {
return "database-service-endpoint";
}
@Override
protected final String serviceName() {
return "Database";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkAdvancedClientOption.SIGNER, defaultSigner())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new DatabaseResolveEndpointInterceptor());
endpointInterceptors.add(new DatabaseRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/database/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
if (credentialsIdentityProvider != null) {
result.putIdentityProvider(credentialsIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors);
return builder.build();
}
private Signer defaultSigner() {
return Aws4Signer.create();
}
@Override
protected final String signingName() {
return "database-service";
}
private DatabaseEndpointProvider defaultEndpointProvider() {
return DatabaseEndpointProvider.defaultProvider();
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
DatabaseServiceClientConfigurationBuilder serviceConfigBuilder = new DatabaseServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
Validate.notNull(c.option(SdkAdvancedClientOption.SIGNER),
"The 'overrideConfiguration.advancedOption[SIGNER]' must be configured in the client builder.");
}
}
| 3,507 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-bearer-auth-client-builder-interface.java | package software.amazon.awssdk.services.json;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.auth.token.credentials.SdkTokenProvider;
import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.TokenIdentity;
import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;
/**
* This includes configuration specific to Json Service that is supported by both {@link JsonClientBuilder} and
* {@link JsonAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkPublicApi
public interface JsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsClientBuilder<B, C> {
/**
* Set the {@link JsonEndpointProvider} implementation that will be used by the client to determine the endpoint for
* each request. This is optional; if none is provided a default implementation will be used the SDK.
*/
default B endpointProvider(JsonEndpointProvider endpointProvider) {
throw new UnsupportedOperationException();
}
/**
* Set the {@link JsonAuthSchemeProvider} implementation that will be used by the client to resolve the auth scheme for
* each request. This is optional; if none is provided a default implementation will be used the SDK.
*/
default B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) {
throw new UnsupportedOperationException();
}
/**
* Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will
* use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}.
* <p>
* If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this
* token provider to retrieve the token to use for authorization.
* <p>
* This provider works in conjunction with the
* {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By
* default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}.
*/
default B tokenProvider(SdkTokenProvider tokenProvider) {
return tokenProvider((IdentityProvider<? extends TokenIdentity>) tokenProvider);
}
/**
* Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will
* use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}.
* <p>
* If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this
* token provider to retrieve the token to use for authorization.
* <p>
* This provider works in conjunction with the
* {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By
* default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}.
*/
default B tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) {
throw new UnsupportedOperationException();
}
}
| 3,508 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-bearer-auth-client-builder-class.java | package software.amazon.awssdk.services.json;
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.credentials.TokenUtils;
import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider;
import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.core.signer.Signer;
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.services.json.endpoints.JsonEndpointProvider;
import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
/**
* Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> {
@Override
protected final String serviceEndpointPrefix() {
return "json-service-endpoint";
}
@Override
protected final String serviceName() {
return "Json";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c
.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)
.lazyOption(AwsClientOption.TOKEN_PROVIDER,
p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER)))
.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider())
.option(SdkAdvancedClientOption.TOKEN_SIGNER, defaultTokenSigner()));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new JsonResolveEndpointInterceptor());
endpointInterceptors.add(new JsonRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/json/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (tokenIdentityProvider != null) {
result.putIdentityProvider(tokenIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors);
return builder.build();
}
@Override
protected final String signingName() {
return "json-service";
}
private JsonEndpointProvider defaultEndpointProvider() {
return JsonEndpointProvider.defaultProvider();
}
private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() {
return DefaultAwsTokenProvider.create();
}
private Signer defaultTokenSigner() {
return BearerTokenSigner.create();
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
Validate.notNull(c.option(SdkAdvancedClientOption.TOKEN_SIGNER),
"The 'overrideConfiguration.advancedOption[TOKEN_SIGNER]' must be configured in the client builder.");
Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER),
"The 'tokenProvider' must be configured in the client builder.");
}
}
| 3,509 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-query-client-builder-class.java | 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;
import software.amazon.awssdk.auth.credentials.TokenUtils;
import software.amazon.awssdk.auth.signer.Aws4Signer;
import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider;
import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.core.signer.Signer;
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.services.query.endpoints.QueryClientContextParams;
import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider;
import software.amazon.awssdk.services.query.endpoints.internal.QueryRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.query.endpoints.internal.QueryResolveEndpointInterceptor;
import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
/**
* Internal base class for {@link DefaultQueryClientBuilder} and {@link DefaultQueryAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultQueryBaseClientBuilder<B extends QueryBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> {
@Override
protected final String serviceEndpointPrefix() {
return "query-service";
}
@Override
protected final String serviceName() {
return "Query";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c
.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkAdvancedClientOption.SIGNER, defaultSigner())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)
.lazyOption(AwsClientOption.TOKEN_PROVIDER,
p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER)))
.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider())
.option(SdkAdvancedClientOption.TOKEN_SIGNER, defaultTokenSigner()));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new QueryResolveEndpointInterceptor());
endpointInterceptors.add(new QueryRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/query/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (tokenIdentityProvider != null) {
result.putIdentityProvider(tokenIdentityProvider);
}
IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
if (credentialsIdentityProvider != null) {
result.putIdentityProvider(credentialsIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).option(SdkClientOption.CLIENT_CONTEXT_PARAMS,
clientContextParams.build());
return builder.build();
}
private Signer defaultSigner() {
return Aws4Signer.create();
}
@Override
protected final String signingName() {
return "query-service";
}
private QueryEndpointProvider defaultEndpointProvider() {
return QueryEndpointProvider.defaultProvider();
}
public B booleanContextParam(Boolean booleanContextParam) {
clientContextParams.put(QueryClientContextParams.BOOLEAN_CONTEXT_PARAM, booleanContextParam);
return thisBuilder();
}
public B stringContextParam(String stringContextParam) {
clientContextParams.put(QueryClientContextParams.STRING_CONTEXT_PARAM, stringContextParam);
return thisBuilder();
}
private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() {
return DefaultAwsTokenProvider.create();
}
private Signer defaultTokenSigner() {
return BearerTokenSigner.create();
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
Validate.notNull(c.option(SdkAdvancedClientOption.SIGNER),
"The 'overrideConfiguration.advancedOption[SIGNER]' must be configured in the client builder.");
Validate.notNull(c.option(SdkAdvancedClientOption.TOKEN_SIGNER),
"The 'overrideConfiguration.advancedOption[TOKEN_SIGNER]' must be configured in the client builder.");
Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER),
"The 'tokenProvider' must be configured in the client builder.");
}
}
| 3,510 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-async-client-builder-class.java | package software.amazon.awssdk.services.json;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.TokenIdentity;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;
/**
* Internal implementation of {@link JsonAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultJsonAsyncClientBuilder extends DefaultJsonBaseClientBuilder<JsonAsyncClientBuilder, JsonAsyncClient> implements
JsonAsyncClientBuilder {
@Override
public DefaultJsonAsyncClientBuilder endpointProvider(JsonEndpointProvider endpointProvider) {
clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER, endpointProvider);
return this;
}
@Override
public DefaultJsonAsyncClientBuilder tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) {
clientConfiguration.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, tokenProvider);
return this;
}
@Override
protected final JsonAsyncClient buildClient() {
SdkClientConfiguration clientConfiguration = super.asyncClientConfiguration();
this.validateClientOptions(clientConfiguration);
JsonAsyncClient client = new DefaultJsonAsyncClient(clientConfiguration);
return client;
}
}
| 3,511 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-client-builder-endpoints-auth-params.java | 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;
import software.amazon.awssdk.auth.credentials.TokenUtils;
import software.amazon.awssdk.auth.signer.Aws4Signer;
import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider;
import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.core.signer.Signer;
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.services.query.endpoints.QueryClientContextParams;
import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider;
import software.amazon.awssdk.services.query.endpoints.internal.QueryRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.query.endpoints.internal.QueryResolveEndpointInterceptor;
import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
/**
* Internal base class for {@link DefaultQueryClientBuilder} and {@link DefaultQueryAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultQueryBaseClientBuilder<B extends QueryBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> {
@Override
protected final String serviceEndpointPrefix() {
return "query-service";
}
@Override
protected final String serviceName() {
return "Query";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c
.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkAdvancedClientOption.SIGNER, defaultSigner())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)
.lazyOption(AwsClientOption.TOKEN_PROVIDER,
p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER)))
.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider())
.option(SdkAdvancedClientOption.TOKEN_SIGNER, defaultTokenSigner()));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new QueryResolveEndpointInterceptor());
endpointInterceptors.add(new QueryRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/query/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (tokenIdentityProvider != null) {
result.putIdentityProvider(tokenIdentityProvider);
}
IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
if (credentialsIdentityProvider != null) {
result.putIdentityProvider(credentialsIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).option(SdkClientOption.CLIENT_CONTEXT_PARAMS,
clientContextParams.build());
return builder.build();
}
private Signer defaultSigner() {
return Aws4Signer.create();
}
@Override
protected final String signingName() {
return "query-service";
}
private QueryEndpointProvider defaultEndpointProvider() {
return QueryEndpointProvider.defaultProvider();
}
public B booleanContextParam(Boolean booleanContextParam) {
clientContextParams.put(QueryClientContextParams.BOOLEAN_CONTEXT_PARAM, booleanContextParam);
return thisBuilder();
}
public B stringContextParam(String stringContextParam) {
clientContextParams.put(QueryClientContextParams.STRING_CONTEXT_PARAM, stringContextParam);
return thisBuilder();
}
private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() {
return DefaultAwsTokenProvider.create();
}
private Signer defaultTokenSigner() {
return BearerTokenSigner.create();
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
Validate.notNull(c.option(SdkAdvancedClientOption.SIGNER),
"The 'overrideConfiguration.advancedOption[SIGNER]' must be configured in the client builder.");
Validate.notNull(c.option(SdkAdvancedClientOption.TOKEN_SIGNER),
"The 'overrideConfiguration.advancedOption[TOKEN_SIGNER]' must be configured in the client builder.");
Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER),
"The 'tokenProvider' must be configured in the client builder.");
}
}
| 3,512 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-client-builder-class.java | package software.amazon.awssdk.services.json;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.MyServiceHttpConfig;
import software.amazon.MyServiceRetryPolicy;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.credentials.TokenUtils;
import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.codegen.poet.plugins.InternalTestPlugin1;
import software.amazon.awssdk.codegen.poet.plugins.InternalTestPlugin2;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme;
import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme;
import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme;
import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme;
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.services.json.auth.scheme.JsonAuthSchemeProvider;
import software.amazon.awssdk.services.json.auth.scheme.internal.JsonAuthSchemeInterceptor;
import software.amazon.awssdk.services.json.endpoints.JsonClientContextParams;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;
import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.AttributeMap;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
/**
* Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> {
private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>();
@Override
protected final String serviceEndpointPrefix() {
return "json-service-endpoint";
}
@Override
protected final String serviceName() {
return "Json";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c
.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider())
.option(SdkClientOption.AUTH_SCHEMES, authSchemes())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)
.option(SdkClientOption.SERVICE_CONFIGURATION, ServiceConfiguration.builder().build())
.lazyOption(AwsClientOption.TOKEN_PROVIDER,
p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER)))
.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new JsonAuthSchemeInterceptor());
endpointInterceptors.add(new JsonResolveEndpointInterceptor());
endpointInterceptors.add(new JsonRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/json/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
ServiceConfiguration.Builder serviceConfigBuilder = ((ServiceConfiguration) config
.option(SdkClientOption.SERVICE_CONFIGURATION)).toBuilder();
serviceConfigBuilder.profileFile(serviceConfigBuilder.profileFileSupplier() != null ? serviceConfigBuilder
.profileFileSupplier() : config.option(SdkClientOption.PROFILE_FILE_SUPPLIER));
serviceConfigBuilder.profileName(serviceConfigBuilder.profileName() != null ? serviceConfigBuilder.profileName() : config
.option(SdkClientOption.PROFILE_NAME));
if (serviceConfigBuilder.dualstackEnabled() != null) {
Validate.validState(
config.option(AwsClientOption.DUALSTACK_ENDPOINT_ENABLED) == null,
"Dualstack has been configured on both ServiceConfiguration and the client/global level. Please limit dualstack configuration to one location.");
} else {
serviceConfigBuilder.dualstackEnabled(config.option(AwsClientOption.DUALSTACK_ENDPOINT_ENABLED));
}
if (serviceConfigBuilder.fipsModeEnabled() != null) {
Validate.validState(
config.option(AwsClientOption.FIPS_ENDPOINT_ENABLED) == null,
"Fips has been configured on both ServiceConfiguration and the client/global level. Please limit fips configuration to one location.");
} else {
serviceConfigBuilder.fipsModeEnabled(config.option(AwsClientOption.FIPS_ENDPOINT_ENABLED));
}
if (serviceConfigBuilder.useArnRegionEnabled() != null) {
Validate.validState(
clientContextParams.get(JsonClientContextParams.USE_ARN_REGION) == null,
"UseArnRegion has been configured on both ServiceConfiguration and the client/global level. Please limit UseArnRegion configuration to one location.");
} else {
serviceConfigBuilder.useArnRegionEnabled(clientContextParams.get(JsonClientContextParams.USE_ARN_REGION));
}
if (serviceConfigBuilder.multiRegionEnabled() != null) {
Validate.validState(
clientContextParams.get(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS) == null,
"DisableMultiRegionAccessPoints has been configured on both ServiceConfiguration and the client/global level. Please limit DisableMultiRegionAccessPoints configuration to one location.");
} else if (clientContextParams.get(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS) != null) {
serviceConfigBuilder.multiRegionEnabled(!clientContextParams
.get(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS));
}
if (serviceConfigBuilder.pathStyleAccessEnabled() != null) {
Validate.validState(
clientContextParams.get(JsonClientContextParams.FORCE_PATH_STYLE) == null,
"ForcePathStyle has been configured on both ServiceConfiguration and the client/global level. Please limit ForcePathStyle configuration to one location.");
} else {
serviceConfigBuilder.pathStyleAccessEnabled(clientContextParams.get(JsonClientContextParams.FORCE_PATH_STYLE));
}
if (serviceConfigBuilder.accelerateModeEnabled() != null) {
Validate.validState(
clientContextParams.get(JsonClientContextParams.ACCELERATE) == null,
"Accelerate has been configured on both ServiceConfiguration and the client/global level. Please limit Accelerate configuration to one location.");
} else {
serviceConfigBuilder.accelerateModeEnabled(clientContextParams.get(JsonClientContextParams.ACCELERATE));
}
ServiceConfiguration finalServiceConfig = serviceConfigBuilder.build();
clientContextParams.put(JsonClientContextParams.USE_ARN_REGION, finalServiceConfig.useArnRegionEnabled());
clientContextParams.put(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS,
!finalServiceConfig.multiRegionEnabled());
clientContextParams.put(JsonClientContextParams.FORCE_PATH_STYLE, finalServiceConfig.pathStyleAccessEnabled());
clientContextParams.put(JsonClientContextParams.ACCELERATE, finalServiceConfig.accelerateModeEnabled());
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (tokenIdentityProvider != null) {
result.putIdentityProvider(tokenIdentityProvider);
}
IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
if (credentialsIdentityProvider != null) {
result.putIdentityProvider(credentialsIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors)
.option(AwsClientOption.DUALSTACK_ENDPOINT_ENABLED, finalServiceConfig.dualstackEnabled())
.option(AwsClientOption.FIPS_ENDPOINT_ENABLED, finalServiceConfig.fipsModeEnabled())
.option(SdkClientOption.RETRY_POLICY, MyServiceRetryPolicy.resolveRetryPolicy(config))
.option(SdkClientOption.SERVICE_CONFIGURATION, finalServiceConfig);
return builder.build();
}
@Override
protected final String signingName() {
return "json-service";
}
private JsonEndpointProvider defaultEndpointProvider() {
return JsonEndpointProvider.defaultProvider();
}
public B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) {
clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider);
return thisBuilder();
}
private JsonAuthSchemeProvider defaultAuthSchemeProvider() {
return JsonAuthSchemeProvider.defaultProvider();
}
@Override
public B putAuthScheme(AuthScheme<?> authScheme) {
additionalAuthSchemes.put(authScheme.schemeId(), authScheme);
return thisBuilder();
}
private Map<String, AuthScheme<?>> authSchemes() {
Map<String, AuthScheme<?>> schemes = new HashMap<>(3 + this.additionalAuthSchemes.size());
AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create();
schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme);
BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create();
schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme);
NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create();
schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme);
schemes.putAll(this.additionalAuthSchemes);
return schemes;
}
public B serviceConfiguration(ServiceConfiguration serviceConfiguration) {
clientConfiguration.option(SdkClientOption.SERVICE_CONFIGURATION, serviceConfiguration);
return thisBuilder();
}
public void setServiceConfiguration(ServiceConfiguration serviceConfiguration) {
serviceConfiguration(serviceConfiguration);
}
private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() {
return DefaultAwsTokenProvider.create();
}
@Override
protected final AttributeMap serviceHttpConfig() {
AttributeMap result = MyServiceHttpConfig.defaultHttpConfig();
return result;
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
List<SdkPlugin> internalPlugins = new ArrayList<>();
internalPlugins.add(new InternalTestPlugin1());
internalPlugins.add(new InternalTestPlugin2());
return internalPlugins;
}
protected static void validateClientOptions(SdkClientConfiguration c) {
Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER),
"The 'tokenProvider' must be configured in the client builder.");
}
}
| 3,513 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-composed-sync-default-client-builder.java | package software.amazon.awssdk.services.json;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.credentials.TokenUtils;
import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme;
import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme;
import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme;
import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme;
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.services.json.auth.scheme.JsonAuthSchemeProvider;
import software.amazon.awssdk.services.json.auth.scheme.internal.JsonAuthSchemeInterceptor;
import software.amazon.awssdk.services.json.endpoints.JsonClientContextParams;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;
import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
/**
* Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> {
private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>();
@Override
protected final String serviceEndpointPrefix() {
return "json-service-endpoint";
}
@Override
protected final String serviceName() {
return "Json";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c
.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider())
.option(SdkClientOption.AUTH_SCHEMES, authSchemes())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)
.option(SdkClientOption.SERVICE_CONFIGURATION, ServiceConfiguration.builder().build())
.lazyOption(AwsClientOption.TOKEN_PROVIDER,
p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER)))
.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new JsonAuthSchemeInterceptor());
endpointInterceptors.add(new JsonResolveEndpointInterceptor());
endpointInterceptors.add(new JsonRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/json/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
ServiceConfiguration.Builder serviceConfigBuilder = ((ServiceConfiguration) config
.option(SdkClientOption.SERVICE_CONFIGURATION)).toBuilder();
serviceConfigBuilder.profileFile(serviceConfigBuilder.profileFileSupplier() != null ? serviceConfigBuilder
.profileFileSupplier() : config.option(SdkClientOption.PROFILE_FILE_SUPPLIER));
serviceConfigBuilder.profileName(serviceConfigBuilder.profileName() != null ? serviceConfigBuilder.profileName() : config
.option(SdkClientOption.PROFILE_NAME));
ServiceConfiguration finalServiceConfig = serviceConfigBuilder.build();
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (tokenIdentityProvider != null) {
result.putIdentityProvider(tokenIdentityProvider);
}
IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
if (credentialsIdentityProvider != null) {
result.putIdentityProvider(credentialsIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).option(SdkClientOption.SERVICE_CONFIGURATION,
finalServiceConfig);
return builder.build();
}
@Override
protected final String signingName() {
return "json-service";
}
private JsonEndpointProvider defaultEndpointProvider() {
return JsonEndpointProvider.defaultProvider();
}
public B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) {
clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider);
return thisBuilder();
}
private JsonAuthSchemeProvider defaultAuthSchemeProvider() {
return JsonAuthSchemeProvider.defaultProvider();
}
@Override
public B putAuthScheme(AuthScheme<?> authScheme) {
additionalAuthSchemes.put(authScheme.schemeId(), authScheme);
return thisBuilder();
}
private Map<String, AuthScheme<?>> authSchemes() {
Map<String, AuthScheme<?>> schemes = new HashMap<>(3 + this.additionalAuthSchemes.size());
AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create();
schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme);
BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create();
schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme);
NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create();
schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme);
schemes.putAll(this.additionalAuthSchemes);
return schemes;
}
public B customParameter(Boolean customParameter) {
clientContextParams.put(JsonClientContextParams.CUSTOM_PARAMETER, customParameter);
return thisBuilder();
}
public B serviceConfiguration(ServiceConfiguration serviceConfiguration) {
clientConfiguration.option(SdkClientOption.SERVICE_CONFIGURATION, serviceConfiguration);
return thisBuilder();
}
public void setServiceConfiguration(ServiceConfiguration serviceConfiguration) {
serviceConfiguration(serviceConfiguration);
}
private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() {
return DefaultAwsTokenProvider.create();
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER),
"The 'tokenProvider' must be configured in the client builder.");
}
}
| 3,514 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-no-auth-service-client-builder-class.java | package software.amazon.awssdk.services.database;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme;
import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.services.database.auth.scheme.DatabaseAuthSchemeProvider;
import software.amazon.awssdk.services.database.auth.scheme.internal.DatabaseAuthSchemeInterceptor;
import software.amazon.awssdk.services.database.endpoints.DatabaseEndpointProvider;
import software.amazon.awssdk.services.database.endpoints.internal.DatabaseRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.database.endpoints.internal.DatabaseResolveEndpointInterceptor;
import software.amazon.awssdk.services.database.internal.DatabaseServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
/**
* Internal base class for {@link DefaultDatabaseClientBuilder} and {@link DefaultDatabaseAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultDatabaseBaseClientBuilder<B extends DatabaseBaseClientBuilder<B, C>, C> extends
AwsDefaultClientBuilder<B, C> {
private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>();
@Override
protected final String serviceEndpointPrefix() {
return "database-service-endpoint";
}
@Override
protected final String serviceName() {
return "Database";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider())
.option(SdkClientOption.AUTH_SCHEMES, authSchemes())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new DatabaseAuthSchemeInterceptor());
endpointInterceptors.add(new DatabaseResolveEndpointInterceptor());
endpointInterceptors.add(new DatabaseRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/database/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors);
return builder.build();
}
@Override
protected final String signingName() {
return "database-service";
}
private DatabaseEndpointProvider defaultEndpointProvider() {
return DatabaseEndpointProvider.defaultProvider();
}
public B authSchemeProvider(DatabaseAuthSchemeProvider authSchemeProvider) {
clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider);
return thisBuilder();
}
private DatabaseAuthSchemeProvider defaultAuthSchemeProvider() {
return DatabaseAuthSchemeProvider.defaultProvider();
}
@Override
public B putAuthScheme(AuthScheme<?> authScheme) {
additionalAuthSchemes.put(authScheme.schemeId(), authScheme);
return thisBuilder();
}
private Map<String, AuthScheme<?>> authSchemes() {
Map<String, AuthScheme<?>> schemes = new HashMap<>(1 + this.additionalAuthSchemes.size());
NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create();
schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme);
schemes.putAll(this.additionalAuthSchemes);
return schemes;
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
DatabaseServiceClientConfigurationBuilder serviceConfigBuilder = new DatabaseServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
}
}
| 3,515 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-client-builder-internal-defaults-class.java | package software.amazon.awssdk.services.json;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.core.retry.RetryMode;
import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme;
import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme;
import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider;
import software.amazon.awssdk.services.json.auth.scheme.internal.JsonAuthSchemeInterceptor;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;
import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
/**
* Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> {
private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>();
@Override
protected final String serviceEndpointPrefix() {
return "json-service-endpoint";
}
@Override
protected final String serviceName() {
return "Json";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider())
.option(SdkClientOption.AUTH_SCHEMES, authSchemes())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false));
}
@Override
protected final SdkClientConfiguration mergeInternalDefaults(SdkClientConfiguration config) {
return config.merge(c -> {
c.option(SdkClientOption.INTERNAL_USER_AGENT, "md/foobar");
c.option(SdkClientOption.DEFAULT_RETRY_MODE, RetryMode.STANDARD);
});
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new JsonAuthSchemeInterceptor());
endpointInterceptors.add(new JsonResolveEndpointInterceptor());
endpointInterceptors.add(new JsonRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/json/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
if (credentialsIdentityProvider != null) {
result.putIdentityProvider(credentialsIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors);
return builder.build();
}
@Override
protected final String signingName() {
return "json-service";
}
private JsonEndpointProvider defaultEndpointProvider() {
return JsonEndpointProvider.defaultProvider();
}
public B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) {
clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider);
return thisBuilder();
}
private JsonAuthSchemeProvider defaultAuthSchemeProvider() {
return JsonAuthSchemeProvider.defaultProvider();
}
@Override
public B putAuthScheme(AuthScheme<?> authScheme) {
additionalAuthSchemes.put(authScheme.schemeId(), authScheme);
return thisBuilder();
}
private Map<String, AuthScheme<?>> authSchemes() {
Map<String, AuthScheme<?>> schemes = new HashMap<>(2 + this.additionalAuthSchemes.size());
AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create();
schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme);
NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create();
schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme);
schemes.putAll(this.additionalAuthSchemes);
return schemes;
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
}
}
| 3,516 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-no-auth-ops-client-builder-class.java | package software.amazon.awssdk.services.database;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme;
import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme;
import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme;
import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.services.database.auth.scheme.DatabaseAuthSchemeProvider;
import software.amazon.awssdk.services.database.auth.scheme.internal.DatabaseAuthSchemeInterceptor;
import software.amazon.awssdk.services.database.endpoints.DatabaseEndpointProvider;
import software.amazon.awssdk.services.database.endpoints.internal.DatabaseRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.database.endpoints.internal.DatabaseResolveEndpointInterceptor;
import software.amazon.awssdk.services.database.internal.DatabaseServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
/**
* Internal base class for {@link DefaultDatabaseClientBuilder} and {@link DefaultDatabaseAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultDatabaseBaseClientBuilder<B extends DatabaseBaseClientBuilder<B, C>, C> extends
AwsDefaultClientBuilder<B, C> {
private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>();
@Override
protected final String serviceEndpointPrefix() {
return "database-service-endpoint";
}
@Override
protected final String serviceName() {
return "Database";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider())
.option(SdkClientOption.AUTH_SCHEMES, authSchemes())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new DatabaseAuthSchemeInterceptor());
endpointInterceptors.add(new DatabaseResolveEndpointInterceptor());
endpointInterceptors.add(new DatabaseRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/database/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
if (credentialsIdentityProvider != null) {
result.putIdentityProvider(credentialsIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors);
return builder.build();
}
@Override
protected final String signingName() {
return "database-service";
}
private DatabaseEndpointProvider defaultEndpointProvider() {
return DatabaseEndpointProvider.defaultProvider();
}
public B authSchemeProvider(DatabaseAuthSchemeProvider authSchemeProvider) {
clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider);
return thisBuilder();
}
private DatabaseAuthSchemeProvider defaultAuthSchemeProvider() {
return DatabaseAuthSchemeProvider.defaultProvider();
}
@Override
public B putAuthScheme(AuthScheme<?> authScheme) {
additionalAuthSchemes.put(authScheme.schemeId(), authScheme);
return thisBuilder();
}
private Map<String, AuthScheme<?>> authSchemes() {
Map<String, AuthScheme<?>> schemes = new HashMap<>(3 + this.additionalAuthSchemes.size());
AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create();
schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme);
BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create();
schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme);
NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create();
schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme);
schemes.putAll(this.additionalAuthSchemes);
return schemes;
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
DatabaseServiceClientConfigurationBuilder serviceConfigBuilder = new DatabaseServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
}
}
| 3,517 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-bearer-auth-client-builder-class.java | package software.amazon.awssdk.services.json;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.credentials.TokenUtils;
import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme;
import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme;
import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme;
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.services.json.auth.scheme.JsonAuthSchemeProvider;
import software.amazon.awssdk.services.json.auth.scheme.internal.JsonAuthSchemeInterceptor;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;
import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
/**
* Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> {
private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>();
@Override
protected final String serviceEndpointPrefix() {
return "json-service-endpoint";
}
@Override
protected final String serviceName() {
return "Json";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c
.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider())
.option(SdkClientOption.AUTH_SCHEMES, authSchemes())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)
.lazyOption(AwsClientOption.TOKEN_PROVIDER,
p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER)))
.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new JsonAuthSchemeInterceptor());
endpointInterceptors.add(new JsonResolveEndpointInterceptor());
endpointInterceptors.add(new JsonRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/json/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (tokenIdentityProvider != null) {
result.putIdentityProvider(tokenIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors);
return builder.build();
}
@Override
protected final String signingName() {
return "json-service";
}
private JsonEndpointProvider defaultEndpointProvider() {
return JsonEndpointProvider.defaultProvider();
}
public B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) {
clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider);
return thisBuilder();
}
private JsonAuthSchemeProvider defaultAuthSchemeProvider() {
return JsonAuthSchemeProvider.defaultProvider();
}
@Override
public B putAuthScheme(AuthScheme<?> authScheme) {
additionalAuthSchemes.put(authScheme.schemeId(), authScheme);
return thisBuilder();
}
private Map<String, AuthScheme<?>> authSchemes() {
Map<String, AuthScheme<?>> schemes = new HashMap<>(2 + this.additionalAuthSchemes.size());
BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create();
schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme);
NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create();
schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme);
schemes.putAll(this.additionalAuthSchemes);
return schemes;
}
private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() {
return DefaultAwsTokenProvider.create();
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER),
"The 'tokenProvider' must be configured in the client builder.");
}
}
| 3,518 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-query-client-builder-class.java | package software.amazon.awssdk.services.query;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.credentials.TokenUtils;
import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme;
import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme;
import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme;
import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme;
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.services.query.auth.scheme.QueryAuthSchemeProvider;
import software.amazon.awssdk.services.query.auth.scheme.internal.QueryAuthSchemeInterceptor;
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;
import software.amazon.awssdk.services.query.endpoints.internal.QueryResolveEndpointInterceptor;
import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
/**
* Internal base class for {@link DefaultQueryClientBuilder} and {@link DefaultQueryAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultQueryBaseClientBuilder<B extends QueryBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> {
private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>();
@Override
protected final String serviceEndpointPrefix() {
return "query-service";
}
@Override
protected final String serviceName() {
return "Query";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c
.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider())
.option(SdkClientOption.AUTH_SCHEMES, authSchemes())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)
.lazyOption(AwsClientOption.TOKEN_PROVIDER,
p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER)))
.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new QueryAuthSchemeInterceptor());
endpointInterceptors.add(new QueryResolveEndpointInterceptor());
endpointInterceptors.add(new QueryRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/query/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (tokenIdentityProvider != null) {
result.putIdentityProvider(tokenIdentityProvider);
}
IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
if (credentialsIdentityProvider != null) {
result.putIdentityProvider(credentialsIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).option(SdkClientOption.CLIENT_CONTEXT_PARAMS,
clientContextParams.build());
return builder.build();
}
@Override
protected final String signingName() {
return "query-service";
}
private QueryEndpointProvider defaultEndpointProvider() {
return QueryEndpointProvider.defaultProvider();
}
public B authSchemeProvider(QueryAuthSchemeProvider authSchemeProvider) {
clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider);
return thisBuilder();
}
private QueryAuthSchemeProvider defaultAuthSchemeProvider() {
return QueryAuthSchemeProvider.defaultProvider();
}
@Override
public B putAuthScheme(AuthScheme<?> authScheme) {
additionalAuthSchemes.put(authScheme.schemeId(), authScheme);
return thisBuilder();
}
private Map<String, AuthScheme<?>> authSchemes() {
Map<String, AuthScheme<?>> schemes = new HashMap<>(3 + this.additionalAuthSchemes.size());
AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create();
schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme);
BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create();
schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme);
NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create();
schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme);
schemes.putAll(this.additionalAuthSchemes);
return schemes;
}
public B booleanContextParam(Boolean booleanContextParam) {
clientContextParams.put(QueryClientContextParams.BOOLEAN_CONTEXT_PARAM, booleanContextParam);
return thisBuilder();
}
public B stringContextParam(String stringContextParam) {
clientContextParams.put(QueryClientContextParams.STRING_CONTEXT_PARAM, stringContextParam);
return thisBuilder();
}
private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() {
return DefaultAwsTokenProvider.create();
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER),
"The 'tokenProvider' must be configured in the client builder.");
}
}
| 3,519 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-client-builder-endpoints-auth-params.java | package software.amazon.awssdk.services.query;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.credentials.TokenUtils;
import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme;
import software.amazon.awssdk.http.auth.aws.scheme.AwsV4aAuthScheme;
import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme;
import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme;
import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme;
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.services.query.auth.scheme.QueryAuthSchemeProvider;
import software.amazon.awssdk.services.query.auth.scheme.internal.QueryAuthSchemeInterceptor;
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;
import software.amazon.awssdk.services.query.endpoints.internal.QueryResolveEndpointInterceptor;
import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
/**
* Internal base class for {@link DefaultQueryClientBuilder} and {@link DefaultQueryAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultQueryBaseClientBuilder<B extends QueryBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> {
private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>();
@Override
protected final String serviceEndpointPrefix() {
return "query-service";
}
@Override
protected final String serviceName() {
return "Query";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c
.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider())
.option(SdkClientOption.AUTH_SCHEMES, authSchemes())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)
.lazyOption(AwsClientOption.TOKEN_PROVIDER,
p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER)))
.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new QueryAuthSchemeInterceptor());
endpointInterceptors.add(new QueryResolveEndpointInterceptor());
endpointInterceptors.add(new QueryRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/query/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER);
if (tokenIdentityProvider != null) {
result.putIdentityProvider(tokenIdentityProvider);
}
IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
if (credentialsIdentityProvider != null) {
result.putIdentityProvider(credentialsIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).option(SdkClientOption.CLIENT_CONTEXT_PARAMS,
clientContextParams.build());
return builder.build();
}
@Override
protected final String signingName() {
return "query-service";
}
private QueryEndpointProvider defaultEndpointProvider() {
return QueryEndpointProvider.defaultProvider();
}
public B authSchemeProvider(QueryAuthSchemeProvider authSchemeProvider) {
clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider);
return thisBuilder();
}
private QueryAuthSchemeProvider defaultAuthSchemeProvider() {
return QueryAuthSchemeProvider.defaultProvider();
}
@Override
public B putAuthScheme(AuthScheme<?> authScheme) {
additionalAuthSchemes.put(authScheme.schemeId(), authScheme);
return thisBuilder();
}
private Map<String, AuthScheme<?>> authSchemes() {
Map<String, AuthScheme<?>> schemes = new HashMap<>(4 + this.additionalAuthSchemes.size());
AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create();
schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme);
AwsV4aAuthScheme awsV4aAuthScheme = AwsV4aAuthScheme.create();
schemes.put(awsV4aAuthScheme.schemeId(), awsV4aAuthScheme);
BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create();
schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme);
NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create();
schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme);
schemes.putAll(this.additionalAuthSchemes);
return schemes;
}
public B booleanContextParam(Boolean booleanContextParam) {
clientContextParams.put(QueryClientContextParams.BOOLEAN_CONTEXT_PARAM, booleanContextParam);
return thisBuilder();
}
public B stringContextParam(String stringContextParam) {
clientContextParams.put(QueryClientContextParams.STRING_CONTEXT_PARAM, stringContextParam);
return thisBuilder();
}
private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() {
return DefaultAwsTokenProvider.create();
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List<SdkPlugin> internalPlugins = internalPlugins();
List<SdkPlugin> externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List<SdkPlugin> internalPlugins() {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER),
"The 'tokenProvider' must be configured in the client builder.");
}
}
| 3,520 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventthreemarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.EventThree;
import software.amazon.awssdk.utils.Validate;
/**
* {@link EventThree} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class EventThreeMarshaller implements Marshaller<EventThree> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().hasExplicitPayloadMember(false)
.hasPayloadMembers(true).hasImplicitPayloadMembers(true).httpMethod(SdkHttpMethod.GET).hasEvent(true).build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public EventThreeMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(EventThree eventThree) {
Validate.paramNotNull(eventThree, "eventThree");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(eventThree).toBuilder().putHeader(":message-type", "event")
.putHeader(":event-type", eventThree.sdkEventType().toString())
.putHeader(":content-type", protocolFactory.getContentType()).build();
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,521 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventstreamoperationwithonlyinputrequestmarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.EventStreamOperationWithOnlyInputRequest;
import software.amazon.awssdk.utils.Validate;
/**
* {@link EventStreamOperationWithOnlyInputRequest} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class EventStreamOperationWithOnlyInputRequestMarshaller implements Marshaller<EventStreamOperationWithOnlyInputRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
.requestUri("/2016-03-11/EventStreamOperationWithOnlyInput").httpMethod(SdkHttpMethod.POST)
.hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true).hasPayloadMembers(true).hasEventStreamingInput(true)
.build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public EventStreamOperationWithOnlyInputRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest) {
Validate.paramNotNull(eventStreamOperationWithOnlyInputRequest, "eventStreamOperationWithOnlyInputRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(eventStreamOperationWithOnlyInputRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,522 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventtwomarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.EventTwo;
import software.amazon.awssdk.utils.Validate;
/**
* {@link EventTwo} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class EventTwoMarshaller implements Marshaller<EventTwo> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().hasExplicitPayloadMember(false)
.hasPayloadMembers(true).hasImplicitPayloadMembers(true).httpMethod(SdkHttpMethod.GET).hasEvent(true).build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public EventTwoMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(EventTwo eventTwo) {
Validate.paramNotNull(eventTwo, "eventTwo");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(eventTwo).toBuilder().putHeader(":message-type", "event")
.putHeader(":event-type", eventTwo.sdkEventType().toString())
.putHeader(":content-type", protocolFactory.getContentType()).build();
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,523 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/inputeventtwomarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.InputEventTwo;
import software.amazon.awssdk.utils.Validate;
/**
* {@link InputEventTwo} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class InputEventTwoMarshaller implements Marshaller<InputEventTwo> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().hasExplicitPayloadMember(false)
.hasPayloadMembers(true).hasImplicitPayloadMembers(true).httpMethod(SdkHttpMethod.GET).hasEvent(true).build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public InputEventTwoMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(InputEventTwo inputEventTwo) {
Validate.paramNotNull(inputEventTwo, "inputEventTwo");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(inputEventTwo).toBuilder().putHeader(":message-type", "event")
.putHeader(":event-type", inputEventTwo.sdkEventType().toString())
.putHeader(":content-type", protocolFactory.getContentType()).build();
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,524 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/inputeventmarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.InputEvent;
import software.amazon.awssdk.utils.Validate;
/**
* {@link InputEvent} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class InputEventMarshaller implements Marshaller<InputEvent> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().hasExplicitPayloadMember(true)
.hasPayloadMembers(true).hasImplicitPayloadMembers(false).httpMethod(SdkHttpMethod.GET).hasEvent(true).build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public InputEventMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(InputEvent inputEvent) {
Validate.paramNotNull(inputEvent, "inputEvent");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(inputEvent).toBuilder().putHeader(":message-type", "event")
.putHeader(":event-type", inputEvent.sdkEventType().toString())
.putHeader(":content-type", "application/octet-stream").build();
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,525 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/streaminginputoperationrequestmarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.StreamingInputOperationRequest;
import software.amazon.awssdk.utils.Validate;
/**
* {@link StreamingInputOperationRequest} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class StreamingInputOperationRequestMarshaller implements Marshaller<StreamingInputOperationRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
.requestUri("/2016-03-11/streamingInputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true)
.hasImplicitPayloadMembers(false).hasPayloadMembers(true).hasStreamingInput(true).build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public StreamingInputOperationRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(StreamingInputOperationRequest streamingInputOperationRequest) {
Validate.paramNotNull(streamingInputOperationRequest, "streamingInputOperationRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(streamingInputOperationRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,526 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/operationwithnoinputoroutputrequestmarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.OperationWithNoInputOrOutputRequest;
import software.amazon.awssdk.utils.Validate;
/**
* {@link OperationWithNoInputOrOutputRequest} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class OperationWithNoInputOrOutputRequestMarshaller implements Marshaller<OperationWithNoInputOrOutputRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/")
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(false)
.hasPayloadMembers(false).build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public OperationWithNoInputOrOutputRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(OperationWithNoInputOrOutputRequest operationWithNoInputOrOutputRequest) {
Validate.paramNotNull(operationWithNoInputOrOutputRequest, "operationWithNoInputOrOutputRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(operationWithNoInputOrOutputRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,527 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventonemarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.EventOne;
import software.amazon.awssdk.utils.Validate;
/**
* {@link EventOne} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class EventOneMarshaller implements Marshaller<EventOne> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().hasExplicitPayloadMember(false)
.hasPayloadMembers(true).hasImplicitPayloadMembers(true).httpMethod(SdkHttpMethod.GET).hasEvent(true).build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public EventOneMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(EventOne eventOne) {
Validate.paramNotNull(eventOne, "eventOne");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(eventOne).toBuilder().putHeader(":message-type", "event")
.putHeader(":event-type", eventOne.sdkEventType().toString())
.putHeader(":content-type", protocolFactory.getContentType()).build();
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,528 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventstreamoperationrequestmarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.EventStreamOperationRequest;
import software.amazon.awssdk.utils.Validate;
/**
* {@link EventStreamOperationRequest} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class EventStreamOperationRequestMarshaller implements Marshaller<EventStreamOperationRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
.requestUri("/2016-03-11/eventStreamOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true)
.hasImplicitPayloadMembers(false).hasPayloadMembers(true).hasEventStreamingInput(true).build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public EventStreamOperationRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(EventStreamOperationRequest eventStreamOperationRequest) {
Validate.paramNotNull(eventStreamOperationRequest, "eventStreamOperationRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(eventStreamOperationRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,529 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/alltypesrequestmarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.AllTypesRequest;
import software.amazon.awssdk.utils.Validate;
/**
* {@link AllTypesRequest} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class AllTypesRequestMarshaller implements Marshaller<AllTypesRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/")
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true)
.hasPayloadMembers(true).build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public AllTypesRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(AllTypesRequest allTypesRequest) {
Validate.paramNotNull(allTypesRequest, "allTypesRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(allTypesRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,530 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/nestedcontainersrequestmarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.NestedContainersRequest;
import software.amazon.awssdk.utils.Validate;
/**
* {@link NestedContainersRequest} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class NestedContainersRequestMarshaller implements Marshaller<NestedContainersRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/")
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true)
.hasPayloadMembers(true).build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public NestedContainersRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(NestedContainersRequest nestedContainersRequest) {
Validate.paramNotNull(nestedContainersRequest, "nestedContainersRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(nestedContainersRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,531 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/streamingoutputoperationrequestmarshaller.java | package software.amazon.awssdk.services.jsonprotocoltests.transform;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.protocols.core.OperationInfo;
import software.amazon.awssdk.protocols.core.ProtocolMarshaller;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.services.jsonprotocoltests.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.utils.Validate;
/**
* {@link StreamingOutputOperationRequest} Marshaller
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class StreamingOutputOperationRequestMarshaller implements Marshaller<StreamingOutputOperationRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
.requestUri("/2016-03-11/streamingOutputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false)
.hasImplicitPayloadMembers(false).hasPayloadMembers(false).build();
private final BaseAwsJsonProtocolFactory protocolFactory;
public StreamingOutputOperationRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
@Override
public SdkHttpFullRequest marshall(StreamingOutputOperationRequest streamingOutputOperationRequest) {
Validate.paramNotNull(streamingOutputOperationRequest, "streamingOutputOperationRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(streamingOutputOperationRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
| 3,532 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java | package software.amazon.awssdk.services.json;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.signer.Aws4UnsignedPayloadSigner;
import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller;
import software.amazon.awssdk.core.signer.Signer;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.json.model.APostOperationRequest;
import software.amazon.awssdk.services.json.model.APostOperationResponse;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse;
import software.amazon.awssdk.services.json.model.InvalidInputException;
import software.amazon.awssdk.services.json.model.JsonException;
import software.amazon.awssdk.services.json.model.JsonRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.utils.HostnameValidator;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link JsonClient}.
*
* @see JsonClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultJsonClient implements JsonClient {
private static final Logger log = Logger.loggerFor(DefaultJsonClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultJsonClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return Result of the APostOperation operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException,
AwsServiceException, SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata,
APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
String hostPrefix = "{StringMember}-foo.";
HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember",
"aPostOperationRequest");
String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember());
return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration)
.withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return Result of the APostOperationWithOutput operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public APostOperationWithOutputResponse aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, APostOperationWithOutputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
return clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the BearerAuthOperation operation.
*
* @param bearerAuthOperationRequest
* @return Result of the BearerAuthOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest)
throws AwsServiceException, SdkClientException, JsonException {
bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create());
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, BearerAuthOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration)
.withInput(bearerAuthOperationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the GetOperationWithChecksum operation.
*
* @param getOperationWithChecksumRequest
* @return Result of the GetOperationWithChecksum operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public GetOperationWithChecksumResponse getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException,
JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(false).build();
HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
return clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(getOperationWithChecksumRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build())
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param getWithoutRequiredMembersRequest
* @return Result of the GetWithoutRequiredMembers operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
@Override
public GetWithoutRequiredMembersResponse getWithoutRequiredMembers(
GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetWithoutRequiredMembersResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers");
return clientHandler
.execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>()
.withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getWithoutRequiredMembersRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithChecksumRequired operation.
*
* @param operationWithChecksumRequiredRequest
* @return Result of the OperationWithChecksumRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithChecksumRequiredResponse operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithChecksumRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
return clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithChecksumRequiredRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create())
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithRequestCompression operation.
*
* @param operationWithRequestCompressionRequest
* @return Result of the OperationWithRequestCompression operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithRequestCompressionResponse operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithRequestCompressionResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
return clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithRequestCompressionRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @param paginatedOperationWithResultKeyRequest
* @return Result of the PaginatedOperationWithResultKey operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) throws AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PaginatedOperationWithResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey");
return clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>()
.withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(paginatedOperationWithResultKeyRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some paginated operation without result_key in paginators.json file
*
* @param paginatedOperationWithoutResultKeyRequest
* @return Result of the PaginatedOperationWithoutResultKey operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResultKey(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) throws AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey");
return clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>()
.withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(paginatedOperationWithoutResultKeyRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the PutOperationWithChecksum operation.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest,
RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer)
throws AwsServiceException, SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
return clientHandler.execute(
new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(putOperationWithChecksumRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build())
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()), responseTransformer);
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest,
RequestBody requestBody) throws AwsServiceException, SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
return clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(streamingInputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingInputOutputOperationResponse and an InputStream to the response content are provided as
* parameters to the callback. The callback may return a transformed type which will be the return value of
* this method. See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing
* this interface and for links to pre-canned implementations for common scenarios like downloading to a
* file. The service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, RequestBody requestBody,
ResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, JsonException {
streamingInputOutputOperationRequest = applySignerOverride(streamingInputOutputOperationRequest,
Aws4UnsignedPayloadSigner.create());
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
streamingInputOutputOperationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation");
return clientHandler.execute(
new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>()
.withOperationName("StreamingInputOutputOperation")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(streamingInputOutputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller
.builder()
.delegateMarshaller(
new StreamingInputOutputOperationRequestMarshaller(protocolFactory))
.requestBody(requestBody).transferEncoding(true).build()), responseTransformer);
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest,
ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
return clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer);
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Creates an instance of {@link JsonUtilities} object with the configuration set on this client.
*/
@Override
public JsonUtilities utilities() {
return JsonUtilities.create(param1, param2, param3);
}
private <T extends JsonRequest> T applySignerOverride(T request, Signer signer) {
if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) {
return request;
}
Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build();
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(signerOverride).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(JsonException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build());
}
@Override
public final JsonServiceClientConfiguration serviceClientConfiguration() {
return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,533 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-abstract-async-client-class.java | package software.amazon.awssdk.services.json;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import org.reactivestreams.Publisher;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.core.SdkClient;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.services.json.model.APostOperationRequest;
import software.amazon.awssdk.services.json.model.APostOperationResponse;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse;
import software.amazon.awssdk.services.json.model.InputEventStream;
import software.amazon.awssdk.services.json.model.InputEventStreamTwo;
import software.amazon.awssdk.services.json.model.JsonRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.utils.Validate;
@Generated("software.amazon.awssdk:codegen")
@SdkPublicApi
public abstract class DelegatingJsonAsyncClient implements JsonAsyncClient {
private final JsonAsyncClient delegate;
public DelegatingJsonAsyncClient(JsonAsyncClient delegate) {
Validate.paramNotNull(delegate, "delegate");
this.delegate = delegate;
}
/**
* Creates an instance of {@link JsonUtilities} object with the configuration set on this client.
*/
@Override
public JsonUtilities utilities() {
return delegate.utilities();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
return invokeOperation(aPostOperationRequest, request -> delegate.aPostOperation(request));
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
return invokeOperation(aPostOperationWithOutputRequest, request -> delegate.aPostOperationWithOutput(request));
}
/**
* Invokes the BearerAuthOperation operation asynchronously.
*
* @param bearerAuthOperationRequest
* @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation(
BearerAuthOperationRequest bearerAuthOperationRequest) {
return invokeOperation(bearerAuthOperationRequest, request -> delegate.bearerAuthOperation(request));
}
/**
* Invokes the EventStreamOperation operation asynchronously.
*
* @param eventStreamOperationRequest
* @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest,
Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) {
return invokeOperation(eventStreamOperationRequest,
request -> delegate.eventStreamOperation(request, requestStream, asyncResponseHandler));
}
/**
* Invokes the EventStreamOperationWithOnlyInput operation asynchronously.
*
* @param eventStreamOperationWithOnlyInputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyInput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput(
EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest,
Publisher<InputEventStreamTwo> requestStream) {
return invokeOperation(eventStreamOperationWithOnlyInputRequest,
request -> delegate.eventStreamOperationWithOnlyInput(request, requestStream));
}
/**
* Invokes the EventStreamOperationWithOnlyOutput operation asynchronously.
*
* @param eventStreamOperationWithOnlyOutputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperationWithOnlyOutput(
EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest,
EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) {
return invokeOperation(eventStreamOperationWithOnlyOutputRequest,
request -> delegate.eventStreamOperationWithOnlyOutput(request, asyncResponseHandler));
}
/**
* Invokes the GetOperationWithChecksum operation asynchronously.
*
* @param getOperationWithChecksumRequest
* @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) {
return invokeOperation(getOperationWithChecksumRequest, request -> delegate.getOperationWithChecksum(request));
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param getWithoutRequiredMembersRequest
* @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers(
GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) {
return invokeOperation(getWithoutRequiredMembersRequest, request -> delegate.getWithoutRequiredMembers(request));
}
/**
* Invokes the OperationWithChecksumRequired operation asynchronously.
*
* @param operationWithChecksumRequiredRequest
* @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
return invokeOperation(operationWithChecksumRequiredRequest, request -> delegate.operationWithChecksumRequired(request));
}
/**
* Invokes the OperationWithRequestCompression operation asynchronously.
*
* @param operationWithRequestCompressionRequest
* @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
return invokeOperation(operationWithRequestCompressionRequest,
request -> delegate.operationWithRequestCompression(request));
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @param paginatedOperationWithResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) {
return invokeOperation(paginatedOperationWithResultKeyRequest,
request -> delegate.paginatedOperationWithResultKey(request));
}
/**
* Some paginated operation without result_key in paginators.json file
*
* @param paginatedOperationWithoutResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) {
return invokeOperation(paginatedOperationWithoutResultKeyRequest,
request -> delegate.paginatedOperationWithoutResultKey(request));
}
/**
* Invokes the PutOperationWithChecksum operation asynchronously.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum(
PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) {
return invokeOperation(putOperationWithChecksumRequest,
request -> delegate.putOperationWithChecksum(request, requestBody, asyncResponseTransformer));
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
return invokeOperation(streamingInputOperationRequest, request -> delegate.streamingInputOperation(request, requestBody));
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) {
return invokeOperation(streamingInputOutputOperationRequest,
request -> delegate.streamingInputOutputOperation(request, requestBody, asyncResponseTransformer));
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest,
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) {
return invokeOperation(streamingOutputOperationRequest,
request -> delegate.streamingOutputOperation(request, asyncResponseTransformer));
}
@Override
public final JsonServiceClientConfiguration serviceClientConfiguration() {
return delegate.serviceClientConfiguration();
}
@Override
public final String serviceName() {
return delegate.serviceName();
}
public SdkClient delegate() {
return this.delegate;
}
protected <T extends JsonRequest, ReturnT> CompletableFuture<ReturnT> invokeOperation(T request,
Function<T, CompletableFuture<ReturnT>> operation) {
return operation.apply(request);
}
@Override
public void close() {
delegate.close();
}
}
| 3,534 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-class.java | package software.amazon.awssdk.services.json;
import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.signer.AsyncAws4Signer;
import software.amazon.awssdk.auth.signer.Aws4UnsignedPayloadSigner;
import software.amazon.awssdk.auth.signer.EventStreamAws4Signer;
import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.client.handler.AwsClientHandlerUtils;
import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer;
import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionJsonMarshaller;
import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier;
import software.amazon.awssdk.awscore.eventstream.RestEventStreamAsyncResponseTransformer;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkPojoBuilder;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.SdkResponse;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils;
import software.amazon.awssdk.core.async.SdkPublisher;
import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
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.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.protocol.VoidSdkResponse;
import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller;
import software.amazon.awssdk.core.signer.Signer;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.json.model.APostOperationRequest;
import software.amazon.awssdk.services.json.model.APostOperationResponse;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.json.model.EventStream;
import software.amazon.awssdk.services.json.model.EventStreamOperationRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse;
import software.amazon.awssdk.services.json.model.InputEventStream;
import software.amazon.awssdk.services.json.model.InputEventStreamTwo;
import software.amazon.awssdk.services.json.model.InvalidInputException;
import software.amazon.awssdk.services.json.model.JsonException;
import software.amazon.awssdk.services.json.model.JsonRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.json.model.inputeventstream.DefaultInputEvent;
import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventOne;
import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventTwo;
import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyInputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyOutputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller;
import software.amazon.awssdk.services.json.transform.InputEventMarshaller;
import software.amazon.awssdk.services.json.transform.InputEventTwoMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
import software.amazon.awssdk.utils.HostnameValidator;
import software.amazon.awssdk.utils.Pair;
/**
* Internal implementation of {@link JsonAsyncClient}.
*
* @see JsonAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultJsonAsyncClient implements JsonAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultJsonAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private final Executor executor;
protected DefaultJsonAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR);
}
@Override
public JsonUtilities utilities() {
return JsonUtilities.create(param1, param2, param3);
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
String hostPrefix = "{StringMember}-foo.";
HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember",
"aPostOperationRequest");
String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember());
CompletableFuture<APostOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
CompletableFuture<APostOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, APostOperationWithOutputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(aPostOperationWithOutputRequest));
CompletableFuture<APostOperationWithOutputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the BearerAuthOperation operation asynchronously.
*
* @param bearerAuthOperationRequest
* @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation(
BearerAuthOperationRequest bearerAuthOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create());
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, BearerAuthOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.credentialType(CredentialType.TOKEN).withInput(bearerAuthOperationRequest));
CompletableFuture<BearerAuthOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperation operation asynchronously.
*
* @param eventStreamOperationRequest
* @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest,
Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation");
eventStreamOperationRequest = applySignerOverride(eventStreamOperationRequest, EventStreamAws4Signer.create());
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationResponse> responseHandler = new AttachHttpMetadataResponseHandler(
protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder));
HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata
.builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
.putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
.putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
.putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
.putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build();
SdkPublisher<InputEventStream> eventPublisher = SdkPublisher.adapt(requestStream);
Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture<Void> future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer
.<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler)
.eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
.exceptionResponseHandler(errorResponseHandler).future(future).executor(executor).serviceName(serviceName())
.build();
RestEventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer
.<EventStreamOperationResponse, EventStream> builder()
.eventStreamAsyncResponseTransformer(asyncResponseTransformer)
.eventStreamResponseHandler(asyncResponseHandler).build();
CompletableFuture<Void> executeFuture = clientHandler.execute(
new ClientExecutionParams<EventStreamOperationRequest, EventStreamOperationResponse>()
.withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
.withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(eventStreamOperationRequest), restAsyncResponseTransformer);
CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
asyncResponseHandler.exceptionOccurred(e);
} finally {
future.completeExceptionally(e);
}
}
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return CompletableFutureUtils.forwardExceptionTo(future, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperationWithOnlyInput operation asynchronously.
*
* @param eventStreamOperationWithOnlyInputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyInput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput(
EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest,
Publisher<InputEventStreamTwo> requestStream) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyInputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyInput");
eventStreamOperationWithOnlyInputRequest = applySignerOverride(eventStreamOperationWithOnlyInputRequest,
EventStreamAws4Signer.create());
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationWithOnlyInputResponse> responseHandler = protocolFactory
.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
.putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory))
.putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build();
SdkPublisher<InputEventStreamTwo> eventPublisher = SdkPublisher.adapt(requestStream);
Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture<EventStreamOperationWithOnlyInputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<EventStreamOperationWithOnlyInputRequest, EventStreamOperationWithOnlyInputResponse>()
.withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory))
.withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationWithOnlyInputRequest));
CompletableFuture<EventStreamOperationWithOnlyInputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperationWithOnlyOutput operation asynchronously.
*
* @param eventStreamOperationWithOnlyOutputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperationWithOnlyOutput(
EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest,
EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationWithOnlyOutputResponse> responseHandler = new AttachHttpMetadataResponseHandler(
protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder));
HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata
.builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
.putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
.putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
.putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<Void> future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer
.<EventStreamOperationWithOnlyOutputResponse, EventStream> builder()
.eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler)
.initialResponseHandler(responseHandler).exceptionResponseHandler(errorResponseHandler).future(future)
.executor(executor).serviceName(serviceName()).build();
RestEventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer
.<EventStreamOperationWithOnlyOutputResponse, EventStream> builder()
.eventStreamAsyncResponseTransformer(asyncResponseTransformer)
.eventStreamResponseHandler(asyncResponseHandler).build();
CompletableFuture<Void> executeFuture = clientHandler
.execute(
new ClientExecutionParams<EventStreamOperationWithOnlyOutputRequest, EventStreamOperationWithOnlyOutputResponse>()
.withOperationName("EventStreamOperationWithOnlyOutput")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationWithOnlyOutputRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(eventStreamOperationWithOnlyOutputRequest), restAsyncResponseTransformer);
CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
asyncResponseHandler.exceptionOccurred(e);
} finally {
future.completeExceptionally(e);
}
}
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return CompletableFutureUtils.forwardExceptionTo(future, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the GetOperationWithChecksum operation asynchronously.
*
* @param getOperationWithChecksumRequest
* @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(false).build();
HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest));
CompletableFuture<GetOperationWithChecksumResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param getWithoutRequiredMembersRequest
* @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers(
GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetWithoutRequiredMembersResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<GetWithoutRequiredMembersResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>()
.withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getWithoutRequiredMembersRequest));
CompletableFuture<GetWithoutRequiredMembersResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithChecksumRequired operation asynchronously.
*
* @param operationWithChecksumRequiredRequest
* @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithChecksumRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest));
CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithRequestCompression operation asynchronously.
*
* @param operationWithRequestCompressionRequest
* @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithRequestCompressionResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withInput(operationWithRequestCompressionRequest));
CompletableFuture<OperationWithRequestCompressionResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @param paginatedOperationWithResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PaginatedOperationWithResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<PaginatedOperationWithResultKeyResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>()
.withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata)
.withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(paginatedOperationWithResultKeyRequest));
CompletableFuture<PaginatedOperationWithResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some paginated operation without result_key in paginators.json file
*
* @param paginatedOperationWithoutResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory
.createResponseHandler(operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<PaginatedOperationWithoutResultKeyResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>()
.withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata)
.withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(paginatedOperationWithoutResultKeyRequest));
CompletableFuture<PaginatedOperationWithoutResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the PutOperationWithChecksum operation asynchronously.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum(
PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
if (!isSignerOverridden(clientConfiguration)) {
putOperationWithChecksumRequest = applySignerOverride(putOperationWithChecksumRequest, AsyncAws4Signer.create());
}
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build())
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.withAsyncRequestBody(requestBody)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build()).withInput(putOperationWithChecksumRequest), asyncResponseTransformer);
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
if (!isSignerOverridden(clientConfiguration)) {
streamingInputOperationRequest = applySignerOverride(streamingInputOperationRequest, AsyncAws4Signer.create());
}
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody)
.withInput(streamingInputOperationRequest));
CompletableFuture<StreamingInputOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
streamingInputOutputOperationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation");
Pair<AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
streamingInputOutputOperationRequest = applySignerOverride(streamingInputOutputOperationRequest,
Aws4UnsignedPayloadSigner.create());
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>()
.withOperationName("StreamingInputOutputOperation")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller
.builder()
.delegateMarshaller(
new StreamingInputOutputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).transferEncoding(true).build())
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withAsyncRequestBody(requestBody).withInput(streamingInputOutputOperationRequest),
asyncResponseTransformer);
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest,
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(streamingOutputOperationRequest), asyncResponseTransformer);
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public final JsonServiceClientConfiguration serviceClientConfiguration() {
return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(JsonException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build());
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private <T extends JsonRequest> T applySignerOverride(T request, Signer signer) {
if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) {
return request;
}
Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build();
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(signerOverride).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
private static boolean isSignerOverridden(SdkClientConfiguration clientConfiguration) {
return Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.SIGNER_OVERRIDDEN));
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,535 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-json-async-client-class.java | package software.amazon.awssdk.services.json;
import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.signer.AsyncAws4Signer;
import software.amazon.awssdk.auth.signer.Aws4UnsignedPayloadSigner;
import software.amazon.awssdk.auth.signer.EventStreamAws4Signer;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.client.handler.AwsClientHandlerUtils;
import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer;
import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionJsonMarshaller;
import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkPojoBuilder;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.SdkResponse;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils;
import software.amazon.awssdk.core.async.SdkPublisher;
import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
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.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.protocol.VoidSdkResponse;
import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller;
import software.amazon.awssdk.core.signer.Signer;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.json.model.APostOperationRequest;
import software.amazon.awssdk.services.json.model.APostOperationResponse;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.json.model.EventStream;
import software.amazon.awssdk.services.json.model.EventStreamOperationRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse;
import software.amazon.awssdk.services.json.model.InputEventStream;
import software.amazon.awssdk.services.json.model.InputEventStreamTwo;
import software.amazon.awssdk.services.json.model.InvalidInputException;
import software.amazon.awssdk.services.json.model.JsonException;
import software.amazon.awssdk.services.json.model.JsonRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.json.model.OperationWithNoneAuthTypeRequest;
import software.amazon.awssdk.services.json.model.OperationWithNoneAuthTypeResponse;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse;
import software.amazon.awssdk.services.json.model.ServiceFaultException;
import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.json.model.inputeventstream.DefaultInputEvent;
import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventOne;
import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventTwo;
import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyInputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyOutputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller;
import software.amazon.awssdk.services.json.transform.InputEventMarshaller;
import software.amazon.awssdk.services.json.transform.InputEventTwoMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithNoneAuthTypeRequestMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
import software.amazon.awssdk.utils.HostnameValidator;
import software.amazon.awssdk.utils.Pair;
/**
* Internal implementation of {@link JsonAsyncClient}.
*
* @see JsonAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultJsonAsyncClient implements JsonAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultJsonAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.AWS_JSON).build();
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private final Executor executor;
protected DefaultJsonAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR);
}
@Override
public JsonUtilities utilities() {
return JsonUtilities.create(param1, param2, param3);
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
String hostPrefix = "{StringMember}-foo.";
HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember",
"aPostOperationRequest");
String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember());
CompletableFuture<APostOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
CompletableFuture<APostOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>ServiceFaultException</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, APostOperationWithOutputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(aPostOperationWithOutputRequest));
CompletableFuture<APostOperationWithOutputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperation operation asynchronously.
*
* @param eventStreamOperationRequest
* @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest,
Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation");
eventStreamOperationRequest = applySignerOverride(eventStreamOperationRequest, EventStreamAws4Signer.create());
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationResponse> responseHandler = new AttachHttpMetadataResponseHandler(
protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder));
HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata
.builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
.putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
.putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
.putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
.putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build();
SdkPublisher<InputEventStream> eventPublisher = SdkPublisher.adapt(requestStream);
Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture<Void> future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer
.<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler)
.eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
.exceptionResponseHandler(errorResponseHandler).future(future).executor(executor).serviceName(serviceName())
.build();
CompletableFuture<Void> executeFuture = clientHandler.execute(
new ClientExecutionParams<EventStreamOperationRequest, SdkResponse>()
.withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
.withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true)
.withInitialRequestEvent(true).withResponseHandler(voidResponseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest),
asyncResponseTransformer);
CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
asyncResponseHandler.exceptionOccurred(e);
} finally {
future.completeExceptionally(e);
}
}
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return CompletableFutureUtils.forwardExceptionTo(future, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperationWithOnlyInput operation asynchronously.
*
* @param eventStreamOperationWithOnlyInputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyInput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput(
EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest,
Publisher<InputEventStreamTwo> requestStream) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyInputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyInput");
eventStreamOperationWithOnlyInputRequest = applySignerOverride(eventStreamOperationWithOnlyInputRequest,
EventStreamAws4Signer.create());
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationWithOnlyInputResponse> responseHandler = protocolFactory
.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
.putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory))
.putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build();
SdkPublisher<InputEventStreamTwo> eventPublisher = SdkPublisher.adapt(requestStream);
Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture<EventStreamOperationWithOnlyInputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<EventStreamOperationWithOnlyInputRequest, EventStreamOperationWithOnlyInputResponse>()
.withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory))
.withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withInitialRequestEvent(true)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(eventStreamOperationWithOnlyInputRequest));
CompletableFuture<EventStreamOperationWithOnlyInputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperationWithOnlyOutput operation asynchronously.
*
* @param eventStreamOperationWithOnlyOutputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperationWithOnlyOutput(
EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest,
EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationWithOnlyOutputResponse> responseHandler = new AttachHttpMetadataResponseHandler(
protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder));
HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata
.builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
.putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
.putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
.putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<Void> future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer
.<EventStreamOperationWithOnlyOutputResponse, EventStream> builder()
.eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler)
.initialResponseHandler(responseHandler).exceptionResponseHandler(errorResponseHandler).future(future)
.executor(executor).serviceName(serviceName()).build();
CompletableFuture<Void> executeFuture = clientHandler.execute(
new ClientExecutionParams<EventStreamOperationWithOnlyOutputRequest, SdkResponse>()
.withOperationName("EventStreamOperationWithOnlyOutput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationWithOnlyOutputRequestMarshaller(protocolFactory))
.withResponseHandler(voidResponseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(eventStreamOperationWithOnlyOutputRequest), asyncResponseTransformer);
CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
asyncResponseHandler.exceptionOccurred(e);
} finally {
future.completeExceptionally(e);
}
}
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return CompletableFutureUtils.forwardExceptionTo(future, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param getWithoutRequiredMembersRequest
* @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers(
GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetWithoutRequiredMembersResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<GetWithoutRequiredMembersResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>()
.withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getWithoutRequiredMembersRequest));
CompletableFuture<GetWithoutRequiredMembersResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithChecksumRequired operation asynchronously.
*
* @param operationWithChecksumRequiredRequest
* @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithChecksumRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest));
CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithNoneAuthType operation asynchronously.
*
* @param operationWithNoneAuthTypeRequest
* @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithNoneAuthType
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithNoneAuthType"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType(
OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithNoneAuthTypeResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>()
.withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.IS_NONE_AUTH_TYPE_REQUEST, false)
.withInput(operationWithNoneAuthTypeRequest));
CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithRequestCompression operation asynchronously.
*
* @param operationWithRequestCompressionRequest
* @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithRequestCompressionResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withInput(operationWithRequestCompressionRequest));
CompletableFuture<OperationWithRequestCompressionResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @param paginatedOperationWithResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PaginatedOperationWithResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<PaginatedOperationWithResultKeyResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>()
.withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata)
.withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(paginatedOperationWithResultKeyRequest));
CompletableFuture<PaginatedOperationWithResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some paginated operation without result_key in paginators.json file
*
* @param paginatedOperationWithoutResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory
.createResponseHandler(operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<PaginatedOperationWithoutResultKeyResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>()
.withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata)
.withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(paginatedOperationWithoutResultKeyRequest));
CompletableFuture<PaginatedOperationWithoutResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
if (!isSignerOverridden(clientConfiguration)) {
streamingInputOperationRequest = applySignerOverride(streamingInputOperationRequest, AsyncAws4Signer.create());
}
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody)
.withInput(streamingInputOperationRequest));
CompletableFuture<StreamingInputOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
streamingInputOutputOperationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation");
Pair<AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
streamingInputOutputOperationRequest = applySignerOverride(streamingInputOutputOperationRequest,
Aws4UnsignedPayloadSigner.create());
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>()
.withOperationName("StreamingInputOutputOperation")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller
.builder()
.delegateMarshaller(
new StreamingInputOutputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).transferEncoding(true).build())
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withAsyncRequestBody(requestBody).withInput(streamingInputOutputOperationRequest),
asyncResponseTransformer);
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest,
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(streamingOutputOperationRequest), asyncResponseTransformer);
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public final JsonServiceClientConfiguration serviceClientConfiguration() {
return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(JsonException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInputException")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceFaultException")
.exceptionBuilderSupplier(ServiceFaultException::builder).httpStatusCode(500).build());
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private <T extends JsonRequest> T applySignerOverride(T request, Signer signer) {
if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) {
return request;
}
Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build();
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(signerOverride).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
private static boolean isSignerOverridden(SdkClientConfiguration clientConfiguration) {
return Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.SIGNER_OVERRIDDEN));
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,536 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java | package software.amazon.awssdk.services.query;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller;
import software.amazon.awssdk.core.signer.Signer;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.query.AwsQueryProtocolFactory;
import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.query.model.APostOperationRequest;
import software.amazon.awssdk.services.query.model.APostOperationResponse;
import software.amazon.awssdk.services.query.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.query.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.query.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.query.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.query.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.query.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.query.model.InvalidInputException;
import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.query.model.OperationWithContextParamRequest;
import software.amazon.awssdk.services.query.model.OperationWithContextParamResponse;
import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeRequest;
import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeResponse;
import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsRequest;
import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsResponse;
import software.amazon.awssdk.services.query.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.query.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.query.model.QueryException;
import software.amazon.awssdk.services.query.model.QueryRequest;
import software.amazon.awssdk.services.query.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.query.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.query.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.query.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.query.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.query.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithContextParamRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithNoneAuthTypeRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithStaticContextParamsRequestMarshaller;
import software.amazon.awssdk.services.query.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.query.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.services.query.waiters.QueryWaiter;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link QueryClient}.
*
* @see QueryClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultQueryClient implements QueryClient {
private static final Logger log = Logger.loggerFor(DefaultQueryClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.QUERY).build();
private final SyncClientHandler clientHandler;
private final AwsQueryProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultQueryClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return Result of the APostOperation operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException,
AwsServiceException, SdkClientException, QueryException {
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory
.createResponseHandler(APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
String hostPrefix = "foo-";
String resolvedHostExpression = "foo-";
return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration)
.withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return Result of the APostOperationWithOutput operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public APostOperationWithOutputResponse aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, QueryException {
HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory
.createResponseHandler(APostOperationWithOutputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
return clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the BearerAuthOperation operation.
*
* @param bearerAuthOperationRequest
* @return Result of the BearerAuthOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest)
throws AwsServiceException, SdkClientException, QueryException {
bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create());
HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory
.createResponseHandler(BearerAuthOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration)
.withInput(bearerAuthOperationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the GetOperationWithChecksum operation.
*
* @param getOperationWithChecksumRequest
* @return Result of the GetOperationWithChecksum operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public GetOperationWithChecksumResponse getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException,
QueryException {
HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory
.createResponseHandler(GetOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
return clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(getOperationWithChecksumRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build())
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithChecksumRequired operation.
*
* @param operationWithChecksumRequiredRequest
* @return Result of the OperationWithChecksumRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithChecksumRequiredResponse operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException,
SdkClientException, QueryException {
HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithChecksumRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
return clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithChecksumRequiredRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create())
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithContextParam operation.
*
* @param operationWithContextParamRequest
* @return Result of the OperationWithContextParam operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.OperationWithContextParam
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithContextParam"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithContextParamResponse operationWithContextParam(
OperationWithContextParamRequest operationWithContextParamRequest) throws AwsServiceException, SdkClientException,
QueryException {
HttpResponseHandler<OperationWithContextParamResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithContextParamResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithContextParamRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithContextParamRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithContextParam");
return clientHandler
.execute(new ClientExecutionParams<OperationWithContextParamRequest, OperationWithContextParamResponse>()
.withOperationName("OperationWithContextParam").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(operationWithContextParamRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new OperationWithContextParamRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithNoneAuthType operation.
*
* @param operationWithNoneAuthTypeRequest
* @return Result of the OperationWithNoneAuthType operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.OperationWithNoneAuthType
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithNoneAuthType"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithNoneAuthTypeResponse operationWithNoneAuthType(
OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) throws AwsServiceException, SdkClientException,
QueryException {
HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithNoneAuthTypeResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType");
return clientHandler
.execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>()
.withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(operationWithNoneAuthTypeRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.IS_NONE_AUTH_TYPE_REQUEST, false)
.withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithRequestCompression operation.
*
* @param operationWithRequestCompressionRequest
* @return Result of the OperationWithRequestCompression operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithRequestCompressionResponse operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException,
SdkClientException, QueryException {
HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithRequestCompressionResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
return clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithRequestCompressionRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithStaticContextParams operation.
*
* @param operationWithStaticContextParamsRequest
* @return Result of the OperationWithStaticContextParams operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.OperationWithStaticContextParams
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithStaticContextParams"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithStaticContextParamsResponse operationWithStaticContextParams(
OperationWithStaticContextParamsRequest operationWithStaticContextParamsRequest) throws AwsServiceException,
SdkClientException, QueryException {
HttpResponseHandler<OperationWithStaticContextParamsResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithStaticContextParamsResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithStaticContextParamsRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithStaticContextParamsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithStaticContextParams");
return clientHandler
.execute(new ClientExecutionParams<OperationWithStaticContextParamsRequest, OperationWithStaticContextParamsResponse>()
.withOperationName("OperationWithStaticContextParams").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(operationWithStaticContextParamsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new OperationWithStaticContextParamsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the PutOperationWithChecksum operation.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest,
RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer)
throws AwsServiceException, SdkClientException, QueryException {
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory
.createResponseHandler(PutOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
return clientHandler
.execute(new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(putOperationWithChecksumRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build())
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest,
RequestBody requestBody) throws AwsServiceException, SdkClientException, QueryException {
HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory
.createResponseHandler(StreamingInputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
return clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(streamingInputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest,
ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, QueryException {
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory
.createResponseHandler(StreamingOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
return clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer);
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Create an instance of {@link QueryWaiter} using this client.
* <p>
* Waiters created via this method are managed by the SDK and resources will be released when the service client is
* closed.
*
* @return an instance of {@link QueryWaiter}
*/
@Override
public QueryWaiter waiter() {
return QueryWaiter.builder().client(this).build();
}
private <T extends QueryRequest> T applySignerOverride(T request, Signer signer) {
if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) {
return request;
}
Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build();
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(signerOverride).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private AwsQueryProtocolFactory init() {
return AwsQueryProtocolFactory
.builder()
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
.clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(QueryException::builder).build();
}
@Override
public final QueryServiceClientConfiguration serviceClientConfiguration() {
return new QueryServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,537 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-sync-client-class.java | package software.amazon.awssdk.services.querytojsoncompatible;
import java.util.Collections;
import java.util.List;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.querytojsoncompatible.internal.QueryToJsonCompatibleServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.querytojsoncompatible.model.APostOperationRequest;
import software.amazon.awssdk.services.querytojsoncompatible.model.APostOperationResponse;
import software.amazon.awssdk.services.querytojsoncompatible.model.InvalidInputException;
import software.amazon.awssdk.services.querytojsoncompatible.model.QueryToJsonCompatibleException;
import software.amazon.awssdk.services.querytojsoncompatible.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.utils.HostnameValidator;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link QueryToJsonCompatibleClient}.
*
* @see QueryToJsonCompatibleClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultQueryToJsonCompatibleClient implements QueryToJsonCompatibleClient {
private static final Logger log = Logger.loggerFor(DefaultQueryToJsonCompatibleClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.AWS_JSON).build();
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultQueryToJsonCompatibleClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return Result of the APostOperation operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryToJsonCompatibleException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryToJsonCompatibleClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-to-json-compatible-service-2010-05-08/APostOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException,
AwsServiceException, SdkClientException, QueryToJsonCompatibleException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata,
APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QueryToJsonCompatibleService");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
String hostPrefix = "{StringMember}-foo.";
HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember",
"aPostOperationRequest");
String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember());
return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration)
.withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
QueryToJsonCompatibleServiceClientConfigurationBuilder serviceConfigBuilder = new QueryToJsonCompatibleServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(QueryToJsonCompatibleException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.1")
.hasAwsQueryCompatible(true)
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build());
}
@Override
public final QueryToJsonCompatibleServiceClientConfiguration serviceClientConfiguration() {
return new QueryToJsonCompatibleServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,538 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-sync.java | package software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype;
import java.util.Collections;
import java.util.List;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.internal.ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.OneOperationRequest;
import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.OneOperationResponse;
import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.ProtocolRestJsonWithCustomContentTypeException;
import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.transform.OneOperationRequestMarshaller;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link ProtocolRestJsonWithCustomContentTypeClient}.
*
* @see ProtocolRestJsonWithCustomContentTypeClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultProtocolRestJsonWithCustomContentTypeClient implements ProtocolRestJsonWithCustomContentTypeClient {
private static final Logger log = Logger.loggerFor(DefaultProtocolRestJsonWithCustomContentTypeClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultProtocolRestJsonWithCustomContentTypeClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
* Invokes the OneOperation operation.
*
* @param oneOperationRequest
* @return Result of the OneOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ProtocolRestJsonWithCustomContentTypeException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ProtocolRestJsonWithCustomContentTypeClient.OneOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/restjson-2016-03-11/OneOperation" target="_top">AWS API
* Documentation</a>
*/
@Override
public OneOperationResponse oneOperation(OneOperationRequest oneOperationRequest) throws AwsServiceException,
SdkClientException, ProtocolRestJsonWithCustomContentTypeException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OneOperationResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata,
OneOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(oneOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, oneOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AmazonProtocolRestJsonWithCustomContentType");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OneOperation");
return clientHandler.execute(new ClientExecutionParams<OneOperationRequest, OneOperationResponse>()
.withOperationName("OneOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(oneOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new OneOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder serviceConfigBuilder = new ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(ProtocolRestJsonWithCustomContentTypeException::builder)
.protocol(AwsJsonProtocol.REST_JSON).protocolVersion("1.1").contentType("application/json");
}
@Override
public final ProtocolRestJsonWithCustomContentTypeServiceClientConfiguration serviceClientConfiguration() {
return new ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder())
.build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,539 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-async-client-class.java | package software.amazon.awssdk.services.querytojsoncompatible;
import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.querytojsoncompatible.internal.QueryToJsonCompatibleServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.querytojsoncompatible.model.APostOperationRequest;
import software.amazon.awssdk.services.querytojsoncompatible.model.APostOperationResponse;
import software.amazon.awssdk.services.querytojsoncompatible.model.InvalidInputException;
import software.amazon.awssdk.services.querytojsoncompatible.model.QueryToJsonCompatibleException;
import software.amazon.awssdk.services.querytojsoncompatible.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
import software.amazon.awssdk.utils.HostnameValidator;
/**
* Internal implementation of {@link QueryToJsonCompatibleAsyncClient}.
*
* @see QueryToJsonCompatibleAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultQueryToJsonCompatibleAsyncClient implements QueryToJsonCompatibleAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultQueryToJsonCompatibleAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.AWS_JSON).build();
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultQueryToJsonCompatibleAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryToJsonCompatibleException Base class for all service exceptions. Unknown exceptions will be
* thrown as an instance of this type.</li>
* </ul>
* @sample QueryToJsonCompatibleAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-to-json-compatible-service-2010-05-08/APostOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QueryToJsonCompatibleService");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
String hostPrefix = "{StringMember}-foo.";
HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember",
"aPostOperationRequest");
String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember());
CompletableFuture<APostOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
CompletableFuture<APostOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public final QueryToJsonCompatibleServiceClientConfiguration serviceClientConfiguration() {
return new QueryToJsonCompatibleServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(QueryToJsonCompatibleException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.1")
.hasAwsQueryCompatible(true)
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build());
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
QueryToJsonCompatibleServiceClientConfigurationBuilder serviceConfigBuilder = new QueryToJsonCompatibleServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,540 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-interface.java | package software.amazon.awssdk.services.json;
import java.nio.file.Path;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.annotations.ThreadSafe;
import software.amazon.awssdk.awscore.AwsClient;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.ResponseBytes;
import software.amazon.awssdk.core.ResponseInputStream;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.regions.ServiceMetadata;
import software.amazon.awssdk.services.json.model.APostOperationRequest;
import software.amazon.awssdk.services.json.model.APostOperationResponse;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse;
import software.amazon.awssdk.services.json.model.InvalidInputException;
import software.amazon.awssdk.services.json.model.JsonException;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable;
import software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable;
/**
* Service client for accessing Json Service. This can be created using the static {@link #builder()} method.
*
* A service that is implemented using the query protocol
*/
@Generated("software.amazon.awssdk:codegen")
@SdkPublicApi
@ThreadSafe
public interface JsonClient extends AwsClient {
String SERVICE_NAME = "json-service";
/**
* Value for looking up the service's metadata from the
* {@link software.amazon.awssdk.regions.ServiceMetadataProvider}.
*/
String SERVICE_METADATA_ID = "json-service-endpoint";
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return Result of the APostOperation operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*
* @deprecated This API is deprecated, use something else
*/
@Deprecated
default APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException,
AwsServiceException, SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
* <br/>
* <p>
* This is a convenience which creates an instance of the {@link APostOperationRequest.Builder} avoiding the need to
* create one manually via {@link APostOperationRequest#builder()}
* </p>
*
* @param aPostOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.APostOperationRequest.Builder} to create a request.
* @return Result of the APostOperation operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*
* @deprecated This API is deprecated, use something else
*/
@Deprecated
default APostOperationResponse aPostOperation(Consumer<APostOperationRequest.Builder> aPostOperationRequest)
throws InvalidInputException, AwsServiceException, SdkClientException, JsonException {
return aPostOperation(APostOperationRequest.builder().applyMutation(aPostOperationRequest).build());
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return Result of the APostOperationWithOutput operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
default APostOperationWithOutputResponse aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
* <br/>
* <p>
* This is a convenience which creates an instance of the {@link APostOperationWithOutputRequest.Builder} avoiding
* the need to create one manually via {@link APostOperationWithOutputRequest#builder()}
* </p>
*
* @param aPostOperationWithOutputRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest.Builder} to create a
* request.
* @return Result of the APostOperationWithOutput operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
default APostOperationWithOutputResponse aPostOperationWithOutput(
Consumer<APostOperationWithOutputRequest.Builder> aPostOperationWithOutputRequest) throws InvalidInputException,
AwsServiceException, SdkClientException, JsonException {
return aPostOperationWithOutput(APostOperationWithOutputRequest.builder().applyMutation(aPostOperationWithOutputRequest)
.build());
}
/**
* Invokes the BearerAuthOperation operation.
*
* @param bearerAuthOperationRequest
* @return Result of the BearerAuthOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
default BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest)
throws AwsServiceException, SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* Invokes the BearerAuthOperation operation.<br/>
* <p>
* This is a convenience which creates an instance of the {@link BearerAuthOperationRequest.Builder} avoiding the
* need to create one manually via {@link BearerAuthOperationRequest#builder()}
* </p>
*
* @param bearerAuthOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.BearerAuthOperationRequest.Builder} to create a request.
* @return Result of the BearerAuthOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
default BearerAuthOperationResponse bearerAuthOperation(
Consumer<BearerAuthOperationRequest.Builder> bearerAuthOperationRequest) throws AwsServiceException,
SdkClientException, JsonException {
return bearerAuthOperation(BearerAuthOperationRequest.builder().applyMutation(bearerAuthOperationRequest).build());
}
/**
* Invokes the GetOperationWithChecksum operation.
*
* @param getOperationWithChecksumRequest
* @return Result of the GetOperationWithChecksum operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default GetOperationWithChecksumResponse getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException,
JsonException {
throw new UnsupportedOperationException();
}
/**
* Invokes the GetOperationWithChecksum operation.<br/>
* <p>
* This is a convenience which creates an instance of the {@link GetOperationWithChecksumRequest.Builder} avoiding
* the need to create one manually via {@link GetOperationWithChecksumRequest#builder()}
* </p>
*
* @param getOperationWithChecksumRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest.Builder} to create a
* request.
* @return Result of the GetOperationWithChecksum operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default GetOperationWithChecksumResponse getOperationWithChecksum(
Consumer<GetOperationWithChecksumRequest.Builder> getOperationWithChecksumRequest) throws AwsServiceException,
SdkClientException, JsonException {
return getOperationWithChecksum(GetOperationWithChecksumRequest.builder().applyMutation(getOperationWithChecksumRequest)
.build());
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param getWithoutRequiredMembersRequest
* @return Result of the GetWithoutRequiredMembers operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
default GetWithoutRequiredMembersResponse getWithoutRequiredMembers(
GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
* <br/>
* <p>
* This is a convenience which creates an instance of the {@link GetWithoutRequiredMembersRequest.Builder} avoiding
* the need to create one manually via {@link GetWithoutRequiredMembersRequest#builder()}
* </p>
*
* @param getWithoutRequiredMembersRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest.Builder} to create a
* request.
* @return Result of the GetWithoutRequiredMembers operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
default GetWithoutRequiredMembersResponse getWithoutRequiredMembers(
Consumer<GetWithoutRequiredMembersRequest.Builder> getWithoutRequiredMembersRequest) throws InvalidInputException,
AwsServiceException, SdkClientException, JsonException {
return getWithoutRequiredMembers(GetWithoutRequiredMembersRequest.builder()
.applyMutation(getWithoutRequiredMembersRequest).build());
}
/**
* Invokes the OperationWithChecksumRequired operation.
*
* @param operationWithChecksumRequiredRequest
* @return Result of the OperationWithChecksumRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
default OperationWithChecksumRequiredResponse operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException,
SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* Invokes the OperationWithChecksumRequired operation.<br/>
* <p>
* This is a convenience which creates an instance of the {@link OperationWithChecksumRequiredRequest.Builder}
* avoiding the need to create one manually via {@link OperationWithChecksumRequiredRequest#builder()}
* </p>
*
* @param operationWithChecksumRequiredRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest.Builder} to create
* a request.
* @return Result of the OperationWithChecksumRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
default OperationWithChecksumRequiredResponse operationWithChecksumRequired(
Consumer<OperationWithChecksumRequiredRequest.Builder> operationWithChecksumRequiredRequest)
throws AwsServiceException, SdkClientException, JsonException {
return operationWithChecksumRequired(OperationWithChecksumRequiredRequest.builder()
.applyMutation(operationWithChecksumRequiredRequest).build());
}
/**
* Invokes the OperationWithRequestCompression operation.
*
* @param operationWithRequestCompressionRequest
* @return Result of the OperationWithRequestCompression operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
default OperationWithRequestCompressionResponse operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException,
SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* Invokes the OperationWithRequestCompression operation.<br/>
* <p>
* This is a convenience which creates an instance of the {@link OperationWithRequestCompressionRequest.Builder}
* avoiding the need to create one manually via {@link OperationWithRequestCompressionRequest#builder()}
* </p>
*
* @param operationWithRequestCompressionRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest.Builder} to
* create a request.
* @return Result of the OperationWithRequestCompression operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
default OperationWithRequestCompressionResponse operationWithRequestCompression(
Consumer<OperationWithRequestCompressionRequest.Builder> operationWithRequestCompressionRequest)
throws AwsServiceException, SdkClientException, JsonException {
return operationWithRequestCompression(OperationWithRequestCompressionRequest.builder()
.applyMutation(operationWithRequestCompressionRequest).build());
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @param paginatedOperationWithResultKeyRequest
* @return Result of the PaginatedOperationWithResultKey operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) throws AwsServiceException,
SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* Some paginated operation with result_key in paginators.json file<br/>
* <p>
* This is a convenience which creates an instance of the {@link PaginatedOperationWithResultKeyRequest.Builder}
* avoiding the need to create one manually via {@link PaginatedOperationWithResultKeyRequest#builder()}
* </p>
*
* @param paginatedOperationWithResultKeyRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest.Builder} to
* create a request.
* @return Result of the PaginatedOperationWithResultKey operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey(
Consumer<PaginatedOperationWithResultKeyRequest.Builder> paginatedOperationWithResultKeyRequest)
throws AwsServiceException, SdkClientException, JsonException {
return paginatedOperationWithResultKey(PaginatedOperationWithResultKeyRequest.builder()
.applyMutation(paginatedOperationWithResultKeyRequest).build());
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @return Result of the PaginatedOperationWithResultKey operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithResultKey
* @see #paginatedOperationWithResultKey(PaginatedOperationWithResultKeyRequest)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey() throws AwsServiceException,
SdkClientException, JsonException {
return paginatedOperationWithResultKey(PaginatedOperationWithResultKeyRequest.builder().build());
}
/**
* Some paginated operation with result_key in paginators.json file<br/>
* <p>
* This is a variant of
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will
* internally handle making service calls for you.
* </p>
* <p>
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
* </p>
*
* <p>
* The following are few ways to iterate through the response pages:
* </p>
* 1) Using a Stream
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request);
* responses.stream().forEach(....);
* }
* </pre>
*
* 2) Using For loop
*
* <pre>
* {
* @code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client
* .paginatedOperationWithResultKeyPaginator(request);
* for (software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response : responses) {
* // do something;
* }
* }
* </pre>
*
* 3) Use iterator directly
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
* </pre>
* <p>
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.</b>
* </p>
* <p>
* <b>Note: If you prefer to have control on service calls, use the
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation.</b>
* </p>
*
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithResultKey
* @see #paginatedOperationWithResultKeyPaginator(PaginatedOperationWithResultKeyRequest)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithResultKeyIterable paginatedOperationWithResultKeyPaginator() throws AwsServiceException,
SdkClientException, JsonException {
return paginatedOperationWithResultKeyPaginator(PaginatedOperationWithResultKeyRequest.builder().build());
}
/**
* Some paginated operation with result_key in paginators.json file<br/>
* <p>
* This is a variant of
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will
* internally handle making service calls for you.
* </p>
* <p>
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
* </p>
*
* <p>
* The following are few ways to iterate through the response pages:
* </p>
* 1) Using a Stream
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request);
* responses.stream().forEach(....);
* }
* </pre>
*
* 2) Using For loop
*
* <pre>
* {
* @code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client
* .paginatedOperationWithResultKeyPaginator(request);
* for (software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response : responses) {
* // do something;
* }
* }
* </pre>
*
* 3) Use iterator directly
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
* </pre>
* <p>
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.</b>
* </p>
* <p>
* <b>Note: If you prefer to have control on service calls, use the
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation.</b>
* </p>
*
* @param paginatedOperationWithResultKeyRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithResultKeyIterable paginatedOperationWithResultKeyPaginator(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) throws AwsServiceException,
SdkClientException, JsonException {
return new PaginatedOperationWithResultKeyIterable(this, paginatedOperationWithResultKeyRequest);
}
/**
* Some paginated operation with result_key in paginators.json file<br/>
* <p>
* This is a variant of
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will
* internally handle making service calls for you.
* </p>
* <p>
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
* </p>
*
* <p>
* The following are few ways to iterate through the response pages:
* </p>
* 1) Using a Stream
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request);
* responses.stream().forEach(....);
* }
* </pre>
*
* 2) Using For loop
*
* <pre>
* {
* @code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client
* .paginatedOperationWithResultKeyPaginator(request);
* for (software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response : responses) {
* // do something;
* }
* }
* </pre>
*
* 3) Use iterator directly
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
* </pre>
* <p>
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.</b>
* </p>
* <p>
* <b>Note: If you prefer to have control on service calls, use the
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation.</b>
* </p>
* <p>
* This is a convenience which creates an instance of the {@link PaginatedOperationWithResultKeyRequest.Builder}
* avoiding the need to create one manually via {@link PaginatedOperationWithResultKeyRequest#builder()}
* </p>
*
* @param paginatedOperationWithResultKeyRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest.Builder} to
* create a request.
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithResultKeyIterable paginatedOperationWithResultKeyPaginator(
Consumer<PaginatedOperationWithResultKeyRequest.Builder> paginatedOperationWithResultKeyRequest)
throws AwsServiceException, SdkClientException, JsonException {
return paginatedOperationWithResultKeyPaginator(PaginatedOperationWithResultKeyRequest.builder()
.applyMutation(paginatedOperationWithResultKeyRequest).build());
}
/**
* Some paginated operation without result_key in paginators.json file
*
* @param paginatedOperationWithoutResultKeyRequest
* @return Result of the PaginatedOperationWithoutResultKey operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResultKey(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) throws AwsServiceException,
SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* Some paginated operation without result_key in paginators.json file<br/>
* <p>
* This is a convenience which creates an instance of the {@link PaginatedOperationWithoutResultKeyRequest.Builder}
* avoiding the need to create one manually via {@link PaginatedOperationWithoutResultKeyRequest#builder()}
* </p>
*
* @param paginatedOperationWithoutResultKeyRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest.Builder} to
* create a request.
* @return Result of the PaginatedOperationWithoutResultKey operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResultKey(
Consumer<PaginatedOperationWithoutResultKeyRequest.Builder> paginatedOperationWithoutResultKeyRequest)
throws AwsServiceException, SdkClientException, JsonException {
return paginatedOperationWithoutResultKey(PaginatedOperationWithoutResultKeyRequest.builder()
.applyMutation(paginatedOperationWithoutResultKeyRequest).build());
}
/**
* Some paginated operation without result_key in paginators.json file<br/>
* <p>
* This is a variant of
* {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)}
* operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will
* internally handle making service calls for you.
* </p>
* <p>
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
* </p>
*
* <p>
* The following are few ways to iterate through the response pages:
* </p>
* 1) Using a Stream
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client.paginatedOperationWithoutResultKeyPaginator(request);
* responses.stream().forEach(....);
* }
* </pre>
*
* 2) Using For loop
*
* <pre>
* {
* @code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client
* .paginatedOperationWithoutResultKeyPaginator(request);
* for (software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse response : responses) {
* // do something;
* }
* }
* </pre>
*
* 3) Use iterator directly
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client.paginatedOperationWithoutResultKeyPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
* </pre>
* <p>
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.</b>
* </p>
* <p>
* <b>Note: If you prefer to have control on service calls, use the
* {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)}
* operation.</b>
* </p>
*
* @param paginatedOperationWithoutResultKeyRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithoutResultKeyIterable paginatedOperationWithoutResultKeyPaginator(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) throws AwsServiceException,
SdkClientException, JsonException {
return new PaginatedOperationWithoutResultKeyIterable(this, paginatedOperationWithoutResultKeyRequest);
}
/**
* Some paginated operation without result_key in paginators.json file<br/>
* <p>
* This is a variant of
* {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)}
* operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will
* internally handle making service calls for you.
* </p>
* <p>
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
* </p>
*
* <p>
* The following are few ways to iterate through the response pages:
* </p>
* 1) Using a Stream
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client.paginatedOperationWithoutResultKeyPaginator(request);
* responses.stream().forEach(....);
* }
* </pre>
*
* 2) Using For loop
*
* <pre>
* {
* @code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client
* .paginatedOperationWithoutResultKeyPaginator(request);
* for (software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse response : responses) {
* // do something;
* }
* }
* </pre>
*
* 3) Use iterator directly
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client.paginatedOperationWithoutResultKeyPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
* </pre>
* <p>
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.</b>
* </p>
* <p>
* <b>Note: If you prefer to have control on service calls, use the
* {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)}
* operation.</b>
* </p>
* <p>
* This is a convenience which creates an instance of the {@link PaginatedOperationWithoutResultKeyRequest.Builder}
* avoiding the need to create one manually via {@link PaginatedOperationWithoutResultKeyRequest#builder()}
* </p>
*
* @param paginatedOperationWithoutResultKeyRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest.Builder} to
* create a request.
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithoutResultKeyIterable paginatedOperationWithoutResultKeyPaginator(
Consumer<PaginatedOperationWithoutResultKeyRequest.Builder> paginatedOperationWithoutResultKeyRequest)
throws AwsServiceException, SdkClientException, JsonException {
return paginatedOperationWithoutResultKeyPaginator(PaginatedOperationWithoutResultKeyRequest.builder()
.applyMutation(paginatedOperationWithoutResultKeyRequest).build());
}
/**
* Invokes the PutOperationWithChecksum operation.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest,
RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer)
throws AwsServiceException, SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* Invokes the PutOperationWithChecksum operation.<br/>
* <p>
* This is a convenience which creates an instance of the {@link PutOperationWithChecksumRequest.Builder} avoiding
* the need to create one manually via {@link PutOperationWithChecksumRequest#builder()}
* </p>
*
* @param putOperationWithChecksumRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest.Builder} to create a
* request.
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> ReturnT putOperationWithChecksum(
Consumer<PutOperationWithChecksumRequest.Builder> putOperationWithChecksumRequest, RequestBody requestBody,
ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, JsonException {
return putOperationWithChecksum(PutOperationWithChecksumRequest.builder().applyMutation(putOperationWithChecksumRequest)
.build(), requestBody, responseTransformer);
}
/**
* Invokes the PutOperationWithChecksum operation.
*
* @param putOperationWithChecksumRequest
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows '
* <p>
* Object data.
* </p>
* '
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PutOperationWithChecksum
* @see #putOperationWithChecksum(PutOperationWithChecksumRequest, RequestBody)
* @see #putOperationWithChecksum(PutOperationWithChecksumRequest, ResponseTransformer)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default PutOperationWithChecksumResponse putOperationWithChecksum(
PutOperationWithChecksumRequest putOperationWithChecksumRequest, Path sourcePath, Path destinationPath)
throws AwsServiceException, SdkClientException, JsonException {
return putOperationWithChecksum(putOperationWithChecksumRequest, RequestBody.fromFile(sourcePath),
ResponseTransformer.toFile(destinationPath));
}
/**
* Invokes the PutOperationWithChecksum operation.<br/>
* <p>
* This is a convenience which creates an instance of the {@link PutOperationWithChecksumRequest.Builder} avoiding
* the need to create one manually via {@link PutOperationWithChecksumRequest#builder()}
* </p>
*
* @param putOperationWithChecksumRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest.Builder} to create a
* request.
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows '
* <p>
* Object data.
* </p>
* '
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PutOperationWithChecksum
* @see #putOperationWithChecksum(PutOperationWithChecksumRequest, RequestBody)
* @see #putOperationWithChecksum(PutOperationWithChecksumRequest, ResponseTransformer)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default PutOperationWithChecksumResponse putOperationWithChecksum(
Consumer<PutOperationWithChecksumRequest.Builder> putOperationWithChecksumRequest, Path sourcePath,
Path destinationPath) throws AwsServiceException, SdkClientException, JsonException {
return putOperationWithChecksum(PutOperationWithChecksumRequest.builder().applyMutation(putOperationWithChecksumRequest)
.build(), sourcePath, destinationPath);
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
default StreamingInputOperationResponse streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, RequestBody requestBody) throws AwsServiceException,
SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* Some operation with a streaming input<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingInputOperationRequest.Builder} avoiding
* the need to create one manually via {@link StreamingInputOperationRequest#builder()}
* </p>
*
* @param streamingInputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingInputOperationRequest.Builder} to create a
* request.
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
default StreamingInputOperationResponse streamingInputOperation(
Consumer<StreamingInputOperationRequest.Builder> streamingInputOperationRequest, RequestBody requestBody)
throws AwsServiceException, SdkClientException, JsonException {
return streamingInputOperation(StreamingInputOperationRequest.builder().applyMutation(streamingInputOperationRequest)
.build(), requestBody);
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOperation
* @see #streamingInputOperation(StreamingInputOperationRequest, RequestBody)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
default StreamingInputOperationResponse streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, Path sourcePath) throws AwsServiceException,
SdkClientException, JsonException {
return streamingInputOperation(streamingInputOperationRequest, RequestBody.fromFile(sourcePath));
}
/**
* Some operation with a streaming input<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingInputOperationRequest.Builder} avoiding
* the need to create one manually via {@link StreamingInputOperationRequest#builder()}
* </p>
*
* @param streamingInputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingInputOperationRequest.Builder} to create a
* request.
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOperation
* @see #streamingInputOperation(StreamingInputOperationRequest, RequestBody)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
default StreamingInputOperationResponse streamingInputOperation(
Consumer<StreamingInputOperationRequest.Builder> streamingInputOperationRequest, Path sourcePath)
throws AwsServiceException, SdkClientException, JsonException {
return streamingInputOperation(StreamingInputOperationRequest.builder().applyMutation(streamingInputOperationRequest)
.build(), sourcePath);
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingInputOutputOperationResponse and an InputStream to the response content are provided as
* parameters to the callback. The callback may return a transformed type which will be the return value of
* this method. See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing
* this interface and for links to pre-canned implementations for common scenarios like downloading to a
* file. The service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> ReturnT streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, RequestBody requestBody,
ResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* Some operation with streaming input and streaming output<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingInputOutputOperationRequest.Builder}
* avoiding the need to create one manually via {@link StreamingInputOutputOperationRequest#builder()}
* </p>
*
* @param streamingInputOutputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest.Builder} to create
* a request.
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingInputOutputOperationResponse and an InputStream to the response content are provided as
* parameters to the callback. The callback may return a transformed type which will be the return value of
* this method. See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing
* this interface and for links to pre-canned implementations for common scenarios like downloading to a
* file. The service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> ReturnT streamingInputOutputOperation(
Consumer<StreamingInputOutputOperationRequest.Builder> streamingInputOutputOperationRequest, RequestBody requestBody,
ResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, JsonException {
return streamingInputOutputOperation(
StreamingInputOutputOperationRequest.builder().applyMutation(streamingInputOutputOperationRequest).build(),
requestBody, responseTransformer);
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows 'This be a stream'
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOutputOperation
* @see #streamingInputOutputOperation(StreamingInputOutputOperationRequest, RequestBody)
* @see #streamingInputOutputOperation(StreamingInputOutputOperationRequest, ResponseTransformer)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default StreamingInputOutputOperationResponse streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, Path sourcePath, Path destinationPath)
throws AwsServiceException, SdkClientException, JsonException {
return streamingInputOutputOperation(streamingInputOutputOperationRequest, RequestBody.fromFile(sourcePath),
ResponseTransformer.toFile(destinationPath));
}
/**
* Some operation with streaming input and streaming output<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingInputOutputOperationRequest.Builder}
* avoiding the need to create one manually via {@link StreamingInputOutputOperationRequest#builder()}
* </p>
*
* @param streamingInputOutputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest.Builder} to create
* a request.
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows 'This be a stream'
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOutputOperation
* @see #streamingInputOutputOperation(StreamingInputOutputOperationRequest, RequestBody)
* @see #streamingInputOutputOperation(StreamingInputOutputOperationRequest, ResponseTransformer)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default StreamingInputOutputOperationResponse streamingInputOutputOperation(
Consumer<StreamingInputOutputOperationRequest.Builder> streamingInputOutputOperationRequest, Path sourcePath,
Path destinationPath) throws AwsServiceException, SdkClientException, JsonException {
return streamingInputOutputOperation(
StreamingInputOutputOperationRequest.builder().applyMutation(streamingInputOutputOperationRequest).build(),
sourcePath, destinationPath);
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest,
ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, JsonException {
throw new UnsupportedOperationException();
}
/**
* Some operation with a streaming output<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding
* the need to create one manually via {@link StreamingOutputOperationRequest#builder()}
* </p>
*
* @param streamingOutputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a
* request.
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> ReturnT streamingOutputOperation(
Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest,
ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, JsonException {
return streamingOutputOperation(StreamingOutputOperationRequest.builder().applyMutation(streamingOutputOperationRequest)
.build(), responseTransformer);
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingOutputOperation
* @see #streamingOutputOperation(StreamingOutputOperationRequest, ResponseTransformer)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default StreamingOutputOperationResponse streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest, Path destinationPath) throws AwsServiceException,
SdkClientException, JsonException {
return streamingOutputOperation(streamingOutputOperationRequest, ResponseTransformer.toFile(destinationPath));
}
/**
* Some operation with a streaming output<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding
* the need to create one manually via {@link StreamingOutputOperationRequest#builder()}
* </p>
*
* @param streamingOutputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a
* request.
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingOutputOperation
* @see #streamingOutputOperation(StreamingOutputOperationRequest, ResponseTransformer)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default StreamingOutputOperationResponse streamingOutputOperation(
Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest, Path destinationPath)
throws AwsServiceException, SdkClientException, JsonException {
return streamingOutputOperation(StreamingOutputOperationRequest.builder().applyMutation(streamingOutputOperationRequest)
.build(), destinationPath);
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @return A {@link ResponseInputStream} containing data streamed from service. Note that this is an unmanaged
* reference to the underlying HTTP connection so great care must be taken to ensure all data if fully read
* from the input stream and that it is properly closed. Failure to do so may result in sub-optimal behavior
* and exhausting connections in the connection pool. The unmarshalled response object can be obtained via
* {@link ResponseInputStream#response()}. The service documentation for the response content is as follows
* 'This be a stream'.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingOutputOperation
* @see #getObject(streamingOutputOperation, ResponseTransformer)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default ResponseInputStream<StreamingOutputOperationResponse> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest) throws AwsServiceException, SdkClientException,
JsonException {
return streamingOutputOperation(streamingOutputOperationRequest, ResponseTransformer.toInputStream());
}
/**
* Some operation with a streaming output<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding
* the need to create one manually via {@link StreamingOutputOperationRequest#builder()}
* </p>
*
* @param streamingOutputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a
* request.
* @return A {@link ResponseInputStream} containing data streamed from service. Note that this is an unmanaged
* reference to the underlying HTTP connection so great care must be taken to ensure all data if fully read
* from the input stream and that it is properly closed. Failure to do so may result in sub-optimal behavior
* and exhausting connections in the connection pool. The unmarshalled response object can be obtained via
* {@link ResponseInputStream#response()}. The service documentation for the response content is as follows
* 'This be a stream'.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingOutputOperation
* @see #getObject(streamingOutputOperation, ResponseTransformer)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default ResponseInputStream<StreamingOutputOperationResponse> streamingOutputOperation(
Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest) throws AwsServiceException,
SdkClientException, JsonException {
return streamingOutputOperation(StreamingOutputOperationRequest.builder().applyMutation(streamingOutputOperationRequest)
.build());
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @return A {@link ResponseBytes} that loads the data streamed from the service into memory and exposes it in
* convenient in-memory representations like a byte buffer or string. The unmarshalled response object can
* be obtained via {@link ResponseBytes#response()}. The service documentation for the response content is
* as follows 'This be a stream'.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingOutputOperation
* @see #getObject(streamingOutputOperation, ResponseTransformer)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default ResponseBytes<StreamingOutputOperationResponse> streamingOutputOperationAsBytes(
StreamingOutputOperationRequest streamingOutputOperationRequest) throws AwsServiceException, SdkClientException,
JsonException {
return streamingOutputOperation(streamingOutputOperationRequest, ResponseTransformer.toBytes());
}
/**
* Some operation with a streaming output<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding
* the need to create one manually via {@link StreamingOutputOperationRequest#builder()}
* </p>
*
* @param streamingOutputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a
* request.
* @return A {@link ResponseBytes} that loads the data streamed from the service into memory and exposes it in
* convenient in-memory representations like a byte buffer or string. The unmarshalled response object can
* be obtained via {@link ResponseBytes#response()}. The service documentation for the response content is
* as follows 'This be a stream'.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingOutputOperation
* @see #getObject(streamingOutputOperation, ResponseTransformer)
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default ResponseBytes<StreamingOutputOperationResponse> streamingOutputOperationAsBytes(
Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest) throws AwsServiceException,
SdkClientException, JsonException {
return streamingOutputOperationAsBytes(StreamingOutputOperationRequest.builder()
.applyMutation(streamingOutputOperationRequest).build());
}
/**
* Creates an instance of {@link JsonUtilities} object with the configuration set on this client.
*/
default JsonUtilities utilities() {
throw new UnsupportedOperationException();
}
/**
* Create a {@link JsonClient} with the region loaded from the
* {@link software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain} and credentials loaded from the
* {@link software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider}.
*/
static JsonClient create() {
return builder().build();
}
/**
* Create a builder that can be used to configure and create a {@link JsonClient}.
*/
static JsonClientBuilder builder() {
return new DefaultJsonClientBuilder();
}
static ServiceMetadata serviceMetadata() {
return ServiceMetadata.of(SERVICE_METADATA_ID);
}
@Override
default JsonServiceClientConfiguration serviceClientConfiguration() {
throw new UnsupportedOperationException();
}
}
| 3,541 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-async-client-class.java | package software.amazon.awssdk.services.xml;
import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.signer.AsyncAws4Signer;
import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer;
import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier;
import software.amazon.awssdk.awscore.eventstream.RestEventStreamAsyncResponseTransformer;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.Response;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkPojoBuilder;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils;
import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller;
import software.amazon.awssdk.core.signer.Signer;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.xml.AwsXmlProtocolFactory;
import software.amazon.awssdk.protocols.xml.XmlOperationMetadata;
import software.amazon.awssdk.services.xml.internal.XmlServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.xml.model.APostOperationRequest;
import software.amazon.awssdk.services.xml.model.APostOperationResponse;
import software.amazon.awssdk.services.xml.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.xml.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.xml.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.xml.model.EventStream;
import software.amazon.awssdk.services.xml.model.EventStreamOperationRequest;
import software.amazon.awssdk.services.xml.model.EventStreamOperationResponse;
import software.amazon.awssdk.services.xml.model.EventStreamOperationResponseHandler;
import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.xml.model.InvalidInputException;
import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeRequest;
import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeResponse;
import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.xml.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.xml.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.xml.model.XmlException;
import software.amazon.awssdk.services.xml.model.XmlRequest;
import software.amazon.awssdk.services.xml.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.EventStreamOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithNoneAuthTypeRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
import software.amazon.awssdk.utils.Pair;
/**
* Internal implementation of {@link XmlAsyncClient}.
*
* @see XmlAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultXmlAsyncClient implements XmlAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultXmlAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_XML).build();
private final AsyncClientHandler clientHandler;
private final AwsXmlProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private final Executor executor;
protected DefaultXmlAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init();
this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR);
}
/**
* <p>
* Performs a post operation to the xml service and has no output
* </p>
*
* @param aPostOperationRequest
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
HttpResponseHandler<Response<APostOperationResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(APostOperationResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
String hostPrefix = "foo-";
String resolvedHostExpression = "foo-";
CompletableFuture<APostOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler).hostPrefixExpression(resolvedHostExpression)
.withMetricCollector(apiCallMetricCollector).withInput(aPostOperationRequest));
CompletableFuture<APostOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the xml service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
HttpResponseHandler<Response<APostOperationWithOutputResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(APostOperationWithOutputResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.withInput(aPostOperationWithOutputRequest));
CompletableFuture<APostOperationWithOutputResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the BearerAuthOperation operation asynchronously.
*
* @param bearerAuthOperationRequest
* @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation(
BearerAuthOperationRequest bearerAuthOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create());
HttpResponseHandler<Response<BearerAuthOperationResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(BearerAuthOperationResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler).credentialType(CredentialType.TOKEN)
.withMetricCollector(apiCallMetricCollector).withInput(bearerAuthOperationRequest));
CompletableFuture<BearerAuthOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperation operation asynchronously.
*
* @param eventStreamOperationRequest
* @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.EventStreamOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/EventStreamOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest,
EventStreamOperationResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation");
HttpResponseHandler<EventStreamOperationResponse> responseHandler = protocolFactory.createResponseHandler(
EventStreamOperationResponse::builder, XmlOperationMetadata.builder().hasStreamingSuccessResponse(true)
.build());
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
EventStreamTaggedUnionPojoSupplier.builder()
.putSdkPojoSupplier("EventPayloadEvent", EventStream::eventPayloadEventBuilder)
.putSdkPojoSupplier("NonEventPayloadEvent", EventStream::nonEventPayloadEventBuilder)
.putSdkPojoSupplier("SecondEventPayloadEvent", EventStream::secondEventPayloadEventBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build(), XmlOperationMetadata
.builder().hasStreamingSuccessResponse(false).build());
CompletableFuture<Void> eventStreamTransformFuture = new CompletableFuture<>();
EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer
.<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler)
.eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
.exceptionResponseHandler(errorResponseHandler).future(eventStreamTransformFuture).executor(executor)
.serviceName(serviceName()).build();
RestEventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer
.<EventStreamOperationResponse, EventStream> builder()
.eventStreamAsyncResponseTransformer(asyncResponseTransformer)
.eventStreamResponseHandler(asyncResponseHandler).build();
CompletableFuture<Void> executeFuture = clientHandler.execute(
new ClientExecutionParams<EventStreamOperationRequest, EventStreamOperationResponse>()
.withOperationName("EventStreamOperation").withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest),
restAsyncResponseTransformer);
CompletableFuture<Void> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(e));
eventStreamTransformFuture.completeExceptionally(e);
}
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return CompletableFutureUtils.forwardExceptionTo(eventStreamTransformFuture, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the GetOperationWithChecksum operation asynchronously.
*
* @param getOperationWithChecksumRequest
* @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
HttpResponseHandler<Response<GetOperationWithChecksumResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(GetOperationWithChecksumResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest));
CompletableFuture<GetOperationWithChecksumResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithChecksumRequired operation asynchronously.
*
* @param operationWithChecksumRequiredRequest
* @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
HttpResponseHandler<Response<OperationWithChecksumRequiredResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithChecksumRequiredResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest));
CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithNoneAuthType operation asynchronously.
*
* @param operationWithNoneAuthTypeRequest
* @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.OperationWithNoneAuthType
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithNoneAuthType"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType(
OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType");
HttpResponseHandler<Response<OperationWithNoneAuthTypeResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithNoneAuthTypeResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>()
.withOperationName("OperationWithNoneAuthType").withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.IS_NONE_AUTH_TYPE_REQUEST, false)
.withInput(operationWithNoneAuthTypeRequest));
CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithRequestCompression operation asynchronously.
*
* @param operationWithRequestCompressionRequest
* @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
HttpResponseHandler<Response<OperationWithRequestCompressionResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithRequestCompressionResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withInput(operationWithRequestCompressionRequest));
CompletableFuture<OperationWithRequestCompressionResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the PutOperationWithChecksum operation asynchronously.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum(
PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
if (!isSignerOverridden(clientConfiguration)) {
putOperationWithChecksumRequest = applySignerOverride(putOperationWithChecksumRequest, AsyncAws4Signer.create());
}
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
PutOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true));
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build())
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build()).withAsyncRequestBody(requestBody)
.withInput(putOperationWithChecksumRequest), asyncResponseTransformer);
CompletableFuture<ReturnT> whenCompleteFuture = null;
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
if (!isSignerOverridden(clientConfiguration)) {
streamingInputOperationRequest = applySignerOverride(streamingInputOperationRequest, AsyncAws4Signer.create());
}
HttpResponseHandler<Response<StreamingInputOperationResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(StreamingInputOperationResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build()).withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody)
.withInput(streamingInputOperationRequest));
CompletableFuture<StreamingInputOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest,
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
StreamingOutputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true));
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(streamingOutputOperationRequest), asyncResponseTransformer);
CompletableFuture<ReturnT> whenCompleteFuture = null;
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public final XmlServiceClientConfiguration serviceClientConfiguration() {
return new XmlServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private AwsXmlProtocolFactory init() {
return AwsXmlProtocolFactory
.builder()
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
.clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(XmlException::builder).build();
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private <T extends XmlRequest> T applySignerOverride(T request, Signer signer) {
if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) {
return request;
}
Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build();
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(signerOverride).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
private static boolean isSignerOverridden(SdkClientConfiguration clientConfiguration) {
return Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.SIGNER_OVERRIDDEN));
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
XmlServiceClientConfigurationBuilder serviceConfigBuilder = new XmlServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,542 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-client-class.java | package software.amazon.awssdk.services.xml;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.Response;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller;
import software.amazon.awssdk.core.signer.Signer;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.xml.AwsXmlProtocolFactory;
import software.amazon.awssdk.protocols.xml.XmlOperationMetadata;
import software.amazon.awssdk.services.xml.internal.XmlServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.xml.model.APostOperationRequest;
import software.amazon.awssdk.services.xml.model.APostOperationResponse;
import software.amazon.awssdk.services.xml.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.xml.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.xml.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.xml.model.InvalidInputException;
import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeRequest;
import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeResponse;
import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.xml.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.xml.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.xml.model.XmlException;
import software.amazon.awssdk.services.xml.model.XmlRequest;
import software.amazon.awssdk.services.xml.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithNoneAuthTypeRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link XmlClient}.
*
* @see XmlClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultXmlClient implements XmlClient {
private static final Logger log = Logger.loggerFor(DefaultXmlClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_XML).build();
private final SyncClientHandler clientHandler;
private final AwsXmlProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultXmlClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init();
}
/**
* <p>
* Performs a post operation to the xml service and has no output
* </p>
*
* @param aPostOperationRequest
* @return Result of the APostOperation operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException,
AwsServiceException, SdkClientException, XmlException {
HttpResponseHandler<Response<APostOperationResponse>> responseHandler = protocolFactory.createCombinedResponseHandler(
APostOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
String hostPrefix = "foo-";
String resolvedHostExpression = "foo-";
return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration)
.withInput(aPostOperationRequest).withMarshaller(new APostOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* <p>
* Performs a post operation to the xml service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return Result of the APostOperationWithOutput operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public APostOperationWithOutputResponse aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, XmlException {
HttpResponseHandler<Response<APostOperationWithOutputResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(APostOperationWithOutputResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
return clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the BearerAuthOperation operation.
*
* @param bearerAuthOperationRequest
* @return Result of the BearerAuthOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest)
throws AwsServiceException, SdkClientException, XmlException {
bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create());
HttpResponseHandler<Response<BearerAuthOperationResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(BearerAuthOperationResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration)
.withInput(bearerAuthOperationRequest)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the GetOperationWithChecksum operation.
*
* @param getOperationWithChecksumRequest
* @return Result of the GetOperationWithChecksum operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public GetOperationWithChecksumResponse getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException,
XmlException {
HttpResponseHandler<Response<GetOperationWithChecksumResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(GetOperationWithChecksumResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
return clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration)
.withInput(getOperationWithChecksumRequest)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build())
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithChecksumRequired operation.
*
* @param operationWithChecksumRequiredRequest
* @return Result of the OperationWithChecksumRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithChecksumRequiredResponse operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException,
SdkClientException, XmlException {
HttpResponseHandler<Response<OperationWithChecksumRequiredResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithChecksumRequiredResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
return clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithChecksumRequiredRequest)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create())
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithNoneAuthType operation.
*
* @param operationWithNoneAuthTypeRequest
* @return Result of the OperationWithNoneAuthType operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.OperationWithNoneAuthType
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithNoneAuthType"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithNoneAuthTypeResponse operationWithNoneAuthType(
OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) throws AwsServiceException, SdkClientException,
XmlException {
HttpResponseHandler<Response<OperationWithNoneAuthTypeResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithNoneAuthTypeResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType");
return clientHandler
.execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>()
.withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration).withInput(operationWithNoneAuthTypeRequest)
.putExecutionAttribute(SdkInternalExecutionAttribute.IS_NONE_AUTH_TYPE_REQUEST, false)
.withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithRequestCompression operation.
*
* @param operationWithRequestCompressionRequest
* @return Result of the OperationWithRequestCompression operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithRequestCompressionResponse operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException,
SdkClientException, XmlException {
HttpResponseHandler<Response<OperationWithRequestCompressionResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithRequestCompressionResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
return clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithRequestCompressionRequest)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the PutOperationWithChecksum operation.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest,
RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer)
throws AwsServiceException, SdkClientException, XmlException {
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
PutOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true));
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
return clientHandler
.execute(new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(putOperationWithChecksumRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build())
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest,
RequestBody requestBody) throws AwsServiceException, SdkClientException, XmlException {
HttpResponseHandler<Response<StreamingInputOperationResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(StreamingInputOperationResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
return clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration)
.withInput(streamingInputOperationRequest)
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest,
ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, XmlException {
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
StreamingOutputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true));
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
return clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer);
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
private <T extends XmlRequest> T applySignerOverride(T request, Signer signer) {
if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) {
return request;
}
Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build();
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(signerOverride).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
XmlServiceClientConfigurationBuilder serviceConfigBuilder = new XmlServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private AwsXmlProtocolFactory init() {
return AwsXmlProtocolFactory
.builder()
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
.clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(XmlException::builder).build();
}
@Override
public final XmlServiceClientConfiguration serviceClientConfiguration() {
return new XmlServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,543 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-async.java | package software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype;
import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.internal.ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.OneOperationRequest;
import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.OneOperationResponse;
import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.ProtocolRestJsonWithCustomContentTypeException;
import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.transform.OneOperationRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link ProtocolRestJsonWithCustomContentTypeAsyncClient}.
*
* @see ProtocolRestJsonWithCustomContentTypeAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultProtocolRestJsonWithCustomContentTypeAsyncClient implements ProtocolRestJsonWithCustomContentTypeAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultProtocolRestJsonWithCustomContentTypeAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultProtocolRestJsonWithCustomContentTypeAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
* Invokes the OneOperation operation asynchronously.
*
* @param oneOperationRequest
* @return A Java Future containing the result of the OneOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>ProtocolRestJsonWithCustomContentTypeException Base class for all service exceptions. Unknown
* exceptions will be thrown as an instance of this type.</li>
* </ul>
* @sample ProtocolRestJsonWithCustomContentTypeAsyncClient.OneOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/restjson-2016-03-11/OneOperation" target="_top">AWS API
* Documentation</a>
*/
@Override
public CompletableFuture<OneOperationResponse> oneOperation(OneOperationRequest oneOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(oneOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, oneOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AmazonProtocolRestJsonWithCustomContentType");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OneOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OneOperationResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata,
OneOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<OneOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OneOperationRequest, OneOperationResponse>()
.withOperationName("OneOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new OneOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(oneOperationRequest));
CompletableFuture<OneOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public final ProtocolRestJsonWithCustomContentTypeServiceClientConfiguration serviceClientConfiguration() {
return new ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder())
.build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(ProtocolRestJsonWithCustomContentTypeException::builder)
.protocol(AwsJsonProtocol.REST_JSON).protocolVersion("1.1").contentType("application/json");
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder serviceConfigBuilder = new ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,544 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-interface.java | package software.amazon.awssdk.services.json;
import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import org.reactivestreams.Publisher;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.annotations.ThreadSafe;
import software.amazon.awssdk.awscore.AwsClient;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.services.builder.Builder;
import software.amazon.awssdk.services.builder.CustomBuilder;
import software.amazon.awssdk.services.builder.DefaultBuilder;
import software.amazon.awssdk.services.builder.DefaultBuilderTwo;
import software.amazon.awssdk.services.json.model.APostOperationRequest;
import software.amazon.awssdk.services.json.model.APostOperationResponse;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse;
import software.amazon.awssdk.services.json.model.InputEventStream;
import software.amazon.awssdk.services.json.model.InputEventStreamTwo;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher;
import software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher;
/**
* Service client for accessing Json Service asynchronously. This can be created using the static {@link #builder()}
* method.
*
* A service that is implemented using the query protocol
*/
@Generated("software.amazon.awssdk:codegen")
@SdkPublicApi
@ThreadSafe
public interface JsonAsyncClient extends AwsClient {
String SERVICE_NAME = "json-service";
/**
* Value for looking up the service's metadata from the
* {@link software.amazon.awssdk.regions.ServiceMetadataProvider}.
*/
String SERVICE_METADATA_ID = "json-service-endpoint";
/**
* Creates an instance of {@link JsonUtilities} object with the configuration set on this client.
*/
default JsonUtilities utilities() {
throw new UnsupportedOperationException();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*
* @deprecated This API is deprecated, use something else
*/
@Deprecated
default CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
throw new UnsupportedOperationException();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
* <br/>
* <p>
* This is a convenience which creates an instance of the {@link APostOperationRequest.Builder} avoiding the need to
* create one manually via {@link APostOperationRequest#builder()}
* </p>
*
* @param aPostOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.APostOperationRequest.Builder} to create a request.
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*
* @deprecated This API is deprecated, use something else
*/
@Deprecated
default CompletableFuture<APostOperationResponse> aPostOperation(Consumer<APostOperationRequest.Builder> aPostOperationRequest) {
return aPostOperation(APostOperationRequest.builder().applyMutation(aPostOperationRequest).build());
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
throw new UnsupportedOperationException();
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
* <br/>
* <p>
* This is a convenience which creates an instance of the {@link APostOperationWithOutputRequest.Builder} avoiding
* the need to create one manually via {@link APostOperationWithOutputRequest#builder()}
* </p>
*
* @param aPostOperationWithOutputRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest.Builder} to create a
* request.
* @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(
Consumer<APostOperationWithOutputRequest.Builder> aPostOperationWithOutputRequest) {
return aPostOperationWithOutput(APostOperationWithOutputRequest.builder().applyMutation(aPostOperationWithOutputRequest)
.build());
}
/**
* Invokes the BearerAuthOperation operation asynchronously.
*
* @param bearerAuthOperationRequest
* @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation(
BearerAuthOperationRequest bearerAuthOperationRequest) {
throw new UnsupportedOperationException();
}
/**
* Invokes the BearerAuthOperation operation asynchronously.<br/>
* <p>
* This is a convenience which creates an instance of the {@link BearerAuthOperationRequest.Builder} avoiding the
* need to create one manually via {@link BearerAuthOperationRequest#builder()}
* </p>
*
* @param bearerAuthOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.BearerAuthOperationRequest.Builder} to create a request.
* @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation(
Consumer<BearerAuthOperationRequest.Builder> bearerAuthOperationRequest) {
return bearerAuthOperation(BearerAuthOperationRequest.builder().applyMutation(bearerAuthOperationRequest).build());
}
/**
* Invokes the EventStreamOperation operation asynchronously.
*
* @param eventStreamOperationRequest
* @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest,
Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) {
throw new UnsupportedOperationException();
}
/**
* Invokes the EventStreamOperation operation asynchronously.<br/>
* <p>
* This is a convenience which creates an instance of the {@link EventStreamOperationRequest.Builder} avoiding the
* need to create one manually via {@link EventStreamOperationRequest#builder()}
* </p>
*
* @param eventStreamOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.EventStreamOperationRequest.Builder} to create a
* request.
* @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<Void> eventStreamOperation(
Consumer<EventStreamOperationRequest.Builder> eventStreamOperationRequest, Publisher<InputEventStream> requestStream,
EventStreamOperationResponseHandler asyncResponseHandler) {
return eventStreamOperation(EventStreamOperationRequest.builder().applyMutation(eventStreamOperationRequest).build(),
requestStream, asyncResponseHandler);
}
/**
* Invokes the EventStreamOperationWithOnlyInput operation asynchronously.
*
* @param eventStreamOperationWithOnlyInputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyInput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput(
EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest,
Publisher<InputEventStreamTwo> requestStream) {
throw new UnsupportedOperationException();
}
/**
* Invokes the EventStreamOperationWithOnlyInput operation asynchronously.<br/>
* <p>
* This is a convenience which creates an instance of the {@link EventStreamOperationWithOnlyInputRequest.Builder}
* avoiding the need to create one manually via {@link EventStreamOperationWithOnlyInputRequest#builder()}
* </p>
*
* @param eventStreamOperationWithOnlyInputRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest.Builder} to
* create a request.
* @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyInput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput(
Consumer<EventStreamOperationWithOnlyInputRequest.Builder> eventStreamOperationWithOnlyInputRequest,
Publisher<InputEventStreamTwo> requestStream) {
return eventStreamOperationWithOnlyInput(
EventStreamOperationWithOnlyInputRequest.builder().applyMutation(eventStreamOperationWithOnlyInputRequest)
.build(), requestStream);
}
/**
* Invokes the EventStreamOperationWithOnlyOutput operation asynchronously.
*
* @param eventStreamOperationWithOnlyOutputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<Void> eventStreamOperationWithOnlyOutput(
EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest,
EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) {
throw new UnsupportedOperationException();
}
/**
* Invokes the EventStreamOperationWithOnlyOutput operation asynchronously.<br/>
* <p>
* This is a convenience which creates an instance of the {@link EventStreamOperationWithOnlyOutputRequest.Builder}
* avoiding the need to create one manually via {@link EventStreamOperationWithOnlyOutputRequest#builder()}
* </p>
*
* @param eventStreamOperationWithOnlyOutputRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest.Builder} to
* create a request.
* @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<Void> eventStreamOperationWithOnlyOutput(
Consumer<EventStreamOperationWithOnlyOutputRequest.Builder> eventStreamOperationWithOnlyOutputRequest,
EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) {
return eventStreamOperationWithOnlyOutput(
EventStreamOperationWithOnlyOutputRequest.builder().applyMutation(eventStreamOperationWithOnlyOutputRequest)
.build(), asyncResponseHandler);
}
/**
* Invokes the GetOperationWithChecksum operation asynchronously.
*
* @param getOperationWithChecksumRequest
* @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) {
throw new UnsupportedOperationException();
}
/**
* Invokes the GetOperationWithChecksum operation asynchronously.<br/>
* <p>
* This is a convenience which creates an instance of the {@link GetOperationWithChecksumRequest.Builder} avoiding
* the need to create one manually via {@link GetOperationWithChecksumRequest#builder()}
* </p>
*
* @param getOperationWithChecksumRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest.Builder} to create a
* request.
* @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum(
Consumer<GetOperationWithChecksumRequest.Builder> getOperationWithChecksumRequest) {
return getOperationWithChecksum(GetOperationWithChecksumRequest.builder().applyMutation(getOperationWithChecksumRequest)
.build());
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param getWithoutRequiredMembersRequest
* @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers(
GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) {
throw new UnsupportedOperationException();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
* <br/>
* <p>
* This is a convenience which creates an instance of the {@link GetWithoutRequiredMembersRequest.Builder} avoiding
* the need to create one manually via {@link GetWithoutRequiredMembersRequest#builder()}
* </p>
*
* @param getWithoutRequiredMembersRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest.Builder} to create a
* request.
* @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers(
Consumer<GetWithoutRequiredMembersRequest.Builder> getWithoutRequiredMembersRequest) {
return getWithoutRequiredMembers(GetWithoutRequiredMembersRequest.builder()
.applyMutation(getWithoutRequiredMembersRequest).build());
}
/**
* Invokes the OperationWithChecksumRequired operation asynchronously.
*
* @param operationWithChecksumRequiredRequest
* @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
throw new UnsupportedOperationException();
}
/**
* Invokes the OperationWithChecksumRequired operation asynchronously.<br/>
* <p>
* This is a convenience which creates an instance of the {@link OperationWithChecksumRequiredRequest.Builder}
* avoiding the need to create one manually via {@link OperationWithChecksumRequiredRequest#builder()}
* </p>
*
* @param operationWithChecksumRequiredRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest.Builder} to create
* a request.
* @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(
Consumer<OperationWithChecksumRequiredRequest.Builder> operationWithChecksumRequiredRequest) {
return operationWithChecksumRequired(OperationWithChecksumRequiredRequest.builder()
.applyMutation(operationWithChecksumRequiredRequest).build());
}
/**
* Invokes the OperationWithRequestCompression operation asynchronously.
*
* @param operationWithRequestCompressionRequest
* @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
throw new UnsupportedOperationException();
}
/**
* Invokes the OperationWithRequestCompression operation asynchronously.<br/>
* <p>
* This is a convenience which creates an instance of the {@link OperationWithRequestCompressionRequest.Builder}
* avoiding the need to create one manually via {@link OperationWithRequestCompressionRequest#builder()}
* </p>
*
* @param operationWithRequestCompressionRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest.Builder} to
* create a request.
* @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression(
Consumer<OperationWithRequestCompressionRequest.Builder> operationWithRequestCompressionRequest) {
return operationWithRequestCompression(OperationWithRequestCompressionRequest.builder()
.applyMutation(operationWithRequestCompressionRequest).build());
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @param paginatedOperationWithResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) {
throw new UnsupportedOperationException();
}
/**
* Some paginated operation with result_key in paginators.json file<br/>
* <p>
* This is a convenience which creates an instance of the {@link PaginatedOperationWithResultKeyRequest.Builder}
* avoiding the need to create one manually via {@link PaginatedOperationWithResultKeyRequest#builder()}
* </p>
*
* @param paginatedOperationWithResultKeyRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest.Builder} to
* create a request.
* @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey(
Consumer<PaginatedOperationWithResultKeyRequest.Builder> paginatedOperationWithResultKeyRequest) {
return paginatedOperationWithResultKey(PaginatedOperationWithResultKeyRequest.builder()
.applyMutation(paginatedOperationWithResultKeyRequest).build());
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey() {
return paginatedOperationWithResultKey(PaginatedOperationWithResultKeyRequest.builder().build());
}
/**
* Some paginated operation with result_key in paginators.json file<br/>
* <p>
* This is a variant of
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
* </p>
* <p>
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
* </p>
*
* <p>
* The following are few ways to use the response class:
* </p>
* 1) Using the subscribe helper method
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request);
* CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
* </pre>
*
* 2) Using a custom subscriber
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request);
* publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse>() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response) { //... };
* });}
* </pre>
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
* <p>
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.</b>
* </p>
* <p>
* <b>Note: If you prefer to have control on service calls, use the
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation.</b>
* </p>
*
* @return A custom publisher that can be subscribed to request a stream of response pages.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithResultKeyPublisher paginatedOperationWithResultKeyPaginator() {
return paginatedOperationWithResultKeyPaginator(PaginatedOperationWithResultKeyRequest.builder().build());
}
/**
* Some paginated operation with result_key in paginators.json file<br/>
* <p>
* This is a variant of
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
* </p>
* <p>
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
* </p>
*
* <p>
* The following are few ways to use the response class:
* </p>
* 1) Using the subscribe helper method
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request);
* CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
* </pre>
*
* 2) Using a custom subscriber
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request);
* publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse>() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response) { //... };
* });}
* </pre>
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
* <p>
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.</b>
* </p>
* <p>
* <b>Note: If you prefer to have control on service calls, use the
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation.</b>
* </p>
*
* @param paginatedOperationWithResultKeyRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithResultKeyPublisher paginatedOperationWithResultKeyPaginator(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) {
return new PaginatedOperationWithResultKeyPublisher(this, paginatedOperationWithResultKeyRequest);
}
/**
* Some paginated operation with result_key in paginators.json file<br/>
* <p>
* This is a variant of
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
* </p>
* <p>
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
* </p>
*
* <p>
* The following are few ways to use the response class:
* </p>
* 1) Using the subscribe helper method
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request);
* CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
* </pre>
*
* 2) Using a custom subscriber
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request);
* publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse>() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response) { //... };
* });}
* </pre>
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
* <p>
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.</b>
* </p>
* <p>
* <b>Note: If you prefer to have control on service calls, use the
* {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)}
* operation.</b>
* </p>
* <p>
* This is a convenience which creates an instance of the {@link PaginatedOperationWithResultKeyRequest.Builder}
* avoiding the need to create one manually via {@link PaginatedOperationWithResultKeyRequest#builder()}
* </p>
*
* @param paginatedOperationWithResultKeyRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest.Builder} to
* create a request.
* @return A custom publisher that can be subscribed to request a stream of response pages.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithResultKeyPublisher paginatedOperationWithResultKeyPaginator(
Consumer<PaginatedOperationWithResultKeyRequest.Builder> paginatedOperationWithResultKeyRequest) {
return paginatedOperationWithResultKeyPaginator(PaginatedOperationWithResultKeyRequest.builder()
.applyMutation(paginatedOperationWithResultKeyRequest).build());
}
/**
* Some paginated operation without result_key in paginators.json file
*
* @param paginatedOperationWithoutResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) {
throw new UnsupportedOperationException();
}
/**
* Some paginated operation without result_key in paginators.json file<br/>
* <p>
* This is a convenience which creates an instance of the {@link PaginatedOperationWithoutResultKeyRequest.Builder}
* avoiding the need to create one manually via {@link PaginatedOperationWithoutResultKeyRequest#builder()}
* </p>
*
* @param paginatedOperationWithoutResultKeyRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest.Builder} to
* create a request.
* @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey(
Consumer<PaginatedOperationWithoutResultKeyRequest.Builder> paginatedOperationWithoutResultKeyRequest) {
return paginatedOperationWithoutResultKey(PaginatedOperationWithoutResultKeyRequest.builder()
.applyMutation(paginatedOperationWithoutResultKeyRequest).build());
}
/**
* Some paginated operation without result_key in paginators.json file<br/>
* <p>
* This is a variant of
* {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
* </p>
* <p>
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
* </p>
*
* <p>
* The following are few ways to use the response class:
* </p>
* 1) Using the subscribe helper method
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher publisher = client.paginatedOperationWithoutResultKeyPaginator(request);
* CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
* </pre>
*
* 2) Using a custom subscriber
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher publisher = client.paginatedOperationWithoutResultKeyPaginator(request);
* publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse>() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse response) { //... };
* });}
* </pre>
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
* <p>
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.</b>
* </p>
* <p>
* <b>Note: If you prefer to have control on service calls, use the
* {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)}
* operation.</b>
* </p>
*
* @param paginatedOperationWithoutResultKeyRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithoutResultKeyPublisher paginatedOperationWithoutResultKeyPaginator(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) {
return new PaginatedOperationWithoutResultKeyPublisher(this, paginatedOperationWithoutResultKeyRequest);
}
/**
* Some paginated operation without result_key in paginators.json file<br/>
* <p>
* This is a variant of
* {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
* </p>
* <p>
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
* </p>
*
* <p>
* The following are few ways to use the response class:
* </p>
* 1) Using the subscribe helper method
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher publisher = client.paginatedOperationWithoutResultKeyPaginator(request);
* CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
* </pre>
*
* 2) Using a custom subscriber
*
* <pre>
* {@code
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher publisher = client.paginatedOperationWithoutResultKeyPaginator(request);
* publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse>() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse response) { //... };
* });}
* </pre>
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
* <p>
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.</b>
* </p>
* <p>
* <b>Note: If you prefer to have control on service calls, use the
* {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)}
* operation.</b>
* </p>
* <p>
* This is a convenience which creates an instance of the {@link PaginatedOperationWithoutResultKeyRequest.Builder}
* avoiding the need to create one manually via {@link PaginatedOperationWithoutResultKeyRequest#builder()}
* </p>
*
* @param paginatedOperationWithoutResultKeyRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest.Builder} to
* create a request.
* @return A custom publisher that can be subscribed to request a stream of response pages.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
default PaginatedOperationWithoutResultKeyPublisher paginatedOperationWithoutResultKeyPaginator(
Consumer<PaginatedOperationWithoutResultKeyRequest.Builder> paginatedOperationWithoutResultKeyRequest) {
return paginatedOperationWithoutResultKeyPaginator(PaginatedOperationWithoutResultKeyRequest.builder()
.applyMutation(paginatedOperationWithoutResultKeyRequest).build());
}
/**
* Invokes the PutOperationWithChecksum operation asynchronously.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum(
PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) {
throw new UnsupportedOperationException();
}
/**
* Invokes the PutOperationWithChecksum operation asynchronously.<br/>
* <p>
* This is a convenience which creates an instance of the {@link PutOperationWithChecksumRequest.Builder} avoiding
* the need to create one manually via {@link PutOperationWithChecksumRequest#builder()}
* </p>
*
* @param putOperationWithChecksumRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest.Builder} to create a
* request.
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum(
Consumer<PutOperationWithChecksumRequest.Builder> putOperationWithChecksumRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) {
return putOperationWithChecksum(PutOperationWithChecksumRequest.builder().applyMutation(putOperationWithChecksumRequest)
.build(), requestBody, asyncResponseTransformer);
}
/**
* Invokes the PutOperationWithChecksum operation asynchronously.
*
* @param putOperationWithChecksumRequest
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows '
* <p>
* Object data.
* </p>
* '
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<PutOperationWithChecksumResponse> putOperationWithChecksum(
PutOperationWithChecksumRequest putOperationWithChecksumRequest, Path sourcePath, Path destinationPath) {
return putOperationWithChecksum(putOperationWithChecksumRequest, AsyncRequestBody.fromFile(sourcePath),
AsyncResponseTransformer.toFile(destinationPath));
}
/**
* Invokes the PutOperationWithChecksum operation asynchronously.<br/>
* <p>
* This is a convenience which creates an instance of the {@link PutOperationWithChecksumRequest.Builder} avoiding
* the need to create one manually via {@link PutOperationWithChecksumRequest#builder()}
* </p>
*
* @param putOperationWithChecksumRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest.Builder} to create a
* request.
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows '
* <p>
* Object data.
* </p>
* '
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<PutOperationWithChecksumResponse> putOperationWithChecksum(
Consumer<PutOperationWithChecksumRequest.Builder> putOperationWithChecksumRequest, Path sourcePath,
Path destinationPath) {
return putOperationWithChecksum(PutOperationWithChecksumRequest.builder().applyMutation(putOperationWithChecksumRequest)
.build(), sourcePath, destinationPath);
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
throw new UnsupportedOperationException();
}
/**
* Some operation with a streaming input<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingInputOperationRequest.Builder} avoiding
* the need to create one manually via {@link StreamingInputOperationRequest#builder()}
* </p>
*
* @param streamingInputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingInputOperationRequest.Builder} to create a
* request.
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
Consumer<StreamingInputOperationRequest.Builder> streamingInputOperationRequest, AsyncRequestBody requestBody) {
return streamingInputOperation(StreamingInputOperationRequest.builder().applyMutation(streamingInputOperationRequest)
.build(), requestBody);
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, Path sourcePath) {
return streamingInputOperation(streamingInputOperationRequest, AsyncRequestBody.fromFile(sourcePath));
}
/**
* Some operation with a streaming input<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingInputOperationRequest.Builder} avoiding
* the need to create one manually via {@link StreamingInputOperationRequest#builder()}
* </p>
*
* @param streamingInputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingInputOperationRequest.Builder} to create a
* request.
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
Consumer<StreamingInputOperationRequest.Builder> streamingInputOperationRequest, Path sourcePath) {
return streamingInputOperation(StreamingInputOperationRequest.builder().applyMutation(streamingInputOperationRequest)
.build(), sourcePath);
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) {
throw new UnsupportedOperationException();
}
/**
* Some operation with streaming input and streaming output<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingInputOutputOperationRequest.Builder}
* avoiding the need to create one manually via {@link StreamingInputOutputOperationRequest#builder()}
* </p>
*
* @param streamingInputOutputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest.Builder} to create
* a request.
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation(
Consumer<StreamingInputOutputOperationRequest.Builder> streamingInputOutputOperationRequest,
AsyncRequestBody requestBody,
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) {
return streamingInputOutputOperation(
StreamingInputOutputOperationRequest.builder().applyMutation(streamingInputOutputOperationRequest).build(),
requestBody, asyncResponseTransformer);
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows 'This be a stream'
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<StreamingInputOutputOperationResponse> streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, Path sourcePath, Path destinationPath) {
return streamingInputOutputOperation(streamingInputOutputOperationRequest, AsyncRequestBody.fromFile(sourcePath),
AsyncResponseTransformer.toFile(destinationPath));
}
/**
* Some operation with streaming input and streaming output<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingInputOutputOperationRequest.Builder}
* avoiding the need to create one manually via {@link StreamingInputOutputOperationRequest#builder()}
* </p>
*
* @param streamingInputOutputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest.Builder} to create
* a request.
* @param sourcePath
* {@link Path} to file containing data to send to the service. File will be read entirely and may be read
* multiple times in the event of a retry. If the file does not exist or the current user does not have
* access to read it then an exception will be thrown. The service documentation for the request content is
* as follows 'This be a stream'
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<StreamingInputOutputOperationResponse> streamingInputOutputOperation(
Consumer<StreamingInputOutputOperationRequest.Builder> streamingInputOutputOperationRequest, Path sourcePath,
Path destinationPath) {
return streamingInputOutputOperation(
StreamingInputOutputOperationRequest.builder().applyMutation(streamingInputOutputOperationRequest).build(),
sourcePath, destinationPath);
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest,
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) {
throw new UnsupportedOperationException();
}
/**
* Some operation with a streaming output<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding
* the need to create one manually via {@link StreamingOutputOperationRequest#builder()}
* </p>
*
* @param streamingOutputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a
* request.
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest,
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) {
return streamingOutputOperation(StreamingOutputOperationRequest.builder().applyMutation(streamingOutputOperationRequest)
.build(), asyncResponseTransformer);
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<StreamingOutputOperationResponse> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest, Path destinationPath) {
return streamingOutputOperation(streamingOutputOperationRequest, AsyncResponseTransformer.toFile(destinationPath));
}
/**
* Some operation with a streaming output<br/>
* <p>
* This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding
* the need to create one manually via {@link StreamingOutputOperationRequest#builder()}
* </p>
*
* @param streamingOutputOperationRequest
* A {@link Consumer} that will call methods on
* {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a
* request.
* @param destinationPath
* {@link Path} to file that response contents will be written to. The file must not exist or this method
* will throw an exception. If the file is not writable by the current user then an exception will be thrown.
* The service documentation for the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
default CompletableFuture<StreamingOutputOperationResponse> streamingOutputOperation(
Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest, Path destinationPath) {
return streamingOutputOperation(StreamingOutputOperationRequest.builder().applyMutation(streamingOutputOperationRequest)
.build(), destinationPath);
}
@Override
default JsonServiceClientConfiguration serviceClientConfiguration() {
throw new UnsupportedOperationException();
}
/**
* Create a {@link JsonAsyncClient} with the region loaded from the
* {@link software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain} and credentials loaded from the
* {@link software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider}.
*/
static JsonAsyncClient create() {
return builder().build();
}
/**
* Create a builder that can be used to configure and create a {@link JsonAsyncClient}.
*/
static JsonAsyncClientBuilder builder() {
return new DefaultJsonAsyncClientBuilder();
}
/**
* Create a default builder
*/
static CustomBuilder builderOne() {
return DefaultBuilder.builder().build();
}
/**
* Create a default builder two
*/
static Builder builderTwo() {
return DefaultBuilderTwo.builder2().build();
}
}
| 3,545 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java | package software.amazon.awssdk.services.endpointdiscoverytest;
import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.endpointdiscovery.EndpointDiscoveryRefreshCache;
import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRequest;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.endpointdiscoverytest.internal.EndpointDiscoveryTestServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.endpointdiscoverytest.model.DescribeEndpointsRequest;
import software.amazon.awssdk.services.endpointdiscoverytest.model.DescribeEndpointsResponse;
import software.amazon.awssdk.services.endpointdiscoverytest.model.EndpointDiscoveryTestException;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryIdentifiersRequiredRequest;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryIdentifiersRequiredResponse;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryOptionalRequest;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryOptionalResponse;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryRequiredRequest;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryRequiredResponse;
import software.amazon.awssdk.services.endpointdiscoverytest.transform.DescribeEndpointsRequestMarshaller;
import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryIdentifiersRequiredRequestMarshaller;
import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryOptionalRequestMarshaller;
import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryRequiredRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link EndpointDiscoveryTestAsyncClient}.
*
* @see EndpointDiscoveryTestAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultEndpointDiscoveryTestAsyncClient implements EndpointDiscoveryTestAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultEndpointDiscoveryTestAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.AWS_JSON).build();
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private EndpointDiscoveryRefreshCache endpointDiscoveryCache;
protected DefaultEndpointDiscoveryTestAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)) {
this.endpointDiscoveryCache = EndpointDiscoveryRefreshCache
.create(EndpointDiscoveryTestAsyncEndpointDiscoveryCacheLoader.create(this));
}
}
/**
* Invokes the DescribeEndpoints operation asynchronously.
*
* @param describeEndpointsRequest
* @return A Java Future containing the result of the DescribeEndpoints operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>EndpointDiscoveryTestException Base class for all service exceptions. Unknown exceptions will be
* thrown as an instance of this type.</li>
* </ul>
* @sample EndpointDiscoveryTestAsyncClient.DescribeEndpoints
*/
@Override
public CompletableFuture<DescribeEndpointsResponse> describeEndpoints(DescribeEndpointsRequest describeEndpointsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeEndpointsRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, describeEndpointsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeEndpoints");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<DescribeEndpointsResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeEndpointsResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<DescribeEndpointsResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<DescribeEndpointsRequest, DescribeEndpointsResponse>()
.withOperationName("DescribeEndpoints").withProtocolMetadata(protocolMetadata)
.withMarshaller(new DescribeEndpointsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(describeEndpointsRequest));
CompletableFuture<DescribeEndpointsResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the TestDiscoveryIdentifiersRequired operation asynchronously.
*
* @param testDiscoveryIdentifiersRequiredRequest
* @return A Java Future containing the result of the TestDiscoveryIdentifiersRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>EndpointDiscoveryTestException Base class for all service exceptions. Unknown exceptions will be
* thrown as an instance of this type.</li>
* </ul>
* @sample EndpointDiscoveryTestAsyncClient.TestDiscoveryIdentifiersRequired
*/
@Override
public CompletableFuture<TestDiscoveryIdentifiersRequiredResponse> testDiscoveryIdentifiersRequired(
TestDiscoveryIdentifiersRequiredRequest testDiscoveryIdentifiersRequiredRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryIdentifiersRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
testDiscoveryIdentifiersRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryIdentifiersRequired");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<TestDiscoveryIdentifiersRequiredResponse> responseHandler = protocolFactory
.createResponseHandler(operationMetadata, TestDiscoveryIdentifiersRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
throw new IllegalStateException(
"This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported.");
}
if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery, but endpoint discovery was disabled on the client.");
}
CompletableFuture<URI> endpointFuture = CompletableFuture.completedFuture(null);
if (endpointDiscoveryEnabled) {
CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryIdentifiersRequiredRequest
.overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER))
.resolveIdentity();
endpointFuture = identityFuture.thenApply(credentials -> {
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(testDiscoveryIdentifiersRequiredRequest.overrideConfiguration().orElse(null))
.build();
return endpointDiscoveryCache.get(credentials.accessKeyId(), endpointDiscoveryRequest);
});
}
CompletableFuture<TestDiscoveryIdentifiersRequiredResponse> executeFuture = endpointFuture
.thenCompose(cachedEndpoint -> clientHandler
.execute(new ClientExecutionParams<TestDiscoveryIdentifiersRequiredRequest, TestDiscoveryIdentifiersRequiredResponse>()
.withOperationName("TestDiscoveryIdentifiersRequired").withProtocolMetadata(protocolMetadata)
.withMarshaller(new TestDiscoveryIdentifiersRequiredRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.discoveredEndpoint(cachedEndpoint).withInput(testDiscoveryIdentifiersRequiredRequest)));
CompletableFuture<TestDiscoveryIdentifiersRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the TestDiscoveryOptional operation asynchronously.
*
* @param testDiscoveryOptionalRequest
* @return A Java Future containing the result of the TestDiscoveryOptional operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>EndpointDiscoveryTestException Base class for all service exceptions. Unknown exceptions will be
* thrown as an instance of this type.</li>
* </ul>
* @sample EndpointDiscoveryTestAsyncClient.TestDiscoveryOptional
*/
@Override
public CompletableFuture<TestDiscoveryOptionalResponse> testDiscoveryOptional(
TestDiscoveryOptionalRequest testDiscoveryOptionalRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryOptionalRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, testDiscoveryOptionalRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryOptional");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<TestDiscoveryOptionalResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, TestDiscoveryOptionalResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
CompletableFuture<URI> endpointFuture = CompletableFuture.completedFuture(null);
if (endpointDiscoveryEnabled) {
CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryOptionalRequest
.overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER))
.resolveIdentity();
endpointFuture = identityFuture.thenApply(credentials -> {
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(false)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(testDiscoveryOptionalRequest.overrideConfiguration().orElse(null)).build();
return endpointDiscoveryCache.get(credentials.accessKeyId(), endpointDiscoveryRequest);
});
}
CompletableFuture<TestDiscoveryOptionalResponse> executeFuture = endpointFuture
.thenCompose(cachedEndpoint -> clientHandler
.execute(new ClientExecutionParams<TestDiscoveryOptionalRequest, TestDiscoveryOptionalResponse>()
.withOperationName("TestDiscoveryOptional").withProtocolMetadata(protocolMetadata)
.withMarshaller(new TestDiscoveryOptionalRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.discoveredEndpoint(cachedEndpoint).withInput(testDiscoveryOptionalRequest)));
CompletableFuture<TestDiscoveryOptionalResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the TestDiscoveryRequired operation asynchronously.
*
* @param testDiscoveryRequiredRequest
* @return A Java Future containing the result of the TestDiscoveryRequired operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>EndpointDiscoveryTestException Base class for all service exceptions. Unknown exceptions will be
* thrown as an instance of this type.</li>
* </ul>
* @sample EndpointDiscoveryTestAsyncClient.TestDiscoveryRequired
*/
@Override
public CompletableFuture<TestDiscoveryRequiredResponse> testDiscoveryRequired(
TestDiscoveryRequiredRequest testDiscoveryRequiredRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, testDiscoveryRequiredRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryRequired");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<TestDiscoveryRequiredResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, TestDiscoveryRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
throw new IllegalStateException(
"This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported.");
}
if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery, but endpoint discovery was disabled on the client.");
}
CompletableFuture<URI> endpointFuture = CompletableFuture.completedFuture(null);
if (endpointDiscoveryEnabled) {
CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryRequiredRequest
.overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER))
.resolveIdentity();
endpointFuture = identityFuture.thenApply(credentials -> {
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(testDiscoveryRequiredRequest.overrideConfiguration().orElse(null)).build();
return endpointDiscoveryCache.get(credentials.accessKeyId(), endpointDiscoveryRequest);
});
}
CompletableFuture<TestDiscoveryRequiredResponse> executeFuture = endpointFuture
.thenCompose(cachedEndpoint -> clientHandler
.execute(new ClientExecutionParams<TestDiscoveryRequiredRequest, TestDiscoveryRequiredResponse>()
.withOperationName("TestDiscoveryRequired").withProtocolMetadata(protocolMetadata)
.withMarshaller(new TestDiscoveryRequiredRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.discoveredEndpoint(cachedEndpoint).withInput(testDiscoveryRequiredRequest)));
CompletableFuture<TestDiscoveryRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public final EndpointDiscoveryTestServiceClientConfiguration serviceClientConfiguration() {
return new EndpointDiscoveryTestServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(EndpointDiscoveryTestException::builder).protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.1");
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
EndpointDiscoveryTestServiceClientConfigurationBuilder serviceConfigBuilder = new EndpointDiscoveryTestServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,546 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java | package software.amazon.awssdk.services.endpointdiscoverytest;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.endpointdiscovery.EndpointDiscoveryRefreshCache;
import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRequest;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.endpointdiscoverytest.internal.EndpointDiscoveryTestServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.endpointdiscoverytest.model.DescribeEndpointsRequest;
import software.amazon.awssdk.services.endpointdiscoverytest.model.DescribeEndpointsResponse;
import software.amazon.awssdk.services.endpointdiscoverytest.model.EndpointDiscoveryTestException;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryIdentifiersRequiredRequest;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryIdentifiersRequiredResponse;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryOptionalRequest;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryOptionalResponse;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryRequiredRequest;
import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryRequiredResponse;
import software.amazon.awssdk.services.endpointdiscoverytest.transform.DescribeEndpointsRequestMarshaller;
import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryIdentifiersRequiredRequestMarshaller;
import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryOptionalRequestMarshaller;
import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryRequiredRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link EndpointDiscoveryTestClient}.
*
* @see EndpointDiscoveryTestClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultEndpointDiscoveryTestClient implements EndpointDiscoveryTestClient {
private static final Logger log = Logger.loggerFor(DefaultEndpointDiscoveryTestClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.AWS_JSON).build();
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private EndpointDiscoveryRefreshCache endpointDiscoveryCache;
protected DefaultEndpointDiscoveryTestClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)) {
this.endpointDiscoveryCache = EndpointDiscoveryRefreshCache.create(EndpointDiscoveryTestEndpointDiscoveryCacheLoader
.create(this));
}
}
/**
* Invokes the DescribeEndpoints operation.
*
* @param describeEndpointsRequest
* @return Result of the DescribeEndpoints operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EndpointDiscoveryTestException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EndpointDiscoveryTestClient.DescribeEndpoints
*/
@Override
public DescribeEndpointsResponse describeEndpoints(DescribeEndpointsRequest describeEndpointsRequest)
throws AwsServiceException, SdkClientException, EndpointDiscoveryTestException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<DescribeEndpointsResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DescribeEndpointsResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeEndpointsRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, describeEndpointsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeEndpoints");
return clientHandler.execute(new ClientExecutionParams<DescribeEndpointsRequest, DescribeEndpointsResponse>()
.withOperationName("DescribeEndpoints").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(describeEndpointsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeEndpointsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the TestDiscoveryIdentifiersRequired operation.
*
* @param testDiscoveryIdentifiersRequiredRequest
* @return Result of the TestDiscoveryIdentifiersRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EndpointDiscoveryTestException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EndpointDiscoveryTestClient.TestDiscoveryIdentifiersRequired
*/
@Override
public TestDiscoveryIdentifiersRequiredResponse testDiscoveryIdentifiersRequired(
TestDiscoveryIdentifiersRequiredRequest testDiscoveryIdentifiersRequiredRequest) throws AwsServiceException,
SdkClientException, EndpointDiscoveryTestException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<TestDiscoveryIdentifiersRequiredResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, TestDiscoveryIdentifiersRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
throw new IllegalStateException(
"This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported.");
}
if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery, but endpoint discovery was disabled on the client.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryIdentifiersRequiredRequest
.overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER)).resolveIdentity();
String key = CompletableFutureUtils.joinLikeSync(identityFuture).accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(testDiscoveryIdentifiersRequiredRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryIdentifiersRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
testDiscoveryIdentifiersRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryIdentifiersRequired");
return clientHandler
.execute(new ClientExecutionParams<TestDiscoveryIdentifiersRequiredRequest, TestDiscoveryIdentifiersRequiredResponse>()
.withOperationName("TestDiscoveryIdentifiersRequired").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.discoveredEndpoint(cachedEndpoint).withRequestConfiguration(clientConfiguration)
.withInput(testDiscoveryIdentifiersRequiredRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new TestDiscoveryIdentifiersRequiredRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the TestDiscoveryOptional operation.
*
* @param testDiscoveryOptionalRequest
* @return Result of the TestDiscoveryOptional operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EndpointDiscoveryTestException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EndpointDiscoveryTestClient.TestDiscoveryOptional
*/
@Override
public TestDiscoveryOptionalResponse testDiscoveryOptional(TestDiscoveryOptionalRequest testDiscoveryOptionalRequest)
throws AwsServiceException, SdkClientException, EndpointDiscoveryTestException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<TestDiscoveryOptionalResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, TestDiscoveryOptionalResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryOptionalRequest
.overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER)).resolveIdentity();
String key = CompletableFutureUtils.joinLikeSync(identityFuture).accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(false)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(testDiscoveryOptionalRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryOptionalRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, testDiscoveryOptionalRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryOptional");
return clientHandler.execute(new ClientExecutionParams<TestDiscoveryOptionalRequest, TestDiscoveryOptionalResponse>()
.withOperationName("TestDiscoveryOptional").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.discoveredEndpoint(cachedEndpoint).withRequestConfiguration(clientConfiguration)
.withInput(testDiscoveryOptionalRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new TestDiscoveryOptionalRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the TestDiscoveryRequired operation.
*
* @param testDiscoveryRequiredRequest
* @return Result of the TestDiscoveryRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EndpointDiscoveryTestException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EndpointDiscoveryTestClient.TestDiscoveryRequired
*/
@Override
public TestDiscoveryRequiredResponse testDiscoveryRequired(TestDiscoveryRequiredRequest testDiscoveryRequiredRequest)
throws AwsServiceException, SdkClientException, EndpointDiscoveryTestException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<TestDiscoveryRequiredResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, TestDiscoveryRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
throw new IllegalStateException(
"This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported.");
}
if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery, but endpoint discovery was disabled on the client.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryRequiredRequest
.overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER)).resolveIdentity();
String key = CompletableFutureUtils.joinLikeSync(identityFuture).accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(testDiscoveryRequiredRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, testDiscoveryRequiredRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryRequired");
return clientHandler.execute(new ClientExecutionParams<TestDiscoveryRequiredRequest, TestDiscoveryRequiredResponse>()
.withOperationName("TestDiscoveryRequired").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.discoveredEndpoint(cachedEndpoint).withRequestConfiguration(clientConfiguration)
.withInput(testDiscoveryRequiredRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new TestDiscoveryRequiredRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
EndpointDiscoveryTestServiceClientConfigurationBuilder serviceConfigBuilder = new EndpointDiscoveryTestServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(EndpointDiscoveryTestException::builder).protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.1");
}
@Override
public final EndpointDiscoveryTestServiceClientConfiguration serviceClientConfiguration() {
return new EndpointDiscoveryTestServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,547 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-async-client-class.java | package software.amazon.awssdk.services.query;
import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.signer.AsyncAws4Signer;
import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller;
import software.amazon.awssdk.core.signer.Signer;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.query.AwsQueryProtocolFactory;
import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.query.model.APostOperationRequest;
import software.amazon.awssdk.services.query.model.APostOperationResponse;
import software.amazon.awssdk.services.query.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.query.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.query.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.query.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.query.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.query.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.query.model.InvalidInputException;
import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.query.model.OperationWithContextParamRequest;
import software.amazon.awssdk.services.query.model.OperationWithContextParamResponse;
import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeRequest;
import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeResponse;
import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsRequest;
import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsResponse;
import software.amazon.awssdk.services.query.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.query.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.query.model.QueryException;
import software.amazon.awssdk.services.query.model.QueryRequest;
import software.amazon.awssdk.services.query.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.query.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.query.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.query.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.query.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.query.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithContextParamRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithNoneAuthTypeRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithStaticContextParamsRequestMarshaller;
import software.amazon.awssdk.services.query.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.query.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.services.query.waiters.QueryAsyncWaiter;
import software.amazon.awssdk.utils.CompletableFutureUtils;
import software.amazon.awssdk.utils.Pair;
/**
* Internal implementation of {@link QueryAsyncClient}.
*
* @see QueryAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultQueryAsyncClient implements QueryAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultQueryAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.QUERY).build();
private final AsyncClientHandler clientHandler;
private final AwsQueryProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private final ScheduledExecutorService executorService;
protected DefaultQueryAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init();
this.executorService = clientConfiguration.option(SdkClientOption.SCHEDULED_EXECUTOR_SERVICE);
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory
.createResponseHandler(APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
String hostPrefix = "foo-";
String resolvedHostExpression = "foo-";
CompletableFuture<APostOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
CompletableFuture<APostOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory
.createResponseHandler(APostOperationWithOutputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(aPostOperationWithOutputRequest));
CompletableFuture<APostOperationWithOutputResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the BearerAuthOperation operation asynchronously.
*
* @param bearerAuthOperationRequest
* @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation(
BearerAuthOperationRequest bearerAuthOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create());
HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory
.createResponseHandler(BearerAuthOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withInput(bearerAuthOperationRequest));
CompletableFuture<BearerAuthOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the GetOperationWithChecksum operation asynchronously.
*
* @param getOperationWithChecksumRequest
* @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory
.createResponseHandler(GetOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest));
CompletableFuture<GetOperationWithChecksumResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithChecksumRequired operation asynchronously.
*
* @param operationWithChecksumRequiredRequest
* @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithChecksumRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest));
CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithContextParam operation asynchronously.
*
* @param operationWithContextParamRequest
* @return A Java Future containing the result of the OperationWithContextParam operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.OperationWithContextParam
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithContextParam"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithContextParamResponse> operationWithContextParam(
OperationWithContextParamRequest operationWithContextParamRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithContextParamRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithContextParamRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithContextParam");
HttpResponseHandler<OperationWithContextParamResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithContextParamResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<OperationWithContextParamResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithContextParamRequest, OperationWithContextParamResponse>()
.withOperationName("OperationWithContextParam").withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithContextParamRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(operationWithContextParamRequest));
CompletableFuture<OperationWithContextParamResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithNoneAuthType operation asynchronously.
*
* @param operationWithNoneAuthTypeRequest
* @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.OperationWithNoneAuthType
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithNoneAuthType"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType(
OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType");
HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithNoneAuthTypeResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>()
.withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.IS_NONE_AUTH_TYPE_REQUEST, false)
.withInput(operationWithNoneAuthTypeRequest));
CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithRequestCompression operation asynchronously.
*
* @param operationWithRequestCompressionRequest
* @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithRequestCompressionResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withInput(operationWithRequestCompressionRequest));
CompletableFuture<OperationWithRequestCompressionResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithStaticContextParams operation asynchronously.
*
* @param operationWithStaticContextParamsRequest
* @return A Java Future containing the result of the OperationWithStaticContextParams operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.OperationWithStaticContextParams
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithStaticContextParams"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithStaticContextParamsResponse> operationWithStaticContextParams(
OperationWithStaticContextParamsRequest operationWithStaticContextParamsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithStaticContextParamsRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithStaticContextParamsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithStaticContextParams");
HttpResponseHandler<OperationWithStaticContextParamsResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithStaticContextParamsResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<OperationWithStaticContextParamsResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithStaticContextParamsRequest, OperationWithStaticContextParamsResponse>()
.withOperationName("OperationWithStaticContextParams").withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithStaticContextParamsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(operationWithStaticContextParamsRequest));
CompletableFuture<OperationWithStaticContextParamsResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the PutOperationWithChecksum operation asynchronously.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum(
PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
if (!isSignerOverridden(clientConfiguration)) {
putOperationWithChecksumRequest = applySignerOverride(putOperationWithChecksumRequest, AsyncAws4Signer.create());
}
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory
.createResponseHandler(PutOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build())
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build()).withAsyncRequestBody(requestBody)
.withInput(putOperationWithChecksumRequest), asyncResponseTransformer);
CompletableFuture<ReturnT> whenCompleteFuture = null;
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
if (!isSignerOverridden(clientConfiguration)) {
streamingInputOperationRequest = applySignerOverride(streamingInputOperationRequest, AsyncAws4Signer.create());
}
HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory
.createResponseHandler(StreamingInputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody)
.withInput(streamingInputOperationRequest));
CompletableFuture<StreamingInputOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest,
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory
.createResponseHandler(StreamingOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(streamingOutputOperationRequest), asyncResponseTransformer);
CompletableFuture<ReturnT> whenCompleteFuture = null;
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public QueryAsyncWaiter waiter() {
return QueryAsyncWaiter.builder().client(this).scheduledExecutorService(executorService).build();
}
@Override
public final QueryServiceClientConfiguration serviceClientConfiguration() {
return new QueryServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private AwsQueryProtocolFactory init() {
return AwsQueryProtocolFactory
.builder()
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
.clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(QueryException::builder).build();
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private <T extends QueryRequest> T applySignerOverride(T request, Signer signer) {
if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) {
return request;
}
Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build();
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(signerOverride).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
private static boolean isSignerOverridden(SdkClientConfiguration clientConfiguration) {
return Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.SIGNER_OVERRIDDEN));
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,548 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-abstract-sync-client-class.java | package software.amazon.awssdk.services.json;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.SdkClient;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.services.json.model.APostOperationRequest;
import software.amazon.awssdk.services.json.model.APostOperationResponse;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse;
import software.amazon.awssdk.services.json.model.InvalidInputException;
import software.amazon.awssdk.services.json.model.JsonException;
import software.amazon.awssdk.services.json.model.JsonRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.utils.Validate;
@Generated("software.amazon.awssdk:codegen")
@SdkPublicApi
public abstract class DelegatingJsonClient implements JsonClient {
private final JsonClient delegate;
public DelegatingJsonClient(JsonClient delegate) {
Validate.paramNotNull(delegate, "delegate");
this.delegate = delegate;
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return Result of the APostOperation operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException,
AwsServiceException, SdkClientException, JsonException {
return invokeOperation(aPostOperationRequest, request -> delegate.aPostOperation(request));
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return Result of the APostOperationWithOutput operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public APostOperationWithOutputResponse aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, JsonException {
return invokeOperation(aPostOperationWithOutputRequest, request -> delegate.aPostOperationWithOutput(request));
}
/**
* Invokes the BearerAuthOperation operation.
*
* @param bearerAuthOperationRequest
* @return Result of the BearerAuthOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest)
throws AwsServiceException, SdkClientException, JsonException {
return invokeOperation(bearerAuthOperationRequest, request -> delegate.bearerAuthOperation(request));
}
/**
* Invokes the GetOperationWithChecksum operation.
*
* @param getOperationWithChecksumRequest
* @return Result of the GetOperationWithChecksum operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public GetOperationWithChecksumResponse getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException,
JsonException {
return invokeOperation(getOperationWithChecksumRequest, request -> delegate.getOperationWithChecksum(request));
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param getWithoutRequiredMembersRequest
* @return Result of the GetWithoutRequiredMembers operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
@Override
public GetWithoutRequiredMembersResponse getWithoutRequiredMembers(
GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, JsonException {
return invokeOperation(getWithoutRequiredMembersRequest, request -> delegate.getWithoutRequiredMembers(request));
}
/**
* Invokes the OperationWithChecksumRequired operation.
*
* @param operationWithChecksumRequiredRequest
* @return Result of the OperationWithChecksumRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithChecksumRequiredResponse operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException,
SdkClientException, JsonException {
return invokeOperation(operationWithChecksumRequiredRequest, request -> delegate.operationWithChecksumRequired(request));
}
/**
* Invokes the OperationWithRequestCompression operation.
*
* @param operationWithRequestCompressionRequest
* @return Result of the OperationWithRequestCompression operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithRequestCompressionResponse operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException,
SdkClientException, JsonException {
return invokeOperation(operationWithRequestCompressionRequest,
request -> delegate.operationWithRequestCompression(request));
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @param paginatedOperationWithResultKeyRequest
* @return Result of the PaginatedOperationWithResultKey operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) throws AwsServiceException,
SdkClientException, JsonException {
return invokeOperation(paginatedOperationWithResultKeyRequest,
request -> delegate.paginatedOperationWithResultKey(request));
}
/**
* Some paginated operation without result_key in paginators.json file
*
* @param paginatedOperationWithoutResultKeyRequest
* @return Result of the PaginatedOperationWithoutResultKey operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResultKey(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) throws AwsServiceException,
SdkClientException, JsonException {
return invokeOperation(paginatedOperationWithoutResultKeyRequest,
request -> delegate.paginatedOperationWithoutResultKey(request));
}
/**
* Invokes the PutOperationWithChecksum operation.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest,
RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer)
throws AwsServiceException, SdkClientException, JsonException {
return invokeOperation(putOperationWithChecksumRequest,
request -> delegate.putOperationWithChecksum(request, requestBody, responseTransformer));
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest,
RequestBody requestBody) throws AwsServiceException, SdkClientException, JsonException {
return invokeOperation(streamingInputOperationRequest, request -> delegate.streamingInputOperation(request, requestBody));
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingInputOutputOperationResponse and an InputStream to the response content are provided as
* parameters to the callback. The callback may return a transformed type which will be the return value of
* this method. See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing
* this interface and for links to pre-canned implementations for common scenarios like downloading to a
* file. The service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, RequestBody requestBody,
ResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, JsonException {
return invokeOperation(streamingInputOutputOperationRequest,
request -> delegate.streamingInputOutputOperation(request, requestBody, responseTransformer));
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest,
ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, JsonException {
return invokeOperation(streamingOutputOperationRequest,
request -> delegate.streamingOutputOperation(request, responseTransformer));
}
/**
* Creates an instance of {@link JsonUtilities} object with the configuration set on this client.
*/
@Override
public JsonUtilities utilities() {
return delegate.utilities();
}
@Override
public final String serviceName() {
return delegate.serviceName();
}
public SdkClient delegate() {
return this.delegate;
}
protected <T extends JsonRequest, ReturnT> ReturnT invokeOperation(T request, Function<T, ReturnT> operation) {
return operation.apply(request);
}
@Override
public final JsonServiceClientConfiguration serviceClientConfiguration() {
return delegate.serviceClientConfiguration();
}
@Override
public void close() {
delegate.close();
}
}
| 3,549 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-json-client-class.java | package software.amazon.awssdk.services.json;
import java.util.Collections;
import java.util.List;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.json.model.APostOperationRequest;
import software.amazon.awssdk.services.json.model.APostOperationResponse;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse;
import software.amazon.awssdk.services.json.model.InvalidInputException;
import software.amazon.awssdk.services.json.model.JsonException;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.utils.HostnameValidator;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link JsonClient}.
*
* @see JsonClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultJsonClient implements JsonClient {
private static final Logger log = Logger.loggerFor(DefaultJsonClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultJsonClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return Result of the APostOperation operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException,
AwsServiceException, SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata,
APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
String hostPrefix = "{StringMember}-foo.";
HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember",
"aPostOperationRequest");
String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember());
return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration)
.withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return Result of the APostOperationWithOutput operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public APostOperationWithOutputResponse aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, APostOperationWithOutputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
return clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the BearerAuthOperation operation.
*
* @param bearerAuthOperationRequest
* @return Result of the BearerAuthOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest)
throws AwsServiceException, SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, BearerAuthOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration)
.withInput(bearerAuthOperationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the GetOperationWithChecksum operation.
*
* @param getOperationWithChecksumRequest
* @return Result of the GetOperationWithChecksum operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public GetOperationWithChecksumResponse getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException,
JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(false).build();
HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
return clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(getOperationWithChecksumRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build())
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param getWithoutRequiredMembersRequest
* @return Result of the GetWithoutRequiredMembers operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
@Override
public GetWithoutRequiredMembersResponse getWithoutRequiredMembers(
GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetWithoutRequiredMembersResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers");
return clientHandler
.execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>()
.withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getWithoutRequiredMembersRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithChecksumRequired operation.
*
* @param operationWithChecksumRequiredRequest
* @return Result of the OperationWithChecksumRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithChecksumRequiredResponse operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithChecksumRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
return clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithChecksumRequiredRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create())
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithRequestCompression operation.
*
* @param operationWithRequestCompressionRequest
* @return Result of the OperationWithRequestCompression operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithRequestCompressionResponse operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithRequestCompressionResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
return clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithRequestCompressionRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @param paginatedOperationWithResultKeyRequest
* @return Result of the PaginatedOperationWithResultKey operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) throws AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PaginatedOperationWithResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey");
return clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>()
.withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(paginatedOperationWithResultKeyRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some paginated operation without result_key in paginators.json file
*
* @param paginatedOperationWithoutResultKeyRequest
* @return Result of the PaginatedOperationWithoutResultKey operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResultKey(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) throws AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey");
return clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>()
.withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(paginatedOperationWithoutResultKeyRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the PutOperationWithChecksum operation.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest,
RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer)
throws AwsServiceException, SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
return clientHandler.execute(
new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(putOperationWithChecksumRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build())
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()), responseTransformer);
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest,
RequestBody requestBody) throws AwsServiceException, SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
return clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(streamingInputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingInputOutputOperationResponse and an InputStream to the response content are provided as
* parameters to the callback. The callback may return a transformed type which will be the return value of
* this method. See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing
* this interface and for links to pre-canned implementations for common scenarios like downloading to a
* file. The service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, RequestBody requestBody,
ResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
streamingInputOutputOperationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation");
return clientHandler.execute(
new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>()
.withOperationName("StreamingInputOutputOperation")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(streamingInputOutputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller
.builder()
.delegateMarshaller(
new StreamingInputOutputOperationRequestMarshaller(protocolFactory))
.requestBody(requestBody).transferEncoding(true).build()), responseTransformer);
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws JsonException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample JsonClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest,
ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, JsonException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
return clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer);
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Creates an instance of {@link JsonUtilities} object with the configuration set on this client.
*/
@Override
public JsonUtilities utilities() {
return JsonUtilities.create(param1, param2, param3);
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(JsonException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build());
}
@Override
public final JsonServiceClientConfiguration serviceClientConfiguration() {
return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,550 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-json-async-client-class.java | package software.amazon.awssdk.services.json;
import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.client.handler.AwsClientHandlerUtils;
import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer;
import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionJsonMarshaller;
import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier;
import software.amazon.awssdk.awscore.eventstream.RestEventStreamAsyncResponseTransformer;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkPojoBuilder;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.SdkResponse;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils;
import software.amazon.awssdk.core.async.SdkPublisher;
import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
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.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.protocol.VoidSdkResponse;
import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.json.model.APostOperationRequest;
import software.amazon.awssdk.services.json.model.APostOperationResponse;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.json.model.EventStream;
import software.amazon.awssdk.services.json.model.EventStreamOperationRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse;
import software.amazon.awssdk.services.json.model.InputEventStream;
import software.amazon.awssdk.services.json.model.InputEventStreamTwo;
import software.amazon.awssdk.services.json.model.InvalidInputException;
import software.amazon.awssdk.services.json.model.JsonException;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.json.model.inputeventstream.DefaultInputEvent;
import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventOne;
import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventTwo;
import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyInputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyOutputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller;
import software.amazon.awssdk.services.json.transform.InputEventMarshaller;
import software.amazon.awssdk.services.json.transform.InputEventTwoMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
import software.amazon.awssdk.utils.HostnameValidator;
import software.amazon.awssdk.utils.Pair;
/**
* Internal implementation of {@link JsonAsyncClient}.
*
* @see JsonAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultJsonAsyncClient implements JsonAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultJsonAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private final Executor executor;
protected DefaultJsonAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR);
}
@Override
public JsonUtilities utilities() {
return JsonUtilities.create(param1, param2, param3);
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
String hostPrefix = "{StringMember}-foo.";
HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember",
"aPostOperationRequest");
String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember());
CompletableFuture<APostOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
CompletableFuture<APostOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, APostOperationWithOutputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(aPostOperationWithOutputRequest));
CompletableFuture<APostOperationWithOutputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the BearerAuthOperation operation asynchronously.
*
* @param bearerAuthOperationRequest
* @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation(
BearerAuthOperationRequest bearerAuthOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, BearerAuthOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.credentialType(CredentialType.TOKEN).withInput(bearerAuthOperationRequest));
CompletableFuture<BearerAuthOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperation operation asynchronously.
*
* @param eventStreamOperationRequest
* @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest,
Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationResponse> responseHandler = new AttachHttpMetadataResponseHandler(
protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder));
HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata
.builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
.putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
.putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
.putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
.putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build();
SdkPublisher<InputEventStream> eventPublisher = SdkPublisher.adapt(requestStream);
Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture<Void> future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer
.<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler)
.eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
.exceptionResponseHandler(errorResponseHandler).future(future).executor(executor).serviceName(serviceName())
.build();
RestEventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer
.<EventStreamOperationResponse, EventStream> builder()
.eventStreamAsyncResponseTransformer(asyncResponseTransformer)
.eventStreamResponseHandler(asyncResponseHandler).build();
CompletableFuture<Void> executeFuture = clientHandler.execute(
new ClientExecutionParams<EventStreamOperationRequest, EventStreamOperationResponse>()
.withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
.withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(eventStreamOperationRequest), restAsyncResponseTransformer);
CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
asyncResponseHandler.exceptionOccurred(e);
} finally {
future.completeExceptionally(e);
}
}
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return CompletableFutureUtils.forwardExceptionTo(future, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperationWithOnlyInput operation asynchronously.
*
* @param eventStreamOperationWithOnlyInputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyInput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput(
EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest,
Publisher<InputEventStreamTwo> requestStream) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyInputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyInput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationWithOnlyInputResponse> responseHandler = protocolFactory
.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
.putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory))
.putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build();
SdkPublisher<InputEventStreamTwo> eventPublisher = SdkPublisher.adapt(requestStream);
Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture<EventStreamOperationWithOnlyInputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<EventStreamOperationWithOnlyInputRequest, EventStreamOperationWithOnlyInputResponse>()
.withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory))
.withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationWithOnlyInputRequest));
CompletableFuture<EventStreamOperationWithOnlyInputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperationWithOnlyOutput operation asynchronously.
*
* @param eventStreamOperationWithOnlyOutputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperationWithOnlyOutput(
EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest,
EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationWithOnlyOutputResponse> responseHandler = new AttachHttpMetadataResponseHandler(
protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder));
HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata
.builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
.putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
.putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
.putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<Void> future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer
.<EventStreamOperationWithOnlyOutputResponse, EventStream> builder()
.eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler)
.initialResponseHandler(responseHandler).exceptionResponseHandler(errorResponseHandler).future(future)
.executor(executor).serviceName(serviceName()).build();
RestEventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer
.<EventStreamOperationWithOnlyOutputResponse, EventStream> builder()
.eventStreamAsyncResponseTransformer(asyncResponseTransformer)
.eventStreamResponseHandler(asyncResponseHandler).build();
CompletableFuture<Void> executeFuture = clientHandler
.execute(
new ClientExecutionParams<EventStreamOperationWithOnlyOutputRequest, EventStreamOperationWithOnlyOutputResponse>()
.withOperationName("EventStreamOperationWithOnlyOutput")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationWithOnlyOutputRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(eventStreamOperationWithOnlyOutputRequest), restAsyncResponseTransformer);
CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
asyncResponseHandler.exceptionOccurred(e);
} finally {
future.completeExceptionally(e);
}
}
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return CompletableFutureUtils.forwardExceptionTo(future, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the GetOperationWithChecksum operation asynchronously.
*
* @param getOperationWithChecksumRequest
* @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(false).build();
HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest));
CompletableFuture<GetOperationWithChecksumResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param getWithoutRequiredMembersRequest
* @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers(
GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetWithoutRequiredMembersResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<GetWithoutRequiredMembersResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>()
.withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getWithoutRequiredMembersRequest));
CompletableFuture<GetWithoutRequiredMembersResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithChecksumRequired operation asynchronously.
*
* @param operationWithChecksumRequiredRequest
* @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithChecksumRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest));
CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithRequestCompression operation asynchronously.
*
* @param operationWithRequestCompressionRequest
* @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithRequestCompressionResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withInput(operationWithRequestCompressionRequest));
CompletableFuture<OperationWithRequestCompressionResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @param paginatedOperationWithResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PaginatedOperationWithResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<PaginatedOperationWithResultKeyResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>()
.withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata)
.withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(paginatedOperationWithResultKeyRequest));
CompletableFuture<PaginatedOperationWithResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some paginated operation without result_key in paginators.json file
*
* @param paginatedOperationWithoutResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory
.createResponseHandler(operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<PaginatedOperationWithoutResultKeyResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>()
.withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata)
.withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(paginatedOperationWithoutResultKeyRequest));
CompletableFuture<PaginatedOperationWithoutResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the PutOperationWithChecksum operation asynchronously.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum(
PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build())
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.withAsyncRequestBody(requestBody)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build()).withInput(putOperationWithChecksumRequest), asyncResponseTransformer);
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody)
.withInput(streamingInputOperationRequest));
CompletableFuture<StreamingInputOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
streamingInputOutputOperationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation");
Pair<AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>()
.withOperationName("StreamingInputOutputOperation")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller
.builder()
.delegateMarshaller(
new StreamingInputOutputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).transferEncoding(true).build())
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withAsyncRequestBody(requestBody).withInput(streamingInputOutputOperationRequest),
asyncResponseTransformer);
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest,
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(streamingOutputOperationRequest), asyncResponseTransformer);
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public final JsonServiceClientConfiguration serviceClientConfiguration() {
return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(JsonException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build());
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,551 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-aws-json-async-client-class.java | package software.amazon.awssdk.services.json;
import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.client.handler.AwsClientHandlerUtils;
import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer;
import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionJsonMarshaller;
import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkPojoBuilder;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.SdkResponse;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils;
import software.amazon.awssdk.core.async.SdkPublisher;
import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
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.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.protocol.VoidSdkResponse;
import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.json.model.APostOperationRequest;
import software.amazon.awssdk.services.json.model.APostOperationResponse;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.json.model.EventStream;
import software.amazon.awssdk.services.json.model.EventStreamOperationRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponse;
import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse;
import software.amazon.awssdk.services.json.model.InputEventStream;
import software.amazon.awssdk.services.json.model.InputEventStreamTwo;
import software.amazon.awssdk.services.json.model.InvalidInputException;
import software.amazon.awssdk.services.json.model.JsonException;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.json.model.OperationWithNoneAuthTypeRequest;
import software.amazon.awssdk.services.json.model.OperationWithNoneAuthTypeResponse;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest;
import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse;
import software.amazon.awssdk.services.json.model.ServiceFaultException;
import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.json.model.inputeventstream.DefaultInputEvent;
import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventOne;
import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventTwo;
import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyInputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyOutputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller;
import software.amazon.awssdk.services.json.transform.InputEventMarshaller;
import software.amazon.awssdk.services.json.transform.InputEventTwoMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithNoneAuthTypeRequestMarshaller;
import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller;
import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
import software.amazon.awssdk.utils.HostnameValidator;
import software.amazon.awssdk.utils.Pair;
/**
* Internal implementation of {@link JsonAsyncClient}.
*
* @see JsonAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultJsonAsyncClient implements JsonAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultJsonAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.AWS_JSON).build();
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private final Executor executor;
protected DefaultJsonAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR);
}
@Override
public JsonUtilities utilities() {
return JsonUtilities.create(param1, param2, param3);
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
String hostPrefix = "{StringMember}-foo.";
HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember",
"aPostOperationRequest");
String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember());
CompletableFuture<APostOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
CompletableFuture<APostOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>ServiceFaultException</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, APostOperationWithOutputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(aPostOperationWithOutputRequest));
CompletableFuture<APostOperationWithOutputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperation operation asynchronously.
*
* @param eventStreamOperationRequest
* @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest,
Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationResponse> responseHandler = new AttachHttpMetadataResponseHandler(
protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder));
HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata
.builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
.putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
.putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
.putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
.putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build();
SdkPublisher<InputEventStream> eventPublisher = SdkPublisher.adapt(requestStream);
Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture<Void> future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer
.<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler)
.eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
.exceptionResponseHandler(errorResponseHandler).future(future).executor(executor).serviceName(serviceName())
.build();
CompletableFuture<Void> executeFuture = clientHandler.execute(
new ClientExecutionParams<EventStreamOperationRequest, SdkResponse>()
.withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
.withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true)
.withInitialRequestEvent(true).withResponseHandler(voidResponseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest),
asyncResponseTransformer);
CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
asyncResponseHandler.exceptionOccurred(e);
} finally {
future.completeExceptionally(e);
}
}
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return CompletableFutureUtils.forwardExceptionTo(future, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperationWithOnlyInput operation asynchronously.
*
* @param eventStreamOperationWithOnlyInputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyInput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput(
EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest,
Publisher<InputEventStreamTwo> requestStream) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyInputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyInput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationWithOnlyInputResponse> responseHandler = protocolFactory
.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
.putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory))
.putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build();
SdkPublisher<InputEventStreamTwo> eventPublisher = SdkPublisher.adapt(requestStream);
Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture<EventStreamOperationWithOnlyInputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<EventStreamOperationWithOnlyInputRequest, EventStreamOperationWithOnlyInputResponse>()
.withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory))
.withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withInitialRequestEvent(true)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(eventStreamOperationWithOnlyInputRequest));
CompletableFuture<EventStreamOperationWithOnlyInputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperationWithOnlyOutput operation asynchronously.
*
* @param eventStreamOperationWithOnlyOutputRequest
* @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperationWithOnlyOutput(
EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest,
EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<EventStreamOperationWithOnlyOutputResponse> responseHandler = new AttachHttpMetadataResponseHandler(
protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder));
HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata
.builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
.putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
.putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
.putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<Void> future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer
.<EventStreamOperationWithOnlyOutputResponse, EventStream> builder()
.eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler)
.initialResponseHandler(responseHandler).exceptionResponseHandler(errorResponseHandler).future(future)
.executor(executor).serviceName(serviceName()).build();
CompletableFuture<Void> executeFuture = clientHandler.execute(
new ClientExecutionParams<EventStreamOperationWithOnlyOutputRequest, SdkResponse>()
.withOperationName("EventStreamOperationWithOnlyOutput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationWithOnlyOutputRequestMarshaller(protocolFactory))
.withResponseHandler(voidResponseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(eventStreamOperationWithOnlyOutputRequest), asyncResponseTransformer);
CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
asyncResponseHandler.exceptionOccurred(e);
} finally {
future.completeExceptionally(e);
}
}
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return CompletableFutureUtils.forwardExceptionTo(future, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param getWithoutRequiredMembersRequest
* @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.GetWithoutRequiredMembers
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers(
GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetWithoutRequiredMembersResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<GetWithoutRequiredMembersResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>()
.withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getWithoutRequiredMembersRequest));
CompletableFuture<GetWithoutRequiredMembersResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithChecksumRequired operation asynchronously.
*
* @param operationWithChecksumRequiredRequest
* @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithChecksumRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest));
CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithNoneAuthType operation asynchronously.
*
* @param operationWithNoneAuthTypeRequest
* @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithNoneAuthType
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithNoneAuthType"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType(
OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithNoneAuthTypeResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>()
.withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(operationWithNoneAuthTypeRequest));
CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithRequestCompression operation asynchronously.
*
* @param operationWithRequestCompressionRequest
* @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, OperationWithRequestCompressionResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withInput(operationWithRequestCompressionRequest));
CompletableFuture<OperationWithRequestCompressionResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some paginated operation with result_key in paginators.json file
*
* @param paginatedOperationWithResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey(
PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PaginatedOperationWithResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<PaginatedOperationWithResultKeyResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>()
.withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata)
.withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(paginatedOperationWithResultKeyRequest));
CompletableFuture<PaginatedOperationWithResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some paginated operation without result_key in paginators.json file
*
* @param paginatedOperationWithoutResultKeyRequest
* @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.PaginatedOperationWithoutResultKey
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey(
PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory
.createResponseHandler(operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<PaginatedOperationWithoutResultKeyResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>()
.withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata)
.withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(paginatedOperationWithoutResultKeyRequest));
CompletableFuture<PaginatedOperationWithoutResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody)
.withInput(streamingInputOperationRequest));
CompletableFuture<StreamingInputOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with streaming input and streaming output
*
* @param streamingInputOutputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingInputOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation(
StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
streamingInputOutputOperationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation");
Pair<AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingInputOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>()
.withOperationName("StreamingInputOutputOperation")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller
.builder()
.delegateMarshaller(
new StreamingInputOutputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).transferEncoding(true).build())
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withAsyncRequestBody(requestBody).withInput(streamingInputOutputOperationRequest),
asyncResponseTransformer);
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample JsonAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest,
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
.isPayloadJson(false).build();
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamingOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(streamingOutputOperationRequest), asyncResponseTransformer);
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public final JsonServiceClientConfiguration serviceClientConfiguration() {
return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(JsonException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInputException")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceFaultException")
.exceptionBuilderSupplier(ServiceFaultException::builder).httpStatusCode(500).build());
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,552 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-query-client-class.java | package software.amazon.awssdk.services.query;
import java.util.Collections;
import java.util.List;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.query.AwsQueryProtocolFactory;
import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.query.model.APostOperationRequest;
import software.amazon.awssdk.services.query.model.APostOperationResponse;
import software.amazon.awssdk.services.query.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.query.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.query.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.query.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.query.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.query.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.query.model.InvalidInputException;
import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.query.model.OperationWithContextParamRequest;
import software.amazon.awssdk.services.query.model.OperationWithContextParamResponse;
import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeRequest;
import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeResponse;
import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsRequest;
import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsResponse;
import software.amazon.awssdk.services.query.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.query.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.query.model.QueryException;
import software.amazon.awssdk.services.query.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.query.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.query.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.query.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.query.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.query.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithContextParamRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithNoneAuthTypeRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithStaticContextParamsRequestMarshaller;
import software.amazon.awssdk.services.query.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.query.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.services.query.waiters.QueryWaiter;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link QueryClient}.
*
* @see QueryClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultQueryClient implements QueryClient {
private static final Logger log = Logger.loggerFor(DefaultQueryClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.QUERY).build();
private final SyncClientHandler clientHandler;
private final AwsQueryProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultQueryClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init();
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return Result of the APostOperation operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException,
AwsServiceException, SdkClientException, QueryException {
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory
.createResponseHandler(APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
String hostPrefix = "foo-";
String resolvedHostExpression = "foo-";
return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration)
.withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return Result of the APostOperationWithOutput operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public APostOperationWithOutputResponse aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, QueryException {
HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory
.createResponseHandler(APostOperationWithOutputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
return clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the BearerAuthOperation operation.
*
* @param bearerAuthOperationRequest
* @return Result of the BearerAuthOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest)
throws AwsServiceException, SdkClientException, QueryException {
HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory
.createResponseHandler(BearerAuthOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration)
.withInput(bearerAuthOperationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the GetOperationWithChecksum operation.
*
* @param getOperationWithChecksumRequest
* @return Result of the GetOperationWithChecksum operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public GetOperationWithChecksumResponse getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException,
QueryException {
HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory
.createResponseHandler(GetOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
return clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(getOperationWithChecksumRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build())
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithChecksumRequired operation.
*
* @param operationWithChecksumRequiredRequest
* @return Result of the OperationWithChecksumRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithChecksumRequiredResponse operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException,
SdkClientException, QueryException {
HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithChecksumRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
return clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithChecksumRequiredRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create())
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithContextParam operation.
*
* @param operationWithContextParamRequest
* @return Result of the OperationWithContextParam operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.OperationWithContextParam
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithContextParam"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithContextParamResponse operationWithContextParam(
OperationWithContextParamRequest operationWithContextParamRequest) throws AwsServiceException, SdkClientException,
QueryException {
HttpResponseHandler<OperationWithContextParamResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithContextParamResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithContextParamRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithContextParamRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithContextParam");
return clientHandler
.execute(new ClientExecutionParams<OperationWithContextParamRequest, OperationWithContextParamResponse>()
.withOperationName("OperationWithContextParam").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(operationWithContextParamRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new OperationWithContextParamRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithNoneAuthType operation.
*
* @param operationWithNoneAuthTypeRequest
* @return Result of the OperationWithNoneAuthType operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.OperationWithNoneAuthType
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithNoneAuthType"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithNoneAuthTypeResponse operationWithNoneAuthType(
OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) throws AwsServiceException, SdkClientException,
QueryException {
HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithNoneAuthTypeResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType");
return clientHandler
.execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>()
.withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(operationWithNoneAuthTypeRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithRequestCompression operation.
*
* @param operationWithRequestCompressionRequest
* @return Result of the OperationWithRequestCompression operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithRequestCompressionResponse operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException,
SdkClientException, QueryException {
HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithRequestCompressionResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
return clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithRequestCompressionRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithStaticContextParams operation.
*
* @param operationWithStaticContextParamsRequest
* @return Result of the OperationWithStaticContextParams operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.OperationWithStaticContextParams
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithStaticContextParams"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithStaticContextParamsResponse operationWithStaticContextParams(
OperationWithStaticContextParamsRequest operationWithStaticContextParamsRequest) throws AwsServiceException,
SdkClientException, QueryException {
HttpResponseHandler<OperationWithStaticContextParamsResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithStaticContextParamsResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithStaticContextParamsRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithStaticContextParamsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithStaticContextParams");
return clientHandler
.execute(new ClientExecutionParams<OperationWithStaticContextParamsRequest, OperationWithStaticContextParamsResponse>()
.withOperationName("OperationWithStaticContextParams").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(operationWithStaticContextParamsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new OperationWithStaticContextParamsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the PutOperationWithChecksum operation.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest,
RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer)
throws AwsServiceException, SdkClientException, QueryException {
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory
.createResponseHandler(PutOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
return clientHandler
.execute(new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(putOperationWithChecksumRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build())
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest,
RequestBody requestBody) throws AwsServiceException, SdkClientException, QueryException {
HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory
.createResponseHandler(StreamingInputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
return clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(streamingInputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QueryClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest,
ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, QueryException {
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory
.createResponseHandler(StreamingOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
return clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer);
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Create an instance of {@link QueryWaiter} using this client.
* <p>
* Waiters created via this method are managed by the SDK and resources will be released when the service client is
* closed.
*
* @return an instance of {@link QueryWaiter}
*/
@Override
public QueryWaiter waiter() {
return QueryWaiter.builder().client(this).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private AwsQueryProtocolFactory init() {
return AwsQueryProtocolFactory
.builder()
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
.clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(QueryException::builder).build();
}
@Override
public final QueryServiceClientConfiguration serviceClientConfiguration() {
return new QueryServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,553 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-xml-async-client-class.java | package software.amazon.awssdk.services.xml;
import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer;
import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier;
import software.amazon.awssdk.awscore.eventstream.RestEventStreamAsyncResponseTransformer;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.Response;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkPojoBuilder;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils;
import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.xml.AwsXmlProtocolFactory;
import software.amazon.awssdk.protocols.xml.XmlOperationMetadata;
import software.amazon.awssdk.services.xml.internal.XmlServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.xml.model.APostOperationRequest;
import software.amazon.awssdk.services.xml.model.APostOperationResponse;
import software.amazon.awssdk.services.xml.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.xml.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.xml.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.xml.model.EventStream;
import software.amazon.awssdk.services.xml.model.EventStreamOperationRequest;
import software.amazon.awssdk.services.xml.model.EventStreamOperationResponse;
import software.amazon.awssdk.services.xml.model.EventStreamOperationResponseHandler;
import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.xml.model.InvalidInputException;
import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeRequest;
import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeResponse;
import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.xml.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.xml.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.xml.model.XmlException;
import software.amazon.awssdk.services.xml.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.EventStreamOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithNoneAuthTypeRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
import software.amazon.awssdk.utils.Pair;
/**
* Internal implementation of {@link XmlAsyncClient}.
*
* @see XmlAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultXmlAsyncClient implements XmlAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultXmlAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_XML).build();
private final AsyncClientHandler clientHandler;
private final AwsXmlProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private final Executor executor;
protected DefaultXmlAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init();
this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR);
}
/**
* <p>
* Performs a post operation to the xml service and has no output
* </p>
*
* @param aPostOperationRequest
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
HttpResponseHandler<Response<APostOperationResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(APostOperationResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
String hostPrefix = "foo-";
String resolvedHostExpression = "foo-";
CompletableFuture<APostOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler).hostPrefixExpression(resolvedHostExpression)
.withMetricCollector(apiCallMetricCollector).withInput(aPostOperationRequest));
CompletableFuture<APostOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the xml service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
HttpResponseHandler<Response<APostOperationWithOutputResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(APostOperationWithOutputResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.withInput(aPostOperationWithOutputRequest));
CompletableFuture<APostOperationWithOutputResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the BearerAuthOperation operation asynchronously.
*
* @param bearerAuthOperationRequest
* @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation(
BearerAuthOperationRequest bearerAuthOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
HttpResponseHandler<Response<BearerAuthOperationResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(BearerAuthOperationResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler).credentialType(CredentialType.TOKEN)
.withMetricCollector(apiCallMetricCollector).withInput(bearerAuthOperationRequest));
CompletableFuture<BearerAuthOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the EventStreamOperation operation asynchronously.
*
* @param eventStreamOperationRequest
* @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.EventStreamOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/EventStreamOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest,
EventStreamOperationResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation");
HttpResponseHandler<EventStreamOperationResponse> responseHandler = protocolFactory.createResponseHandler(
EventStreamOperationResponse::builder, XmlOperationMetadata.builder().hasStreamingSuccessResponse(true)
.build());
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
EventStreamTaggedUnionPojoSupplier.builder()
.putSdkPojoSupplier("EventPayloadEvent", EventStream::eventPayloadEventBuilder)
.putSdkPojoSupplier("NonEventPayloadEvent", EventStream::nonEventPayloadEventBuilder)
.putSdkPojoSupplier("SecondEventPayloadEvent", EventStream::secondEventPayloadEventBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build(), XmlOperationMetadata
.builder().hasStreamingSuccessResponse(false).build());
CompletableFuture<Void> eventStreamTransformFuture = new CompletableFuture<>();
EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer
.<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler)
.eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
.exceptionResponseHandler(errorResponseHandler).future(eventStreamTransformFuture).executor(executor)
.serviceName(serviceName()).build();
RestEventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer
.<EventStreamOperationResponse, EventStream> builder()
.eventStreamAsyncResponseTransformer(asyncResponseTransformer)
.eventStreamResponseHandler(asyncResponseHandler).build();
CompletableFuture<Void> executeFuture = clientHandler.execute(
new ClientExecutionParams<EventStreamOperationRequest, EventStreamOperationResponse>()
.withOperationName("EventStreamOperation").withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest),
restAsyncResponseTransformer);
CompletableFuture<Void> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(e));
eventStreamTransformFuture.completeExceptionally(e);
}
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return CompletableFutureUtils.forwardExceptionTo(eventStreamTransformFuture, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the GetOperationWithChecksum operation asynchronously.
*
* @param getOperationWithChecksumRequest
* @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
HttpResponseHandler<Response<GetOperationWithChecksumResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(GetOperationWithChecksumResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest));
CompletableFuture<GetOperationWithChecksumResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithChecksumRequired operation asynchronously.
*
* @param operationWithChecksumRequiredRequest
* @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
HttpResponseHandler<Response<OperationWithChecksumRequiredResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithChecksumRequiredResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest));
CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithNoneAuthType operation asynchronously.
*
* @param operationWithNoneAuthTypeRequest
* @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.OperationWithNoneAuthType
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithNoneAuthType"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType(
OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType");
HttpResponseHandler<Response<OperationWithNoneAuthTypeResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithNoneAuthTypeResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>()
.withOperationName("OperationWithNoneAuthType").withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.withInput(operationWithNoneAuthTypeRequest));
CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithRequestCompression operation asynchronously.
*
* @param operationWithRequestCompressionRequest
* @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
HttpResponseHandler<Response<OperationWithRequestCompressionResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithRequestCompressionResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withInput(operationWithRequestCompressionRequest));
CompletableFuture<OperationWithRequestCompressionResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the PutOperationWithChecksum operation asynchronously.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum(
PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
PutOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true));
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build())
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build()).withAsyncRequestBody(requestBody)
.withInput(putOperationWithChecksumRequest), asyncResponseTransformer);
CompletableFuture<ReturnT> whenCompleteFuture = null;
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
HttpResponseHandler<Response<StreamingInputOperationResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(StreamingInputOperationResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withRequestConfiguration(clientConfiguration)
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build()).withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody)
.withInput(streamingInputOperationRequest));
CompletableFuture<StreamingInputOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
return whenCompleteFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.</li>
* </ul>
* @sample XmlAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest,
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
StreamingOutputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true));
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(streamingOutputOperationRequest), asyncResponseTransformer);
CompletableFuture<ReturnT> whenCompleteFuture = null;
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public final XmlServiceClientConfiguration serviceClientConfiguration() {
return new XmlServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private AwsXmlProtocolFactory init() {
return AwsXmlProtocolFactory
.builder()
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
.clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(XmlException::builder).build();
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
XmlServiceClientConfigurationBuilder serviceConfigBuilder = new XmlServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,554 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-xml-client-class.java | package software.amazon.awssdk.services.xml;
import java.util.Collections;
import java.util.List;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.Response;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.xml.AwsXmlProtocolFactory;
import software.amazon.awssdk.protocols.xml.XmlOperationMetadata;
import software.amazon.awssdk.services.xml.internal.XmlServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.xml.model.APostOperationRequest;
import software.amazon.awssdk.services.xml.model.APostOperationResponse;
import software.amazon.awssdk.services.xml.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.xml.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.xml.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.xml.model.InvalidInputException;
import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeRequest;
import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeResponse;
import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.xml.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.xml.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.xml.model.XmlException;
import software.amazon.awssdk.services.xml.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithNoneAuthTypeRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.xml.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link XmlClient}.
*
* @see XmlClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultXmlClient implements XmlClient {
private static final Logger log = Logger.loggerFor(DefaultXmlClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_XML).build();
private final SyncClientHandler clientHandler;
private final AwsXmlProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultXmlClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init();
}
/**
* <p>
* Performs a post operation to the xml service and has no output
* </p>
*
* @param aPostOperationRequest
* @return Result of the APostOperation operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException,
AwsServiceException, SdkClientException, XmlException {
HttpResponseHandler<Response<APostOperationResponse>> responseHandler = protocolFactory.createCombinedResponseHandler(
APostOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
String hostPrefix = "foo-";
String resolvedHostExpression = "foo-";
return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration)
.withInput(aPostOperationRequest).withMarshaller(new APostOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* <p>
* Performs a post operation to the xml service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return Result of the APostOperationWithOutput operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public APostOperationWithOutputResponse aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException,
SdkClientException, XmlException {
HttpResponseHandler<Response<APostOperationWithOutputResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(APostOperationWithOutputResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
return clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the BearerAuthOperation operation.
*
* @param bearerAuthOperationRequest
* @return Result of the BearerAuthOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest)
throws AwsServiceException, SdkClientException, XmlException {
HttpResponseHandler<Response<BearerAuthOperationResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(BearerAuthOperationResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration)
.withInput(bearerAuthOperationRequest)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the GetOperationWithChecksum operation.
*
* @param getOperationWithChecksumRequest
* @return Result of the GetOperationWithChecksum operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public GetOperationWithChecksumResponse getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException,
XmlException {
HttpResponseHandler<Response<GetOperationWithChecksumResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(GetOperationWithChecksumResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
return clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration)
.withInput(getOperationWithChecksumRequest)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build())
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithChecksumRequired operation.
*
* @param operationWithChecksumRequiredRequest
* @return Result of the OperationWithChecksumRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithChecksumRequiredResponse operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException,
SdkClientException, XmlException {
HttpResponseHandler<Response<OperationWithChecksumRequiredResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithChecksumRequiredResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
return clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithChecksumRequiredRequest)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create())
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithNoneAuthType operation.
*
* @param operationWithNoneAuthTypeRequest
* @return Result of the OperationWithNoneAuthType operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.OperationWithNoneAuthType
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithNoneAuthType"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithNoneAuthTypeResponse operationWithNoneAuthType(
OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) throws AwsServiceException, SdkClientException,
XmlException {
HttpResponseHandler<Response<OperationWithNoneAuthTypeResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithNoneAuthTypeResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType");
return clientHandler
.execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>()
.withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration).withInput(operationWithNoneAuthTypeRequest)
.withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the OperationWithRequestCompression operation.
*
* @param operationWithRequestCompressionRequest
* @return Result of the OperationWithRequestCompression operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithRequestCompressionResponse operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException,
SdkClientException, XmlException {
HttpResponseHandler<Response<OperationWithRequestCompressionResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(OperationWithRequestCompressionResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
return clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration)
.withInput(operationWithRequestCompressionRequest)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Invokes the PutOperationWithChecksum operation.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest,
RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer)
throws AwsServiceException, SdkClientException, XmlException {
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(
PutOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true));
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
return clientHandler
.execute(new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(putOperationWithChecksumRequest)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build())
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest,
RequestBody requestBody) throws AwsServiceException, SdkClientException, XmlException {
HttpResponseHandler<Response<StreamingInputOperationResponse>> responseHandler = protocolFactory
.createCombinedResponseHandler(StreamingInputOperationResponse::builder,
new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
return clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withCombinedResponseHandler(responseHandler)
.withMetricCollector(apiCallMetricCollector)
.withRequestConfiguration(clientConfiguration)
.withInput(streamingInputOperationRequest)
.withRequestBody(requestBody)
.withMarshaller(
StreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.requestBody(requestBody).build()));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param responseTransformer
* Functional interface for processing the streamed response content. The unmarshalled
* StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to
* the callback. The callback may return a transformed type which will be the return value of this method.
* See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
* interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
* service documentation for the response content is as follows 'This be a stream'.
* @return The transformed result of the ResponseTransformer.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest,
ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException,
SdkClientException, XmlException {
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(
StreamingOutputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true));
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
return clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer);
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
XmlServiceClientConfigurationBuilder serviceConfigBuilder = new XmlServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private AwsXmlProtocolFactory init() {
return AwsXmlProtocolFactory
.builder()
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
.clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(XmlException::builder).build();
}
@Override
public final XmlServiceClientConfiguration serviceClientConfiguration() {
return new XmlServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,555 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client | Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-query-async-client-class.java | package software.amazon.awssdk.services.query;
import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.CredentialType;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.http.HttpResponseHandler;
import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksum;
import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired;
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.query.AwsQueryProtocolFactory;
import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.query.model.APostOperationRequest;
import software.amazon.awssdk.services.query.model.APostOperationResponse;
import software.amazon.awssdk.services.query.model.APostOperationWithOutputRequest;
import software.amazon.awssdk.services.query.model.APostOperationWithOutputResponse;
import software.amazon.awssdk.services.query.model.BearerAuthOperationRequest;
import software.amazon.awssdk.services.query.model.BearerAuthOperationResponse;
import software.amazon.awssdk.services.query.model.GetOperationWithChecksumRequest;
import software.amazon.awssdk.services.query.model.GetOperationWithChecksumResponse;
import software.amazon.awssdk.services.query.model.InvalidInputException;
import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredRequest;
import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredResponse;
import software.amazon.awssdk.services.query.model.OperationWithContextParamRequest;
import software.amazon.awssdk.services.query.model.OperationWithContextParamResponse;
import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeRequest;
import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeResponse;
import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionRequest;
import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionResponse;
import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsRequest;
import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsResponse;
import software.amazon.awssdk.services.query.model.PutOperationWithChecksumRequest;
import software.amazon.awssdk.services.query.model.PutOperationWithChecksumResponse;
import software.amazon.awssdk.services.query.model.QueryException;
import software.amazon.awssdk.services.query.model.StreamingInputOperationRequest;
import software.amazon.awssdk.services.query.model.StreamingInputOperationResponse;
import software.amazon.awssdk.services.query.model.StreamingOutputOperationRequest;
import software.amazon.awssdk.services.query.model.StreamingOutputOperationResponse;
import software.amazon.awssdk.services.query.transform.APostOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller;
import software.amazon.awssdk.services.query.transform.BearerAuthOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.GetOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithChecksumRequiredRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithContextParamRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithNoneAuthTypeRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithRequestCompressionRequestMarshaller;
import software.amazon.awssdk.services.query.transform.OperationWithStaticContextParamsRequestMarshaller;
import software.amazon.awssdk.services.query.transform.PutOperationWithChecksumRequestMarshaller;
import software.amazon.awssdk.services.query.transform.StreamingInputOperationRequestMarshaller;
import software.amazon.awssdk.services.query.transform.StreamingOutputOperationRequestMarshaller;
import software.amazon.awssdk.services.query.waiters.QueryAsyncWaiter;
import software.amazon.awssdk.utils.CompletableFutureUtils;
import software.amazon.awssdk.utils.Pair;
/**
* Internal implementation of {@link QueryAsyncClient}.
*
* @see QueryAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultQueryAsyncClient implements QueryAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultQueryAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.QUERY).build();
private final AsyncClientHandler clientHandler;
private final AwsQueryProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private final ScheduledExecutorService executorService;
protected DefaultQueryAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init();
this.executorService = clientConfiguration.option(SdkClientOption.SCHEDULED_EXECUTOR_SERVICE);
}
/**
* <p>
* Performs a post operation to the query service and has no output
* </p>
*
* @param aPostOperationRequest
* @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory
.createResponseHandler(APostOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
String hostPrefix = "foo-";
String resolvedHostExpression = "foo-";
CompletableFuture<APostOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>()
.withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
CompletableFuture<APostOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* <p>
* Performs a post operation to the query service and has modelled output
* </p>
*
* @param aPostOperationWithOutputRequest
* @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
* for an input parameter.</li>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.APostOperationWithOutput
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperationWithOutput"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(
APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory
.createResponseHandler(APostOperationWithOutputResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>()
.withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
.withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(aPostOperationWithOutputRequest));
CompletableFuture<APostOperationWithOutputResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the BearerAuthOperation operation asynchronously.
*
* @param bearerAuthOperationRequest
* @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.BearerAuthOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/BearerAuthOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation(
BearerAuthOperationRequest bearerAuthOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation");
HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory
.createResponseHandler(BearerAuthOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>()
.withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withInput(bearerAuthOperationRequest));
CompletableFuture<BearerAuthOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the GetOperationWithChecksum operation asynchronously.
*
* @param getOperationWithChecksumRequest
* @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.GetOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/GetOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum(
GetOperationWithChecksumRequest getOperationWithChecksumRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum");
HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory
.createResponseHandler(GetOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>()
.withOperationName("GetOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(true)
.requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString())
.isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest));
CompletableFuture<GetOperationWithChecksumResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithChecksumRequired operation asynchronously.
*
* @param operationWithChecksumRequiredRequest
* @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(
OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithChecksumRequiredResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>()
.withOperationName("OperationWithChecksumRequired")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest));
CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithContextParam operation asynchronously.
*
* @param operationWithContextParamRequest
* @return A Java Future containing the result of the OperationWithContextParam operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.OperationWithContextParam
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithContextParam"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithContextParamResponse> operationWithContextParam(
OperationWithContextParamRequest operationWithContextParamRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithContextParamRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithContextParamRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithContextParam");
HttpResponseHandler<OperationWithContextParamResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithContextParamResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<OperationWithContextParamResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithContextParamRequest, OperationWithContextParamResponse>()
.withOperationName("OperationWithContextParam").withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithContextParamRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(operationWithContextParamRequest));
CompletableFuture<OperationWithContextParamResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithNoneAuthType operation asynchronously.
*
* @param operationWithNoneAuthTypeRequest
* @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.OperationWithNoneAuthType
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithNoneAuthType"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType(
OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType");
HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithNoneAuthTypeResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>()
.withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(operationWithNoneAuthTypeRequest));
CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithRequestCompression operation asynchronously.
*
* @param operationWithRequestCompressionRequest
* @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.OperationWithRequestCompression
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithRequestCompression"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression(
OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithRequestCompressionResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>()
.withOperationName("OperationWithRequestCompression")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
RequestCompression.builder().encodings("gzip").isStreaming(false).build())
.withInput(operationWithRequestCompressionRequest));
CompletableFuture<OperationWithRequestCompressionResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the OperationWithStaticContextParams operation asynchronously.
*
* @param operationWithStaticContextParamsRequest
* @return A Java Future containing the result of the OperationWithStaticContextParams operation returned by the
* service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.OperationWithStaticContextParams
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithStaticContextParams"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<OperationWithStaticContextParamsResponse> operationWithStaticContextParams(
OperationWithStaticContextParamsRequest operationWithStaticContextParamsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithStaticContextParamsRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration,
operationWithStaticContextParamsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithStaticContextParams");
HttpResponseHandler<OperationWithStaticContextParamsResponse> responseHandler = protocolFactory
.createResponseHandler(OperationWithStaticContextParamsResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<OperationWithStaticContextParamsResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<OperationWithStaticContextParamsRequest, OperationWithStaticContextParamsResponse>()
.withOperationName("OperationWithStaticContextParams").withProtocolMetadata(protocolMetadata)
.withMarshaller(new OperationWithStaticContextParamsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(operationWithStaticContextParamsRequest));
CompletableFuture<OperationWithStaticContextParamsResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Invokes the PutOperationWithChecksum operation asynchronously.
*
* @param putOperationWithChecksumRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows '
* <p>
* Object data.
* </p>
* '
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows '
* <p>
* Object data.
* </p>
* '.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.PutOperationWithChecksum
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/PutOperationWithChecksum"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum(
PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody,
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum");
Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory
.createResponseHandler(PutOperationWithChecksumResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>()
.withOperationName("PutOperationWithChecksum")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build())
.withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector)
.putExecutionAttribute(
SdkInternalExecutionAttribute.HTTP_CHECKSUM,
HttpChecksum.builder().requestChecksumRequired(false)
.requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString())
.responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true)
.build()).withAsyncRequestBody(requestBody)
.withInput(putOperationWithChecksumRequest), asyncResponseTransformer);
CompletableFuture<ReturnT> whenCompleteFuture = null;
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* Functional interface that can be implemented to produce the request content in a non-blocking manner. The
* size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
* implementing this interface as well as links to precanned implementations for common scenarios like
* uploading from a file. The service documentation for the request content is as follows 'This be a stream'
* @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation(
StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory
.createResponseHandler(StreamingInputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler
.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>()
.withOperationName("StreamingInputOperation")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(
AsyncStreamingRequestMarshaller.builder()
.delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
.asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody)
.withInput(streamingInputOperationRequest));
CompletableFuture<StreamingInputOperationResponse> whenCompleteFuture = null;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
* Some operation with a streaming output
*
* @param streamingOutputOperationRequest
* @param asyncResponseTransformer
* The response transformer for processing the streaming response in a non-blocking manner. See
* {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
* precanned implementations for common scenarios like downloading to a file. The service documentation for
* the response content is as follows 'This be a stream'.
* @return A future to the transformed result of the AsyncResponseTransformer.<br/>
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
* <ul>
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.</li>
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.</li>
* <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.</li>
* </ul>
* @sample QueryAsyncClient.StreamingOutputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingOutputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
StreamingOutputOperationRequest streamingOutputOperationRequest,
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
this.clientConfiguration);
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils
.wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture<Void> endOfStreamFuture = pair.right();
HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory
.createResponseHandler(StreamingOutputOperationResponse::builder);
HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
CompletableFuture<ReturnT> executeFuture = clientHandler.execute(
new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>()
.withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
.withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(streamingOutputOperationRequest), asyncResponseTransformer);
CompletableFuture<ReturnT> whenCompleteFuture = null;
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
});
return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
} catch (Throwable t) {
AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public QueryAsyncWaiter waiter() {
return QueryAsyncWaiter.builder().client(this).scheduledExecutorService(executorService).build();
}
@Override
public final QueryServiceClientConfiguration serviceClientConfiguration() {
return new QueryServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private AwsQueryProtocolFactory init() {
return AwsQueryProtocolFactory
.builder()
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
.clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(QueryException::builder).build();
}
private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List<MetricPublisher> publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
if (plugins.isEmpty()) {
return clientConfiguration;
}
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
@Override
public void close() {
clientHandler.close();
}
}
| 3,556 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/AddShapesTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import java.io.IOException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.MemberModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
import software.amazon.awssdk.codegen.model.service.Location;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.poet.model.AwsModelSpecTest;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
class AddShapesTest {
private static IntermediateModel intermediateModel;
@BeforeAll
public static void setUp() throws IOException {
File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json").getFile());
File customizationConfigFile = new File(AwsModelSpecTest.class
.getResource("customization.config")
.getFile());
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile))
.customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile))
.build())
.build();
}
@Test
void generateShapeModel_memberRequiredByShape_setsMemberModelAsRequired() {
String requestShapeName = "QueryParameterOperationRequest";
String queryParamName = "QueryParamOne";
ShapeModel requestShapeModel = intermediateModel.getShapes().get(requestShapeName);
MemberModel requiredMemberModel = requestShapeModel.findMemberModelByC2jName(queryParamName);
assertThat(requestShapeModel.getRequired()).contains(queryParamName);
assertThat(requiredMemberModel.getHttp().getLocation()).isEqualTo(Location.QUERY_STRING);
assertThat(requiredMemberModel.isRequired()).isTrue();
}
@Test
void generateShapeModel_memberNotRequiredByShape_doesNotSetMemberModelAsRequired() {
String requestShapeName = "QueryParameterOperationRequest";
String queryParamName = "QueryParamTwo";
ShapeModel requestShapeModel = intermediateModel.getShapes().get(requestShapeName);
MemberModel requiredMemberModel = requestShapeModel.findMemberModelByC2jName(queryParamName);
assertThat(requestShapeModel.getRequired()).doesNotContain(queryParamName);
assertThat(requiredMemberModel.getHttp().getLocation()).isEqualTo(Location.QUERY_STRING);
assertThat(requiredMemberModel.isRequired()).isFalse();
}
@Test
void generateShapeModel_memberRequiredByNestedShape_setsMemberModelAsRequired() {
String requestShapeName = "NestedQueryParameterOperation";
String queryParamName = "QueryParamOne";
ShapeModel requestShapeModel = intermediateModel.getShapes().get(requestShapeName);
MemberModel requiredMemberModel = requestShapeModel.findMemberModelByC2jName(queryParamName);
assertThat(requestShapeModel.getRequired()).contains(queryParamName);
assertThat(requiredMemberModel.getHttp().getLocation()).isEqualTo(Location.QUERY_STRING);
assertThat(requiredMemberModel.isRequired()).isTrue();
}
}
| 3,557 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/TestStringUtils.java | package software.amazon.awssdk.codegen;
import software.amazon.awssdk.codegen.internal.Constant;
/**
* Various convenience methods for strings manipulation required in Code Generator tests.
*/
public final class TestStringUtils {
/**
* Not intended to be constructed directly.
*/
private TestStringUtils() {
}
/**
* Replaces all the newline (line feed/LF) characters ('\u000A' or '\n') with the platform-dependent line separator char
* (e.g. "\u000D\u000A" or "\r\n" on Windows systems).
*
* @param str string, containing '\n' chars to be replaced
* @return original string with '\n' chars replaced with platform-dependent line separator chars
* @see Constant#LF
*/
public static String toPlatformLfs(String str) {
return str.replaceAll("\n", Constant.LF);
}
}
| 3,558 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/IntermediateModelBuilderTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.File;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
public class IntermediateModelBuilderTest {
@Test
public void testServiceAndShapeNameCollisions() throws Exception {
final File modelFile = new File(IntermediateModelBuilderTest.class
.getResource("poet/client/c2j/collision/service-2.json").getFile());
IntermediateModel testModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, modelFile))
.customizationConfig(CustomizationConfig.create())
.build())
.build();
assertThat(testModel.getShapes().values())
.extracting(ShapeModel::getShapeName)
.containsExactlyInAnyOrder("DefaultCollisionException", "DefaultCollisionRequest", "DefaultCollisionResponse");
}
@Test
public void sharedOutputShapesLinkCorrectlyToOperationOutputs() {
final File modelFile = new File(IntermediateModelBuilderTest.class
.getResource("poet/client/c2j/shared-output/service-2.json").getFile());
IntermediateModel testModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, modelFile))
.customizationConfig(CustomizationConfig.create())
.build())
.build();
assertEquals("PingResponse", testModel.getOperation("Ping").getOutputShape().getShapeName());
assertEquals("SecurePingResponse", testModel.getOperation("SecurePing").getOutputShape().getShapeName());
}
@Test
public void defaultEndpointDiscovery_true() {
final File modelFile = new File(IntermediateModelBuilderTest.class
.getResource("poet/client/c2j/endpointdiscovery/service-2.json").getFile());
IntermediateModel testModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, modelFile))
.customizationConfig(CustomizationConfig.create())
.build())
.build();
assertTrue(testModel.getEndpointOperation().get().isEndpointCacheRequired());
}
@Test
public void defaultEndpointDiscovery_false() {
final File modelFile = new File(IntermediateModelBuilderTest.class
.getResource("poet/client/c2j/endpointdiscoveryoptional/service-2.json").getFile());
IntermediateModel testModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, modelFile))
.customizationConfig(CustomizationConfig.create())
.build())
.build();
assertFalse(testModel.getEndpointOperation().get().isEndpointCacheRequired());
}
@Test
public void assertAwsQueryCompatibleTrait_notNull() {
final File modelFile = new File(IntermediateModelBuilderTest.class
.getResource("poet/client/c2j/query-to-json-errorcode/service-2.json").getFile());
IntermediateModel testModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, modelFile))
.customizationConfig(CustomizationConfig.create())
.build())
.build();
assertNotNull(testModel.getMetadata().getAwsQueryCompatible());
}
}
| 3,559 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization/processors/UseLegacyEventGenerationSchemeProcessorTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.customization.processors;
import java.io.File;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
/**
* Tests for {@link UseLegacyEventGenerationSchemeProcessor}
*/
public class UseLegacyEventGenerationSchemeProcessorTest {
private static final String RESOURCE_ROOT = "/software/amazon/awssdk/codegen/emitters/customizations/processors/uselegacyeventgenerationscheme";
private static final UseLegacyEventGenerationSchemeProcessor processor = new UseLegacyEventGenerationSchemeProcessor();
@Rule
public ExpectedException thrown = ExpectedException.none();
private static ServiceModel serviceModel;
@BeforeClass
public static void setup() {
String c2jFilePath = UseLegacyEventGenerationSchemeProcessorTest.class.getResource(RESOURCE_ROOT + "/service-2.json").getFile();
File c2jFile = new File(c2jFilePath);
serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, c2jFile);
}
@Test
public void testPostProcess_customizationDeclaredForMultipleMembersWithSameShape_throws() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("targets more than one member with the shape");
IntermediateModel intermediateModel = intermediateModelWithConfig("multiple-event-types-same-shape.config");
processor.postprocess(intermediateModel);
}
@Test
public void testPostProcess_customizationIsValid_succeeds() {
IntermediateModel intermediateModel = intermediateModelWithConfig("happy-case-customization.config");
processor.postprocess(intermediateModel);
}
private static IntermediateModel intermediateModelWithConfig(String configName) {
return new IntermediateModelBuilder(C2jModels.builder()
.serviceModel(serviceModel)
.customizationConfig(loadCustomizationConfig(configName))
.build())
.build();
}
private static CustomizationConfig loadCustomizationConfig(String configName) {
String c2jFilePath = UseLegacyEventGenerationSchemeProcessorTest.class.getResource(RESOURCE_ROOT + "/" + configName).getFile();
File file = new File(c2jFilePath);
return ModelLoaderUtils.loadModel(CustomizationConfig.class, file);
}
}
| 3,560 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization/processors/S3RemoveBucketFromUriProcessorTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.customization.processors;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import software.amazon.awssdk.codegen.model.service.Http;
import software.amazon.awssdk.codegen.model.service.Operation;
import software.amazon.awssdk.codegen.model.service.ServiceMetadata;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
public class S3RemoveBucketFromUriProcessorTest {
private static final String WITH_BUCKET_URI_OPERATION = "WithBucketInUri";
private static final String WITHOUT_BUCKET_URI_OPERATION = "WithoutBucketInUri";
private static final String WITH_BUCKET_URI = "/{Bucket}/{Key+}";
private static final String WITHOUT_BUCKET_URI = "/{Key+}";
private final S3RemoveBucketFromUriProcessor processor = new S3RemoveBucketFromUriProcessor();
@Test
public void preprocess_serviceNotS3_doesNotModifyUri() {
ServiceModel nonS3 = createServiceModel("NonS3");
processor.preprocess(nonS3);
Map<String, Operation> operations = nonS3.getOperations();
assertThat(operations.get(WITH_BUCKET_URI_OPERATION).getHttp().getRequestUri()).isEqualTo(WITH_BUCKET_URI);
assertThat(operations.get(WITHOUT_BUCKET_URI_OPERATION).getHttp().getRequestUri()).isEqualTo(WITHOUT_BUCKET_URI);
}
@Test
public void preprocess_serviceIsS3_operationHasBucket_modifiesUri() {
ServiceModel s3 = createServiceModel("S3");
processor.preprocess(s3);
Map<String, Operation> operations = s3.getOperations();
assertThat(operations.get(WITH_BUCKET_URI_OPERATION).getHttp().getRequestUri()).isEqualTo("/{Key+}");
}
@Test
public void preprocess_serviceIsS3_operationDoesNotHaveBucket_noModification() {
ServiceModel s3 = createServiceModel("S3");
processor.preprocess(s3);
Map<String, Operation> operations = s3.getOperations();
assertThat(operations.get(WITHOUT_BUCKET_URI_OPERATION).getHttp().getRequestUri()).isEqualTo(WITHOUT_BUCKET_URI);
}
private static ServiceModel createServiceModel(String serviceId) {
ServiceModel model = new ServiceModel();
ServiceMetadata serviceMetadata = new ServiceMetadata();
serviceMetadata.setServiceId(serviceId);
model.setMetadata(serviceMetadata);
Operation operationWithBucketInUri = new Operation()
.withHttp(new Http().withRequestUri(WITH_BUCKET_URI));
Operation operationWithoutBucketInUri = new Operation()
.withHttp(new Http().withRequestUri(WITHOUT_BUCKET_URI));
Map<String, Operation> operations = new HashMap<>();
operations.put(WITH_BUCKET_URI_OPERATION, operationWithBucketInUri);
operations.put(WITHOUT_BUCKET_URI_OPERATION, operationWithoutBucketInUri);
model.setOperations(operations);
return model;
}
}
| 3,561 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization/processors/S3ControlRemoveAccountIdHostPrefixProcessorTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.customization.processors;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import software.amazon.awssdk.codegen.model.service.EndpointTrait;
import software.amazon.awssdk.codegen.model.service.Operation;
import software.amazon.awssdk.codegen.model.service.ServiceMetadata;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
public class S3ControlRemoveAccountIdHostPrefixProcessorTest {
private static final String WITH_ACCOUNT_ID_PREFIX = "WithBucketInUri";
private static final String WITHOUT_ACCOUNT_ID_PREFIX = "WithoutBucketInUri";
private static final String ACCOUNT_ID_PREFIX = "{AccountId}.";
private final S3ControlRemoveAccountIdHostPrefixProcessor processor = new S3ControlRemoveAccountIdHostPrefixProcessor();
@Test
public void preprocess_serviceNotS3Control_doesNotModify() {
ServiceModel nonS3 = createServiceModel("NonS3Control");
processor.preprocess(nonS3);
Map<String, Operation> operations = nonS3.getOperations();
assertThat(operations.get(WITH_ACCOUNT_ID_PREFIX).getEndpoint().getHostPrefix()).isEqualTo(ACCOUNT_ID_PREFIX);
assertThat(operations.get(WITHOUT_ACCOUNT_ID_PREFIX).getEndpoint()).isNull();
}
@Test
public void preprocess_serviceIsS3Control_operationAccountIdPrefix_modifiesPrefix() {
ServiceModel s3Control = createServiceModel("S3 Control");
processor.preprocess(s3Control);
Map<String, Operation> operations = s3Control.getOperations();
assertThat(operations.get(WITH_ACCOUNT_ID_PREFIX).getEndpoint().getHostPrefix()).isNull();
}
@Test
public void preprocess_serviceIsS3Control_operationDoesNotAccountIdPrefix_noModification() {
ServiceModel s3Control = createServiceModel("S3 Control");
processor.preprocess(s3Control);
Map<String, Operation> operations = s3Control.getOperations();
assertThat(operations.get(WITHOUT_ACCOUNT_ID_PREFIX).getEndpoint()).isNull();;
}
private static ServiceModel createServiceModel(String serviceId) {
ServiceModel model = new ServiceModel();
ServiceMetadata serviceMetadata = new ServiceMetadata();
serviceMetadata.setServiceId(serviceId);
model.setMetadata(serviceMetadata);
Operation operationWithoutAccountIdPrefix = new Operation();
Operation operationWithAccountIdPrefix = new Operation();
EndpointTrait endpointTrait = new EndpointTrait();
endpointTrait.setHostPrefix(ACCOUNT_ID_PREFIX);
operationWithAccountIdPrefix.setEndpoint(endpointTrait);
Map<String, Operation> operations = new HashMap<>();
operations.put(WITH_ACCOUNT_ID_PREFIX, operationWithAccountIdPrefix);
operations.put(WITHOUT_ACCOUNT_ID_PREFIX, operationWithoutAccountIdPrefix);
model.setOperations(operations);
return model;
}
}
| 3,562 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization/processors/CustomSdkShapesProcessorTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.customization.processors;
import static org.assertj.core.api.Assertions.assertThatNullPointerException;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomSdkShapes;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.service.Member;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.model.service.Shape;
import software.amazon.awssdk.codegen.poet.model.AwsModelSpecTest;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
public class CustomSdkShapesProcessorTest {
CustomizationConfig config;
ServiceModel serviceModel;
@BeforeEach
public void setUp() throws IOException {
File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json").getFile());
File customizationConfigFile = new File(AwsModelSpecTest.class.getResource("customization.config").getFile());
serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile);
config = ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile);
}
@Test
public void setCustomStringShape_isAddedToModel() {
CustomSdkShapes customSdkShapes = config.getCustomSdkShapes();
Map<String, Shape> shapes = new HashMap<>();
shapes.putAll(customSdkShapes.getShapes());
Shape stringShape = new Shape();
stringShape.setType("string");
String shapeName = "StringShape";
shapes.put(shapeName, stringShape);
customSdkShapes.setShapes(shapes);
config.setCustomSdkShapes(customSdkShapes);
new IntermediateModelBuilder(C2jModels.builder()
.serviceModel(serviceModel)
.customizationConfig(config)
.build())
.build();
assertThat(serviceModel.getShapes()).containsKey(shapeName);
assertThat(serviceModel.getShapes()).containsValue(stringShape);
assertThat(serviceModel.getShape(shapeName).getType()).isEqualTo("string");
}
@Test
public void setCustomListShape_isAddedToModel() {
CustomSdkShapes customSdkShapes = config.getCustomSdkShapes();
Map<String, Shape> shapes = new HashMap<>();
shapes.putAll(customSdkShapes.getShapes());
Shape listShape = new Shape();
listShape.setType("list");
Member member = new Member();
String memberName = "Event";
member.setShape(memberName);
listShape.setMember(member);
String shapeName = "ListShape";
shapes.put(shapeName, listShape);
customSdkShapes.setShapes(shapes);
config.setCustomSdkShapes(customSdkShapes);
new IntermediateModelBuilder(C2jModels.builder()
.serviceModel(serviceModel)
.customizationConfig(config)
.build())
.build();
assertThat(serviceModel.getShapes()).containsKey(shapeName);
assertThat(serviceModel.getShapes()).containsValue(listShape);
assertThat(serviceModel.getShape(shapeName).getType()).isEqualTo("list");
assertThat(serviceModel.getShape(shapeName).getListMember()).isEqualTo(member);
assertThat(serviceModel.getShape(shapeName).getListMember().getShape()).isEqualTo("Event");
}
@Test
public void setCustomCustomizedShape_isAddedToModel() {
CustomSdkShapes customSdkShapes = config.getCustomSdkShapes();
Map<String, Shape> shapes = new HashMap<>();
shapes.putAll(customSdkShapes.getShapes());
Shape stringShape = new Shape();
stringShape.setType("string");
String shapeName = "StringShape";
shapes.put(shapeName, stringShape);
Shape customizedShape = new Shape();
customizedShape.setType(shapeName);
String customizedShapeName = "CustomizedShape";
shapes.put(customizedShapeName, customizedShape);
customSdkShapes.setShapes(shapes);
config.setCustomSdkShapes(customSdkShapes);
new IntermediateModelBuilder(C2jModels.builder()
.serviceModel(serviceModel)
.customizationConfig(config)
.build())
.build();
assertThat(serviceModel.getShapes()).containsKey(customizedShapeName);
assertThat(serviceModel.getShapes()).containsValue(customizedShape);
assertThat(serviceModel.getShape(customizedShapeName).getType()).isEqualTo(shapeName);
}
@Test
public void setCustomNullShape_throwsNullPointerException() {
CustomSdkShapes customSdkShapes = config.getCustomSdkShapes();
Map<String, Shape> shapes = new HashMap<>();
shapes.putAll(customSdkShapes.getShapes());
Shape stringShape = new Shape();
stringShape.setType(null);
String shapeName = "NullShape";
shapes.put(shapeName, stringShape);
customSdkShapes.setShapes(shapes);
config.setCustomSdkShapes(customSdkShapes);
assertThatNullPointerException()
.isThrownBy(() -> new IntermediateModelBuilder(C2jModels.builder()
.serviceModel(serviceModel)
.customizationConfig(config)
.build()).
build());
}
}
| 3,563 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/internal/UtilsTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.internal;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
public class UtilsTest {
final Map<String,String> capitalizedToUncapitalized = new HashMap<String,String>() {{
put("A", "a");
put("AB", "ab");
put("ABC", "abc");
put("ABCD", "abcd");
put("AToken", "aToken");
put("MFAToken", "mfaToken");
put("AWSRequest", "awsRequest");
put("MfaToken", "mfaToken");
put("AwsRequest", "awsRequest");
}};
@Test
public void testUnCapitalize() {
capitalizedToUncapitalized.forEach((capitalized,unCapitalized) ->
assertThat(Utils.unCapitalize(capitalized), is(equalTo(unCapitalized))));
}
}
| 3,564 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/internal/DocumentationUtilsTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.internal;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
public class DocumentationUtilsTest {
@Test
public void strip_html_tags_null_or_empty_input_returns_empty_string() {
assertThat(DocumentationUtils.stripHtmlTags(null), Matchers
.isEmptyString());
assertThat(DocumentationUtils.stripHtmlTags(""), Matchers
.isEmptyString());
}
@Test
public void html_tags_at_start_of_string_are_removed() {
assertEquals("foo", DocumentationUtils.stripHtmlTags
("<bar>foo</bar>"));
}
@Test
public void empty_html_tags_at_start_are_removed() {
assertThat(DocumentationUtils.stripHtmlTags("<p></p>"), Matchers
.isEmptyString());
assertThat(DocumentationUtils.stripHtmlTags("<p/>"), Matchers
.isEmptyString());
}
}
| 3,565 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/PoetCollectorsTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet;
import static org.assertj.core.api.Assertions.assertThat;
import com.squareup.javapoet.CodeBlock;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
/**
* Validate functionality of the {@link PoetCollectors}.
*/
public class PoetCollectorsTest {
@Test
public void emptyCollectIsEmptyCodeBlock() {
CodeBlock result = Stream.<CodeBlock>of().collect(PoetCollectors.toCodeBlock());
assertThat(result).isEqualTo(CodeBlock.builder().build());
}
@Test
public void emptyDelimitedCollectIsEmptyCodeBlock() {
CodeBlock result = Stream.<CodeBlock>of().collect(PoetCollectors.toDelimitedCodeBlock(","));
assertThat(result).isEqualTo(CodeBlock.builder().build());
}
@Test
public void codeBlocksJoined() {
CodeBlock a = CodeBlock.of("a");
CodeBlock b = CodeBlock.of("b");
CodeBlock ab = CodeBlock.builder().add(a).add(b).build();
CodeBlock result = Stream.of(a, b).collect(PoetCollectors.toCodeBlock());
assertThat(result).isEqualTo(ab);
}
@Test
public void delimitedCodeBlocksJoined() {
CodeBlock a = CodeBlock.of("a");
CodeBlock b = CodeBlock.of("b");
CodeBlock delimeter = CodeBlock.of(",");
CodeBlock ab = CodeBlock.builder().add(a).add(delimeter).add(b).build();
CodeBlock result = Stream.of(a, b).collect(PoetCollectors.toDelimitedCodeBlock(","));
assertThat(result).isEqualTo(ab);
}
}
| 3,566 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/PoetMatchers.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalToIgnoringWhiteSpace;
import static software.amazon.awssdk.codegen.poet.PoetUtils.buildJavaFile;
import java.io.IOException;
import java.io.InputStream;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.junit.ComparisonFailure;
import software.amazon.awssdk.codegen.emitters.CodeTransformer;
import software.amazon.awssdk.codegen.emitters.JavaCodeFormatter;
import software.amazon.awssdk.utils.IoUtils;
import software.amazon.awssdk.utils.Validate;
public final class PoetMatchers {
private static final CodeTransformer processor = CodeTransformer.chain(new CopyrightRemover(),
new JavaCodeFormatter());
private static final CodeTransformer formattingDisabledProcessor = CodeTransformer.chain(new CopyrightRemover());
public static Matcher<ClassSpec> generatesTo(String expectedTestFile, boolean disableFormatting) {
return new TypeSafeMatcher<ClassSpec>() {
@Override
protected boolean matchesSafely(ClassSpec spec) {
String expectedClass = getExpectedClass(spec, expectedTestFile, disableFormatting);
String actualClass = generateClass(spec);
try {
assertThat(actualClass, equalToIgnoringWhiteSpace(expectedClass));
} catch (AssertionError e) {
//Unfortunately for string comparisons Hamcrest doesn't really give us a nice diff. On the other hand
//IDEs know how to nicely display JUnit's ComparisonFailure - makes debugging tests much easier
throw new ComparisonFailure(String.format("Output class does not match expected [test-file: %s]", expectedTestFile), expectedClass, actualClass);
}
return true;
}
@Override
public void describeTo(Description description) {
//Since we bubble an exception this will never actually get called
}
};
}
public static Matcher<ClassSpec> generatesTo(String expectedTestFile) {
return new TypeSafeMatcher<ClassSpec>() {
@Override
protected boolean matchesSafely(ClassSpec spec) {
String expectedClass = getExpectedClass(spec, expectedTestFile, false);
String actualClass = generateClass(spec);
try {
assertThat(actualClass, equalToIgnoringWhiteSpace(expectedClass));
} catch (AssertionError e) {
//Unfortunately for string comparisons Hamcrest doesn't really give us a nice diff. On the other hand
//IDEs know how to nicely display JUnit's ComparisonFailure - makes debugging tests much easier
throw new ComparisonFailure(String.format("Output class does not match expected [test-file: %s]", expectedTestFile), expectedClass, actualClass);
}
return true;
}
@Override
public void describeTo(Description description) {
//Since we bubble an exception this will never actually get called
}
};
}
private static String getExpectedClass(ClassSpec spec, String testFile, boolean disableFormatting) {
try {
InputStream resource = spec.getClass().getResourceAsStream(testFile);
Validate.notNull(resource, "Failed to load test file " + testFile + " with " + spec.getClass());
if (disableFormatting) {
return formattingDisabledProcessor.apply(IoUtils.toUtf8String(resource));
}
return processor.apply(IoUtils.toUtf8String(resource));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static String generateClass(ClassSpec spec) {
StringBuilder output = new StringBuilder();
try {
buildJavaFile(spec).writeTo(output);
} catch (IOException e) {
throw new RuntimeException("Failed to generate class", e);
}
return processor.apply(output.toString());
}
private static class CopyrightRemover implements CodeTransformer {
@Override
public String apply(String input) {
return input.substring(input.indexOf("package"));
}
}
}
| 3,567 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/ClientTestModels.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet;
import java.io.File;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.rules.endpoints.EndpointTestSuiteModel;
import software.amazon.awssdk.codegen.model.service.EndpointRuleSetModel;
import software.amazon.awssdk.codegen.model.service.Paginators;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.model.service.Waiters;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
/**
* A static set of service models that can be used for testing purposes.
*/
public class ClientTestModels {
private ClientTestModels() {}
public static IntermediateModel awsJsonServiceModels() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/json/service-2.json").getFile());
File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/json/customization.config").getFile());
File paginatorsModel = new File(ClientTestModels.class.getResource("client/c2j/json/paginators.json").getFile());
C2jModels models = C2jModels.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.paginatorsModel(getPaginatorsModel(paginatorsModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel awsQueryCompatibleJsonServiceModels() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/query-to-json-errorcode/service-2.json").getFile());
File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/query-to-json-errorcode/customization.config").getFile());
File paginatorsModel = new File(ClientTestModels.class.getResource("client/c2j/query-to-json-errorcode/paginators.json").getFile());
C2jModels models = C2jModels.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.paginatorsModel(getPaginatorsModel(paginatorsModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel bearerAuthServiceModels() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/json-bearer-auth/service-2.json").getFile());
File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/json-bearer-auth/customization.config").getFile());
File paginatorsModel = new File(ClientTestModels.class.getResource("client/c2j/json-bearer-auth/paginators.json").getFile());
C2jModels models = C2jModels.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.paginatorsModel(getPaginatorsModel(paginatorsModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel restJsonServiceModels() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/rest-json/service-2.json").getFile());
File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/rest-json/customization.config").getFile());
File paginatorsModel = new File(ClientTestModels.class.getResource("client/c2j/rest-json/paginators.json").getFile());
C2jModels models = C2jModels.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.paginatorsModel(getPaginatorsModel(paginatorsModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel queryServiceModels() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/query/service-2.json").getFile());
File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/query/customization.config").getFile());
File waitersModel = new File(ClientTestModels.class.getResource("client/c2j/query/waiters-2.json").getFile());
File endpointRuleSetModel =
new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-rule-set.json").getFile());
File endpointTestsModel =
new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-tests.json").getFile());
C2jModels models = C2jModels
.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.waitersModel(getWaiters(waitersModel))
.endpointRuleSetModel(getEndpointRuleSet(endpointRuleSetModel))
.endpointTestSuiteModel(getEndpointTestSuite(endpointTestsModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel queryServiceModelsEndpointAuthParamsWithAllowList() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/query/service-2.json").getFile());
File customizationModel =
new File(ClientTestModels.class.getResource("client/c2j/query/customization-endpoint-auth-params-with-allowed.config")
.getFile());
File waitersModel = new File(ClientTestModels.class.getResource("client/c2j/query/waiters-2.json").getFile());
File endpointRuleSetModel =
new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-rule-set.json").getFile());
File endpointTestsModel =
new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-tests.json").getFile());
C2jModels models = C2jModels
.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.waitersModel(getWaiters(waitersModel))
.endpointRuleSetModel(getEndpointRuleSet(endpointRuleSetModel))
.endpointTestSuiteModel(getEndpointTestSuite(endpointTestsModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel queryServiceModelsEndpointAuthParamsWithoutAllowList() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/query/service-2.json").getFile());
File customizationModel =
new File(ClientTestModels.class.getResource("client/c2j/query/customization-endpoint-auth-params-without-allowed"
+ ".config")
.getFile());
File waitersModel = new File(ClientTestModels.class.getResource("client/c2j/query/waiters-2.json").getFile());
File endpointRuleSetModel =
new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-rule-set.json").getFile());
File endpointTestsModel =
new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-tests.json").getFile());
C2jModels models = C2jModels
.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.waitersModel(getWaiters(waitersModel))
.endpointRuleSetModel(getEndpointRuleSet(endpointRuleSetModel))
.endpointTestSuiteModel(getEndpointTestSuite(endpointTestsModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel granularAuthProvidersServiceModels() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/fine-grained-auth/service-2.json").getFile());
File customizationModel =
new File(ClientTestModels.class.getResource("client/c2j/fine-grained-auth/customization.config")
.getFile());
C2jModels models = C2jModels
.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel granularAuthWithLegacyTraitServiceModels() {
File serviceModel =
new File(ClientTestModels.class.getResource("client/c2j/fine-grained-auth-legacy-trait/service-2.json").getFile());
File customizationModel =
new File(ClientTestModels.class.getResource("client/c2j/fine-grained-auth-legacy-trait/customization.config")
.getFile());
C2jModels models = C2jModels
.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel allOperationsWithAuthSameValueServiceModels() {
File serviceModel =
new File(ClientTestModels.class.getResource("client/c2j/all-ops-with-auth-same-value/service-2.json").getFile());
File customizationModel =
new File(ClientTestModels.class.getResource("client/c2j/all-ops-with-auth-same-value/customization.config")
.getFile());
C2jModels models = C2jModels
.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel allOperationsWithAuthDifferentValueServiceModels() {
File serviceModel =
new File(ClientTestModels.class.getResource("client/c2j/all-ops-with-auth-different-value/service-2.json").getFile());
File customizationModel =
new File(ClientTestModels.class.getResource("client/c2j/all-ops-with-auth-different-value/customization.config")
.getFile());
C2jModels models = C2jModels
.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel operationWithNoAuth() {
File serviceModel =
new File(ClientTestModels.class.getResource("client/c2j/ops-with-no-auth/service-2.json").getFile());
File customizationModel =
new File(ClientTestModels.class.getResource("client/c2j/ops-with-no-auth/customization.config")
.getFile());
C2jModels models = C2jModels
.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel serviceWithNoAuth() {
File serviceModel =
new File(ClientTestModels.class.getResource("client/c2j/service-with-no-auth/service-2.json").getFile());
File customizationModel =
new File(ClientTestModels.class.getResource("client/c2j/service-with-no-auth/customization.config")
.getFile());
C2jModels models = C2jModels
.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel serviceMiniS3() {
File serviceModel =
new File(ClientTestModels.class.getResource("client/c2j/mini-s3/service-2.json").getFile());
File customizationModel =
new File(ClientTestModels.class.getResource("client/c2j/mini-s3/customization.config")
.getFile());
C2jModels models = C2jModels
.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel xmlServiceModels() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/xml/service-2.json").getFile());
File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/xml/customization.config").getFile());
C2jModels models = C2jModels
.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel endpointDiscoveryModels() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/endpointdiscovery/service-2.json").getFile());
File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/endpointdiscovery/customization.config").getFile());
C2jModels models = C2jModels.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel customContentTypeModels() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/customservicemetadata/service-2.json").getFile());
File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/customservicemetadata/customization.config").getFile());
C2jModels models = C2jModels.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel composedClientJsonServiceModels() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/rest-json/service-2.json").getFile());
File customizationModel =
new File(ClientTestModels.class.getResource("client/c2j/composedclient/customization.config").getFile());
CustomizationConfig customizationConfig = getCustomizationConfig(customizationModel);
C2jModels models = C2jModels.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(customizationConfig)
.build();
return new IntermediateModelBuilder(models).build();
}
public static IntermediateModel internalConfigModels() {
File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/internalconfig/service-2.json").getFile());
File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/internalconfig/customization.config").getFile());
C2jModels models = C2jModels.builder()
.serviceModel(getServiceModel(serviceModel))
.customizationConfig(getCustomizationConfig(customizationModel))
.build();
return new IntermediateModelBuilder(models).build();
}
private static ServiceModel getServiceModel(File file) {
return ModelLoaderUtils.loadModel(ServiceModel.class, file);
}
private static CustomizationConfig getCustomizationConfig(File file) {
return ModelLoaderUtils.loadModel(CustomizationConfig.class, file);
}
private static Waiters getWaiters(File file) {
return ModelLoaderUtils.loadModel(Waiters.class, file);
}
private static EndpointRuleSetModel getEndpointRuleSet(File file) {
return ModelLoaderUtils.loadModel(EndpointRuleSetModel.class, file);
}
private static EndpointTestSuiteModel getEndpointTestSuite(File file) {
return ModelLoaderUtils.loadModel(EndpointTestSuiteModel.class, file);
}
private static Paginators getPaginatorsModel(File file) {
return ModelLoaderUtils.loadModel(Paginators.class, file);
}
}
| 3,568 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/eventstream/EventStreamFunctionalTests.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.eventstream;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import java.util.function.BiFunction;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.emitters.GeneratorTaskParams;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.OperationModel;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.ClientTestModels;
public class EventStreamFunctionalTests {
@Test
public void visitorBuilder() throws Exception {
runTest(EventStreamVisitorBuilderImplSpec::new, "test-visitor-builder.java");
}
@Test
public void responseHandler() throws Exception {
runTest(EventStreamResponseHandlerSpec::new, "test-response-handler.java");
}
@Test
public void responseHandlerBuilder() throws Exception {
runTest(EventStreamResponseHandlerBuilderImplSpec::new, "test-response-handler-builder.java");
}
private void runTest(BiFunction<GeneratorTaskParams, OperationModel, ClassSpec> specFactory,
String expectedTestFile) {
IntermediateModel model = ClientTestModels.restJsonServiceModels();
GeneratorTaskParams dependencies = GeneratorTaskParams.create(model, "sources/", "tests/", "resources/");
ClassSpec classSpec = specFactory.apply(dependencies, model.getOperation("EventStreamOperation"));
assertThat(classSpec, generatesTo(expectedTestFile));
}
}
| 3,569 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/eventstream/EventModelSpecTest.java | package software.amazon.awssdk.codegen.poet.eventstream;
import static java.util.stream.Collectors.toList;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Locale;
import java.util.Objects;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.customization.processors.UseLegacyEventGenerationSchemeProcessorTest;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.MemberModel;
import software.amazon.awssdk.codegen.model.intermediate.OperationModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.poet.model.AwsModelSpecTest;
import software.amazon.awssdk.codegen.poet.model.EventModelSpec;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
@RunWith(Parameterized.class)
public class EventModelSpecTest {
private static IntermediateModel intermediateModel;
private final MemberModel event;
private final ShapeModel eventStream;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() {
invokeSafely(EventModelSpecTest::setUp);
return intermediateModel.getShapes().values().stream()
.filter(ShapeModel::isEventStream)
.flatMap(eventStream -> eventStream.getMembers().stream()
.filter(m -> m.getShape().isEvent())
.map(e -> new Object[]{e, eventStream}))
.collect(toList());
}
public EventModelSpecTest(MemberModel event, ShapeModel eventStream) {
this.event = event;
this.eventStream = eventStream;
}
@Test
public void basicGeneration() {
assertThat(new EventModelSpec(event, eventStream, intermediateModel), generatesTo(referenceFileForShape()));
}
private String referenceFileForShape() {
String className = "Default" + intermediateModel.getNamingStrategy().getShapeClassName(event.getName());
String fileName = className.toLowerCase(Locale.ENGLISH) + ".java";
return "/software/amazon/awssdk/codegen/poet/eventstream/" + fileName;
}
private static void setUp() {
File serviceModelFile = new File(EventModelSpecTest.class.getResource("service-2.json").getFile());
ServiceModel serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile);
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(serviceModel)
.customizationConfig(loadCustomizationConfig("customization.config"))
.build())
.build();
}
private static CustomizationConfig loadCustomizationConfig(String configName) {
String c2jFilePath = EventModelSpecTest.class.getResource(configName).getFile();
File file = new File(c2jFilePath);
return ModelLoaderUtils.loadModel(CustomizationConfig.class, file);
}
}
| 3,570 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/paginators/PaginatedResponseClassSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.paginators;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.service.PaginatorDefinition;
import software.amazon.awssdk.codegen.model.service.Paginators;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.paginators.customizations.SameTokenAsyncResponseClassSpec;
import software.amazon.awssdk.codegen.poet.paginators.customizations.SameTokenSyncResponseClassSpec;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
public class PaginatedResponseClassSpecTest {
private static final String SAME_TOKEN_CUSTOMIZATION = "LastPageHasPreviousToken";
private static IntermediateModel intermediateModel;
private static Paginators paginators;
private static Map<String, String> paginationCustomization;
@BeforeAll
public static void setUp() throws IOException {
File serviceModelFile = new File(PaginatedResponseClassSpecTest.class.getResource("service-2.json").getFile());
File customizationConfigFile = new File(PaginatedResponseClassSpecTest.class.getResource("customization.config")
.getFile());
File paginatorsModel = new File(PaginatedResponseClassSpecTest.class.getResource("paginators.json")
.getFile());
paginators = getPaginatorsModel(paginatorsModel);
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile))
.customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile))
.paginatorsModel(paginators)
.build())
.build();
paginationCustomization = intermediateModel.getCustomizationConfig().getPaginationCustomization();
}
private static Paginators getPaginatorsModel(File file) {
return ModelLoaderUtils.loadModel(Paginators.class, file);
}
@Test
public void testGeneratedResponseForSyncOperations() {
paginators.getPagination().entrySet()
.stream()
.filter(entry -> entry.getValue().isValid())
.forEach(entry ->
{
ClassSpec classSpec = getSyncResponseSpec(entry);
assertThat(classSpec, generatesTo(classSpec.className().simpleName() + ".java"));
});
}
@Test
public void testGeneratedResponseForAsyncOperations() {
paginators.getPagination().entrySet()
.stream()
.filter(entry -> entry.getValue().isValid())
.forEach(entry ->
{
ClassSpec classSpec = getAsyncResponseSpec(entry);
assertThat(classSpec, generatesTo(classSpec.className().simpleName() + ".java"));
});
}
private ClassSpec getSyncResponseSpec(Map.Entry<String, PaginatorDefinition> entry) {
ClassSpec classSpec = new SyncResponseClassSpec(intermediateModel,
entry.getKey(),
entry.getValue());
if (paginationCustomization != null && paginationCustomization.containsKey(entry.getKey())) {
String customvalue = paginationCustomization.get(entry.getKey());
switch (customvalue) {
case SAME_TOKEN_CUSTOMIZATION:
classSpec = new SameTokenSyncResponseClassSpec(intermediateModel,
entry.getKey(),
entry.getValue());
break;
default:
throw new IllegalArgumentException("Unknown paginationCustomization value: " + customvalue);
}
}
return classSpec;
}
private ClassSpec getAsyncResponseSpec(Map.Entry<String, PaginatorDefinition> entry) {
ClassSpec classSpec = new AsyncResponseClassSpec(intermediateModel,
entry.getKey(),
entry.getValue());
if (paginationCustomization != null && paginationCustomization.containsKey(entry.getKey())) {
String customvalue = paginationCustomization.get(entry.getKey());
switch (customvalue) {
case SAME_TOKEN_CUSTOMIZATION:
classSpec = new SameTokenAsyncResponseClassSpec(intermediateModel,
entry.getKey(),
entry.getValue());
break;
default:
throw new IllegalArgumentException("Unknown paginationCustomization value: " + customvalue);
}
}
return classSpec;
}
}
| 3,571 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/auth | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/auth/scheme/AuthSchemeSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.auth.scheme;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.ClientTestModels;
public class AuthSchemeSpecTest {
@ParameterizedTest
@MethodSource("parameters")
void testCase(TestCase testCase) {
ClassSpec classSpec = testCase.classSpecProvider.apply(testCase.modelProvider.get());
String expectedFileName = testCase.caseName + "-auth-scheme-" + testCase.outputFileSuffix + ".java";
assertThat("Generated class must match " + expectedFileName,
classSpec, generatesTo(expectedFileName));
}
static List<TestCase> parameters() {
return Arrays.asList(
// query
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModels)
.classSpecProvider(AuthSchemeProviderSpec::new)
.caseName("query")
.outputFileSuffix("provider")
.build(),
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModels)
.classSpecProvider(AuthSchemeParamsSpec::new)
.caseName("query")
.outputFileSuffix("params")
.build(),
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModels)
.classSpecProvider(ModelBasedAuthSchemeProviderSpec::new)
.caseName("query")
.outputFileSuffix("default-provider")
.build(),
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModels)
.classSpecProvider(DefaultAuthSchemeParamsSpec::new)
.caseName("query")
.outputFileSuffix("default-params")
.build(),
// query-endpoint-auth-params
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList)
.classSpecProvider(AuthSchemeProviderSpec::new)
.caseName("query-endpoint-auth-params")
.outputFileSuffix("provider")
.build(),
// Endpoint based AuthScheme provider WITH allow list
// - Endpoint Provider
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList)
.classSpecProvider(EndpointBasedAuthSchemeProviderSpec::new)
.caseName("query-endpoint-auth-params")
.outputFileSuffix("endpoint-provider")
.build(),
// - Modeled provider
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList)
.classSpecProvider(ModelBasedAuthSchemeProviderSpec::new)
.caseName("query-endpoint-auth-params")
.outputFileSuffix("modeled-provider")
.build(),
// Endpoint based AuthScheme provider WITHOUT allow list
// - Endpoint Provider
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithoutAllowList)
.classSpecProvider(EndpointBasedAuthSchemeProviderSpec::new)
.caseName("query-endpoint-auth-params")
.outputFileSuffix("endpoint-provider-without-allowlist")
.build(),
// Auth scheme params from endpoint WITH allow list, MUST include ONLY the params in the allow list.
// - Interface
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList)
.classSpecProvider(AuthSchemeParamsSpec::new)
.caseName("query-endpoint-auth-params")
.outputFileSuffix("params-with-allowlist")
.build(),
// - Implementation
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList)
.classSpecProvider(DefaultAuthSchemeParamsSpec::new)
.caseName("query-endpoint-auth-params")
.outputFileSuffix("default-params-with-allowlist")
.build(),
// Auth scheme params from endpoint WITHOUT allow list, it MUST include all the endpoint params except for the
// default params.
// - Interface
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithoutAllowList)
.classSpecProvider(AuthSchemeParamsSpec::new)
.caseName("query-endpoint-auth-params")
.outputFileSuffix("params-without-allowlist")
.build(),
// - Implementation
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithoutAllowList)
.classSpecProvider(DefaultAuthSchemeParamsSpec::new)
.caseName("query-endpoint-auth-params")
.outputFileSuffix("default-params-without-allowlist")
.build(),
// Granular auth
TestCase.builder()
.modelProvider(ClientTestModels::granularAuthProvidersServiceModels)
.classSpecProvider(ModelBasedAuthSchemeProviderSpec::new)
.caseName("granular")
.outputFileSuffix("default-provider")
.build(),
// All operations with auth with the same values
TestCase.builder()
.modelProvider(ClientTestModels::allOperationsWithAuthSameValueServiceModels)
.classSpecProvider(ModelBasedAuthSchemeProviderSpec::new)
.caseName("all-ops-auth-same-value")
.outputFileSuffix("default-provider")
.build(),
// All operations with auth with different values
TestCase.builder()
.modelProvider(ClientTestModels::allOperationsWithAuthDifferentValueServiceModels)
.classSpecProvider(ModelBasedAuthSchemeProviderSpec::new)
.caseName("all-ops-auth-different-value")
.outputFileSuffix("default-provider")
.build(),
// Service with operations with auth none
TestCase.builder()
.modelProvider(ClientTestModels::operationWithNoAuth)
.classSpecProvider(ModelBasedAuthSchemeProviderSpec::new)
.caseName("ops-with-no-auth")
.outputFileSuffix("default-provider")
.build(),
// Service with signature version with the same value as S3
TestCase.builder()
.modelProvider(ClientTestModels::serviceMiniS3)
.classSpecProvider(ModelBasedAuthSchemeProviderSpec::new)
.caseName("mini-s3")
.outputFileSuffix("default-provider")
.build(),
TestCase.builder()
.modelProvider(ClientTestModels::granularAuthWithLegacyTraitServiceModels)
.classSpecProvider(ModelBasedAuthSchemeProviderSpec::new)
.caseName("auth-with-legacy-trait")
.outputFileSuffix("default-provider")
.build(),
// Interceptors
// - Normal case
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModels)
.classSpecProvider(AuthSchemeInterceptorSpec::new)
.caseName("query")
.outputFileSuffix("interceptor")
.build(),
// - Endpoints based params with allow list
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList)
.classSpecProvider(AuthSchemeInterceptorSpec::new)
.caseName("query-endpoint-auth-params-with-allowlist")
.outputFileSuffix("interceptor")
.build(),
// - Endpoints based params without allow list
TestCase.builder()
.modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithoutAllowList)
.classSpecProvider(AuthSchemeInterceptorSpec::new)
.caseName("query-endpoint-auth-params-without-allowlist")
.outputFileSuffix("interceptor")
.build()
);
}
static class TestCase {
private final Supplier<IntermediateModel> modelProvider;
private final Function<IntermediateModel, ClassSpec> classSpecProvider;
private final String outputFileSuffix;
private final String caseName;
TestCase(Builder builder) {
this.modelProvider = builder.modelProvider;
this.classSpecProvider = builder.classSpecProvider;
this.outputFileSuffix = builder.outputFileSuffix;
this.caseName = builder.caseName;
}
static Builder builder() {
return new Builder();
}
static class Builder {
private Supplier<IntermediateModel> modelProvider;
private Function<IntermediateModel, ClassSpec> classSpecProvider;
private String outputFileSuffix;
private String caseName;
Builder modelProvider(Supplier<IntermediateModel> modelProvider) {
this.modelProvider = modelProvider;
return this;
}
Builder classSpecProvider(Function<IntermediateModel, ClassSpec> classSpecProvider) {
this.classSpecProvider = classSpecProvider;
return this;
}
Builder outputFileSuffix(String outputFileSuffix) {
this.outputFileSuffix = outputFileSuffix;
return this;
}
Builder caseName(String caseName) {
this.caseName = caseName;
return this;
}
TestCase build() {
return new TestCase(this);
}
}
}
}
| 3,572 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/endpointdiscovery/EndpointDiscoveryCacheLoaderGeneratorTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.endpointdiscovery;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.emitters.GeneratorTaskParams;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.poet.ClientTestModels;
public class EndpointDiscoveryCacheLoaderGeneratorTest {
@Test
public void syncEndpointDiscoveryCacheLoaderGenerator() {
IntermediateModel model = ClientTestModels.endpointDiscoveryModels();
GeneratorTaskParams dependencies = GeneratorTaskParams.create(model, "sources/", "tests/", "resources/");
EndpointDiscoveryCacheLoaderGenerator cacheLoader = new EndpointDiscoveryCacheLoaderGenerator(dependencies);
assertThat(cacheLoader, generatesTo("test-sync-cache-loader.java"));
}
@Test
public void asyncEndpointDiscoveryCacheLoaderGenerator() {
IntermediateModel model = ClientTestModels.endpointDiscoveryModels();
GeneratorTaskParams dependencies = GeneratorTaskParams.create(model, "sources/", "tests/", "resources/");
EndpointDiscoveryAsyncCacheLoaderGenerator cacheLoader = new EndpointDiscoveryAsyncCacheLoaderGenerator(dependencies);
assertThat(cacheLoader, generatesTo("test-async-cache-loader.java"));
}
}
| 3,573 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/waiters/WaitersClassSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.waiters;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.ClientTestModels;
public class WaitersClassSpecTest {
@Test
public void asyncWaiterInterface() throws Exception {
ClassSpec asyncWaiterInterfaceSpec = new AsyncWaiterInterfaceSpec(ClientTestModels.queryServiceModels());
assertThat(asyncWaiterInterfaceSpec, generatesTo("query-async-waiter-interface.java"));
}
@Test
public void syncWaiterInterface() throws Exception {
ClassSpec waiterInterface = new WaiterInterfaceSpec(ClientTestModels.queryServiceModels());
assertThat(waiterInterface, generatesTo("query-sync-waiter-interface.java"));
}
@Test
public void asyncWaiterImpl() throws Exception {
ClassSpec asyncWaiterInterfaceSpec = new AsyncWaiterClassSpec(ClientTestModels.queryServiceModels());
assertThat(asyncWaiterInterfaceSpec, generatesTo("query-async-waiter-class.java"));
}
@Test
public void syncWaiterImpl() throws Exception {
ClassSpec waiterInterface = new WaiterClassSpec(ClientTestModels.queryServiceModels());
assertThat(waiterInterface, generatesTo("query-sync-waiter-class.java"));
}
}
| 3,574 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/waiters/JmesPathAcceptorGeneratorTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.waiters;
import static org.assertj.core.api.Assertions.assertThat;
import com.squareup.javapoet.ClassName;
import org.junit.Before;
import org.junit.Test;
public class JmesPathAcceptorGeneratorTest {
private JmesPathAcceptorGenerator acceptorGenerator;
@Before
public void setup() {
acceptorGenerator = new JmesPathAcceptorGenerator(ClassName.get("software.amazon.awssdk.codegen", "WaitersRuntime"));
}
@Test
public void testAutoScalingComplexExpression() {
testConversion("contains(AutoScalingGroups[].[length(Instances[?LifecycleState=='InService']) >= MinSize][], `false`)",
"input.field(\"AutoScalingGroups\").flatten().multiSelectList(x0 -> x0.field(\"Instances\").filter(x1 -> "
+ "x1.field(\"LifecycleState\").compare(\"==\", x1.constant(\"InService\"))).length().compare(\">=\", "
+ "x0.field(\"MinSize\"))).flatten().contains(input.constant(false))");
}
@Test
public void testEcsComplexExpression() {
testConversion("length(services[?!(length(deployments) == `1` && runningCount == desiredCount)]) == `0`",
"input.field(\"services\").filter(x0 -> x0.constant(x0.field(\"deployments\").length().compare(\"==\", "
+ "x0.constant(1)).and(x0.field(\"runningCount\").compare(\"==\", x0.field(\"desiredCount\"))).not()))"
+ ".length().compare(\"==\", input.constant(0))");
}
@Test
public void testSubExpressionWithIdentifier() {
testConversion("foo.bar", "input.field(\"foo\").field(\"bar\")");
}
@Test
public void testSubExpressionWithMultiSelectList() {
testConversion("foo.[bar]", "input.field(\"foo\").multiSelectList(x0 -> x0.field(\"bar\"))");
}
@Test(expected = UnsupportedOperationException.class)
public void testSubExpressionWithMultiSelectHash() {
testConversion("foo.{bar : baz}", "");
}
@Test
public void testSubExpressionWithFunction() {
testConversion("length(foo)", "input.field(\"foo\").length()");
}
@Test
public void testSubExpressionWithStar() {
testConversion("foo.*", "input.field(\"foo\").wildcard()");
}
@Test(expected = UnsupportedOperationException.class)
public void testPipeExpression() {
testConversion("foo | bar", "");
}
@Test
public void testOrExpression() {
testConversion("foo || bar", "input.field(\"foo\").or(input.field(\"bar\"))");
}
@Test
public void testAndExpression() {
testConversion("foo && bar", "input.field(\"foo\").and(input.field(\"bar\"))");
}
@Test
public void testNotExpression() {
testConversion("!foo", "input.constant(input.field(\"foo\").not())");
}
@Test
public void testParenExpression() {
testConversion("(foo)", "input.field(\"foo\")");
}
@Test
public void testWildcardExpression() {
testConversion("*", "input.wildcard()");
}
@Test
public void testIndexedExpressionWithoutLeftExpressionWithoutContents() {
testConversion("[]", "input.flatten()");
}
@Test
public void testIndexedExpressionWithoutLeftExpressionWithNumberContents() {
testConversion("[10]", "input.index(10)");
}
@Test(expected = UnsupportedOperationException.class)
public void testIndexedExpressionWithoutLeftExpressionWithStarContents() {
testConversion("[*]", "");
}
@Test
public void testIndexedExpressionWithoutLeftExpressionWithQuestionMark() {
testConversion("[?foo]", "input.filter(x0 -> x0.field(\"foo\"))");
}
@Test
public void testIndexedExpressionWithLeftExpressionWithoutContents() {
testConversion("foo[]", "input.field(\"foo\").flatten()");
}
@Test
public void testIndexedExpressionWithLeftExpressionWithContents() {
testConversion("foo[10]", "input.field(\"foo\").index(10)");
}
@Test(expected = UnsupportedOperationException.class)
public void testIndexedExpressionWithLeftExpressionWithStarContents() {
testConversion("foo[*]", "");
}
@Test
public void testIndexedExpressionWithLeftExpressionWithQuestionMark() {
testConversion("foo[?bar]", "input.field(\"foo\").filter(x0 -> x0.field(\"bar\"))");
}
@Test
public void testMultiSelectList2() {
testConversion("[foo, bar]", "input.multiSelectList(x0 -> x0.field(\"foo\"), x1 -> x1.field(\"bar\"))");
}
@Test
public void testMultiSelectList3() {
testConversion("[foo, bar, baz]",
"input.multiSelectList(x0 -> x0.field(\"foo\"), x1 -> x1.field(\"bar\"), x2 -> x2.field(\"baz\"))");
}
@Test
public void testNestedMultiSelectListsRight() {
testConversion("[foo, [bar, baz]]",
"input.multiSelectList(x0 -> x0.field(\"foo\"), "
+ "x1 -> x1.multiSelectList(x2 -> x2.field(\"bar\"), x3 -> x3.field(\"baz\")))");
}
@Test
public void testNestedMultiSelectListsCenter() {
testConversion("[foo, [bar, baz], bam]",
"input.multiSelectList(x0 -> x0.field(\"foo\"), "
+ "x1 -> x1.multiSelectList(x2 -> x2.field(\"bar\"), x3 -> x3.field(\"baz\")), "
+ "x4 -> x4.field(\"bam\"))");
}
@Test
public void testNestedMultiSelectListsLeft() {
testConversion("[[foo, bar], baz]", "input.multiSelectList(x0 -> x0.multiSelectList(x1 -> x1.field(\"foo\"), "
+ "x2 -> x2.field(\"bar\")), "
+ "x3 -> x3.field(\"baz\"))");
}
@Test(expected = UnsupportedOperationException.class)
public void testMultiSelectHash2() {
testConversion("{fooK : fooV, barK : barV}", "");
}
@Test(expected = UnsupportedOperationException.class)
public void testMultiSelectHash3() {
testConversion("{fooK : fooV, barK : barV, bazK : bazV}", "");
}
@Test
public void testComparatorExpressionLT() {
testConversion("foo < bar", "input.field(\"foo\").compare(\"<\", input.field(\"bar\"))");
}
@Test
public void testComparatorExpressionGT() {
testConversion("foo > bar", "input.field(\"foo\").compare(\">\", input.field(\"bar\"))");
}
@Test
public void testComparatorExpressionLTE() {
testConversion("foo <= bar", "input.field(\"foo\").compare(\"<=\", input.field(\"bar\"))");
}
@Test
public void testComparatorExpressionGTE() {
testConversion("foo >= bar", "input.field(\"foo\").compare(\">=\", input.field(\"bar\"))");
}
@Test
public void testComparatorExpressionEQ() {
testConversion("foo == bar", "input.field(\"foo\").compare(\"==\", input.field(\"bar\"))");
}
@Test
public void testComparatorExpressionNEQ() {
testConversion("foo != bar", "input.field(\"foo\").compare(\"!=\", input.field(\"bar\"))");
}
@Test(expected = UnsupportedOperationException.class)
public void testSliceExpressionWithNoNumbers2() {
testConversion("[:]", "");
}
@Test(expected = UnsupportedOperationException.class)
public void testSliceExpressionWithNoNumbers3() {
testConversion("[::]", "");
}
@Test(expected = UnsupportedOperationException.class)
public void testSliceExpressionWithStartNumber2() {
testConversion("[10:]", "");
}
@Test(expected = UnsupportedOperationException.class)
public void testSliceExpressionWithStopNumber2() {
testConversion("[:10]", "");
}
@Test(expected = UnsupportedOperationException.class)
public void testSliceExpressionWithStartStopNumber2() {
testConversion("[10:20]", "");
}
@Test(expected = UnsupportedOperationException.class)
public void testSliceExpressionWithStartNumber3() {
testConversion("[10::]", "");
}
@Test(expected = UnsupportedOperationException.class)
public void testSliceExpressionWithStopNumber3() {
testConversion("[:10:]", "");
}
@Test(expected = UnsupportedOperationException.class)
public void testSliceExpressionWithStartStopNumber3() {
testConversion("[10:20:]", "");
}
@Test(expected = UnsupportedOperationException.class)
public void testSliceExpressionWithStartStopStepNumber3() {
testConversion("[10:20:30]", "");
}
@Test(expected = UnsupportedOperationException.class)
public void testSliceExpressionWithStepNumber3() {
testConversion("[::30]", "");
}
@Test(expected = UnsupportedOperationException.class)
public void testCurrentNode() {
testConversion("@", "");
}
@Test
public void testEmptyIdentifierUnquoted() {
testConversion("foo_bar", "input.field(\"foo_bar\")");
}
@Test
public void testIdentifierUnquoted() {
testConversion("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_",
"input.field(\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_\")");
}
@Test
public void testIdentifierQuoted() {
testConversion("\"foo bar\"", "input.field(\"foo bar\")");
}
@Test
public void testRawStringEmpty() {
testConversion("''", "input.constant(\"\")");
}
@Test
public void testRawStringWithValue() {
testConversion("'foo bar'", "input.constant(\"foo bar\")");
}
@Test
public void testNegativeNumber() {
testConversion("foo[-10]", "input.field(\"foo\").index(-10)");
}
private void testConversion(String jmesPathString, String expectedCode) {
assertThat(acceptorGenerator.interpret(jmesPathString, "input").toString()).isEqualTo((expectedCode));
}
} | 3,575 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/common/UserAgentClassSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.common;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.ClientTestModels;
import software.amazon.awssdk.codegen.poet.common.UserAgentUtilsSpec;
public class UserAgentClassSpecTest {
@Test
void testUserAgentClass() {
ClassSpec useragentspec = new UserAgentUtilsSpec(ClientTestModels.restJsonServiceModels());
assertThat(useragentspec, generatesTo("test-user-agent-class.java"));
}
}
| 3,576 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/common/EnumClassTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.common;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.model.intermediate.EnumModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeType;
public class EnumClassTest {
@Test
public void basicEnumTest() throws IOException {
ShapeModel m = new ShapeModel("TestEnumClass");
m.setType(ShapeType.Enum);
m.setShapeName("TestEnumClass");
m.setEnums(asList(new EnumModel("AVAILABLE", "available"), new EnumModel("PERMANENT_FAILURE", "permanent-failure")));
m.setDocumentation("Some comment on the class itself");
EnumClass sut = new EnumClass("software.amazon.awssdk.codegen.poet.common.model", m);
assertThat(sut, generatesTo("test-enum-class.java"));
}
}
| 3,577 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/SharedStreamAwsModelSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import static java.util.stream.Collectors.toList;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Locale;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
@RunWith(Parameterized.class)
public class SharedStreamAwsModelSpecTest {
private static IntermediateModel intermediateModel;
private final ShapeModel shapeModel;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() {
invokeSafely(SharedStreamAwsModelSpecTest::setUp);
return intermediateModel.getShapes().values().stream().map(shape -> new Object[] { shape }).collect(toList());
}
public SharedStreamAwsModelSpecTest(ShapeModel shapeModel) {
this.shapeModel = shapeModel;
}
@Test
public void basicGeneration() throws Exception {
assertThat(new AwsServiceModel(intermediateModel, shapeModel), generatesTo(referenceFileForShape()));
}
private String referenceFileForShape() {
return "sharedstream/" + shapeModel.getShapeName().toLowerCase(Locale.ENGLISH) + ".java";
}
private static void setUp() throws IOException {
File serviceModelFile = new File(SharedStreamAwsModelSpecTest.class.getResource("sharedstream/service-2.json").getFile());
ServiceModel serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile);
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(serviceModel)
.customizationConfig(CustomizationConfig.create())
.build())
.build();
}
}
| 3,578 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/AwsServiceBaseResponseSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import java.io.File;
import java.io.IOException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
public class AwsServiceBaseResponseSpecTest {
private static IntermediateModel intermediateModel;
@BeforeAll
public static void setUp() throws IOException {
File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json").getFile());
File customizationConfigFile = new File(AwsModelSpecTest.class
.getResource("customization.config")
.getFile());
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile))
.customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile))
.build())
.build();
}
@Test
public void testGeneration() {
AwsServiceBaseResponseSpec spec = new AwsServiceBaseResponseSpec(intermediateModel);
assertThat(spec, generatesTo(spec.className().simpleName().toLowerCase() + ".java"));
}
}
| 3,579 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/ServiceClientConfigurationSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import java.io.File;
import java.io.IOException;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
public class ServiceClientConfigurationSpecTest {
private static IntermediateModel intermediateModel;
@BeforeAll
public static void setUp() throws IOException {
File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json").getFile());
File customizationConfigFile = new File(AwsModelSpecTest.class
.getResource("customization.config")
.getFile());
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile))
.customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile))
.build())
.build();
}
@Test
public void testGeneration() {
ServiceClientConfigurationClass spec = new ServiceClientConfigurationClass(intermediateModel);
MatcherAssert.assertThat(spec, generatesTo("serviceclientconfiguration.java"));
}
}
| 3,580 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/ResponseMetadataSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import java.io.File;
import java.io.IOException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
public class ResponseMetadataSpecTest {
private static IntermediateModel model;
private static IntermediateModel modelWithCustomizedResponseMetadata;
@BeforeAll
public static void setUp() throws IOException {
File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json")
.getFile());
File configFile = new File(AwsModelSpecTest.class
.getResource("customization.config")
.getFile());
File customizationConfigFile = new File(ResponseMetadataSpecTest.class
.getResource("customresponsemetadata/customization.config")
.getFile());
model = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile))
.customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, configFile))
.build())
.build();
modelWithCustomizedResponseMetadata = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile))
.customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile))
.build())
.build();
}
@Test
public void responseMetadataGeneration() {
ResponseMetadataSpec spec = new ResponseMetadataSpec(model);
assertThat(spec, generatesTo(spec.className().simpleName().toLowerCase() + ".java"));
AwsServiceBaseResponseSpec responseSpec = new AwsServiceBaseResponseSpec(model);
assertThat(responseSpec, generatesTo(responseSpec.className().simpleName().toLowerCase() + ".java"));
}
@Test
public void customResponseMetadataGeneration() {
ResponseMetadataSpec spec = new ResponseMetadataSpec(modelWithCustomizedResponseMetadata);
assertThat(spec, generatesTo("./customresponsemetadata/" + spec.className().simpleName().toLowerCase() + ".java"));
AwsServiceBaseResponseSpec responseSpec = new AwsServiceBaseResponseSpec(modelWithCustomizedResponseMetadata);
assertThat(responseSpec, generatesTo("./customresponsemetadata/" + responseSpec.className().simpleName().toLowerCase() + ".java"));
}
}
| 3,581 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/CustomSdkShapesCodegenTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.MemberModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
public class CustomSdkShapesCodegenTest {
private IntermediateModel intermediateModel;
@Before
public void setUp() throws IOException {
File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json").getFile());
File customizationConfigFile = new File(AwsModelSpecTest.class
.getResource("customization.config")
.getFile());
ServiceModel serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile);
CustomizationConfig basicConfig = ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile);
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(serviceModel)
.customizationConfig(basicConfig)
.build())
.build();
}
@Test
public void setAndInjectCustomShapes_areAddedAsMembersToBaseTypeShape() {
ShapeModel baseTypeShape = intermediateModel.getShapes().get("BaseType");
List<MemberModel> baseTypeShapeMembers = baseTypeShape.getMembers();
List<String> memberNames = new ArrayList<>();
for (MemberModel member: baseTypeShapeMembers) {
memberNames.add(member.getName());
}
assertThat(memberNames).contains("CustomShape1","CustomShape2");
}
}
| 3,582 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/BaseExceptionClassSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import java.io.File;
import java.io.IOException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
public class BaseExceptionClassSpecTest {
private static IntermediateModel intermediateModel;
@BeforeAll
public static void setUp() throws IOException {
File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json").getFile());
File customizationConfigFile = new File(AwsModelSpecTest.class
.getResource("customization.config")
.getFile());
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile))
.customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile))
.build())
.build();
}
@Test
public void testGeneration() {
BaseExceptionClass spec = new BaseExceptionClass(intermediateModel);
assertThat(spec, generatesTo("baseserviceexception.java"));
}
}
| 3,583 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/DeprecatedNameTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import java.io.File;
import org.junit.Test;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
public class DeprecatedNameTest {
@Test(expected = IllegalStateException.class)
public void throwsOnListDeprecation() {
runTest("listdeprecationfailure");
}
@Test(expected = IllegalStateException.class)
public void throwsOnMapDeprecation() {
runTest("mapdeprecationfailure");
}
@Test(expected = IllegalStateException.class)
public void throwsOnEnumDeprecation() {
runTest("enumdeprecationfailure");
}
private void runTest(String testName) {
File serviceModelFile = new File(getClass().getResource("./deprecatedname/" + testName + ".json").getFile());
File customizationConfigFile = new File(getClass()
.getResource("./deprecatedname/" + testName + ".customization")
.getFile());
ServiceModel serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile);
CustomizationConfig basicConfig = ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile);
new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(serviceModel)
.customizationConfig(basicConfig)
.build())
.build();
}
}
| 3,584 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/AwsModelSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import static java.util.stream.Collectors.toList;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Locale;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
@RunWith(Parameterized.class)
public class AwsModelSpecTest {
private static IntermediateModel intermediateModel;
private final ShapeModel shapeModel;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() {
invokeSafely(AwsModelSpecTest::setUp);
return intermediateModel.getShapes().values().stream().map(shape -> new Object[] { shape }).collect(toList());
}
public AwsModelSpecTest(ShapeModel shapeModel) {
this.shapeModel = shapeModel;
}
@Test
public void basicGeneration() {
AwsServiceModel actual = new AwsServiceModel(intermediateModel, shapeModel);
assertThat(actual, generatesTo(referenceFileForShape()));
}
private String referenceFileForShape() {
return shapeModel.getShapeName().toLowerCase(Locale.ENGLISH) + ".java";
}
private static void setUp() throws IOException {
File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json").getFile());
File customizationConfigFile = new File(AwsModelSpecTest.class
.getResource("customization.config")
.getFile());
ServiceModel serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile);
CustomizationConfig basicConfig = ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile);
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(serviceModel)
.customizationConfig(basicConfig)
.build())
.build();
}
}
| 3,585 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/XmlNamespaceModelTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import static java.util.stream.Collectors.toList;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Locale;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
@RunWith(Parameterized.class)
public class XmlNamespaceModelTest {
private static IntermediateModel intermediateModel;
private final ShapeModel shapeModel;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() {
invokeSafely(XmlNamespaceModelTest::setUp);
return intermediateModel.getShapes().values().stream().map(shape -> new Object[] { shape }).collect(toList());
}
public XmlNamespaceModelTest(ShapeModel shapeModel) {
this.shapeModel = shapeModel;
}
private static void setUp() throws IOException {
File serviceModelFile = new File(XmlNamespaceModelTest.class.getResource("xmlnamespace/service-2.json")
.getFile());
File configFile = new File(XmlNamespaceModelTest.class
.getResource("xmlnamespace/customization.config")
.getFile());
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile))
.customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, configFile))
.build())
.build();
}
@Test
public void basicGeneration() {
assertThat(new AwsServiceModel(intermediateModel, shapeModel), generatesTo("./xmlnamespace/" + referenceFileForShape()));
}
private String referenceFileForShape() {
return shapeModel.getShapeName().toLowerCase(Locale.ENGLISH) + ".java";
}
}
| 3,586 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/AwsServiceBaseRequestSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Optional;
import java.util.regex.Pattern;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.poet.PoetUtils;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
public class AwsServiceBaseRequestSpecTest {
private static IntermediateModel intermediateModel;
@BeforeAll
public static void setUp() throws IOException {
File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json").getFile());
File customizationConfigFile = new File(AwsModelSpecTest.class
.getResource("customization.config")
.getFile());
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile))
.customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile))
.build())
.build();
}
@Test
void testGeneration() {
AwsServiceBaseRequestSpec spec = new AwsServiceBaseRequestSpec(intermediateModel);
assertThat(spec, generatesTo(spec.className().simpleName().toLowerCase() + ".java"));
}
@Test
void buildJavaFile_memberRequiredByShape_addsTraitToGeneratedCode() {
String requestShapeName = "QueryParameterOperationRequest";
String queryParamName = "QueryParamOne";
ShapeModel requestShapeModel = intermediateModel.getShapes().get(requestShapeName);
AwsServiceModel spec = new AwsServiceModel(intermediateModel, requestShapeModel);
String codeString = PoetUtils.buildJavaFile(spec).toString();
String uploadIdDeclarationString = findTraitDeclarationString(codeString, queryParamName).get();
Assertions.assertThat(uploadIdDeclarationString).contains("RequiredTrait.create()");
}
@Test
void buildJavaFile_memberNotRequiredByShape_doesNotAddTraitToGeneratedCode() {
String requestShapeName = "QueryParameterOperationRequest";
String queryParamName = "QueryParamTwo";
ShapeModel requestShapeModel = intermediateModel.getShapes().get(requestShapeName);
AwsServiceModel spec = new AwsServiceModel(intermediateModel, requestShapeModel);
String codeString = PoetUtils.buildJavaFile(spec).toString();
String uploadIdDeclarationString = findTraitDeclarationString(codeString, queryParamName).get();
Assertions.assertThat(uploadIdDeclarationString).doesNotContain("RequiredTrait.create()");
}
private static Optional<String> findTraitDeclarationString(String javaFileString, String fieldName) {
return Arrays.stream(Pattern.compile("\n\n").split(javaFileString))
.filter(block -> block.contains(fieldName))
.filter(block -> block.contains("traits"))
.findFirst();
}
}
| 3,587 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/ServiceClientConfigurationBuilderSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import java.io.File;
import java.io.IOException;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
public class ServiceClientConfigurationBuilderSpecTest {
private static IntermediateModel intermediateModel;
@BeforeAll
public static void setUp() throws IOException {
File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json").getFile());
File customizationConfigFile = new File(AwsModelSpecTest.class
.getResource("customization.config")
.getFile());
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile))
.customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile))
.build())
.build();
}
@Test
public void testGeneration() {
ServiceClientConfigurationBuilderClass spec = new ServiceClientConfigurationBuilderClass(intermediateModel);
MatcherAssert.assertThat(spec, generatesTo("serviceclientconfiguration-builder.java"));
}
}
| 3,588 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/TestMemberModels.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import java.util.HashMap;
import java.util.Map;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.MemberModel;
class TestMemberModels {
private final IntermediateModel intermediateModel;
private Map<String, MemberModel> shapeToMemberMap;
public TestMemberModels(IntermediateModel intermediateModel) {
this.intermediateModel = intermediateModel;
}
/**
* Returns a mapping of c2jshapes to a single MemberModel in the intermediate model.
*
* @return
*/
public Map<String, MemberModel> shapeToMemberMap() {
if (shapeToMemberMap == null) {
shapeToMemberMap = new HashMap<>();
intermediateModel.getShapes().values().stream()
.flatMap(s -> s.getMembers().stream())
.forEach(m -> shapeToMemberMap.put(m.getC2jShape(), m));
}
return shapeToMemberMap;
}
}
| 3,589 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/ModelCopierSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.model;
import static java.util.stream.Collectors.toList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.stream.Collectors;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.MemberModel;
import software.amazon.awssdk.codegen.model.service.ServiceModel;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.utils.ModelLoaderUtils;
@RunWith(Parameterized.class)
public class ModelCopierSpecTest {
private static File serviceModelFile;
private static IntermediateModel intermediateModel;
private static TestMemberModels testMemberModels;
private final ClassSpec spec;
private final String specName;
private static void setUp() throws URISyntaxException, IOException {
serviceModelFile = new File(AwsModelSpecTest.class
.getResource("service-2.json")
.getFile());
File customizationConfigFile = new File(AwsModelSpecTest.class
.getResource("customization.config")
.getFile());
intermediateModel = new IntermediateModelBuilder(
C2jModels.builder()
.serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile))
.customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile))
.build())
.build();
testMemberModels = new TestMemberModels(intermediateModel);
}
@Parameterized.Parameters(name = "{1}")
public static Collection<Object[]> data() {
invokeSafely(ModelCopierSpecTest::setUp);
return new ServiceModelCopiers(intermediateModel).copierSpecs().stream()
.map(spec -> new Object[] { spec, spec.className().simpleName().toLowerCase(Locale.ENGLISH) })
.collect(toList());
}
public ModelCopierSpecTest(ClassSpec spec, String specName) {
this.spec = spec;
this.specName = specName;
}
@Test
public void basicGeneration() {
assertThat(spec, generatesTo(specName + ".java"));
}
@Test
public void doesNotReturnACopierForImmutableTypes() {
ServiceModelCopiers copiers = new ServiceModelCopiers(intermediateModel);
// Find members that are not Maps, Lists, Dates, or SdkBytes
List<MemberModel> immutableMembers = testMemberModels.shapeToMemberMap().values().stream()
.filter(m -> !(m.isList() || m.isMap()))
.filter(m -> !(m.getVariable().getSimpleType().equals("Date")))
.filter(m -> !(m.getVariable().getSimpleType().equals("SdkBytes")))
.collect(Collectors.toList());
// Quick sanity check to ensure we're actually testing something
assertThat(immutableMembers.size(), is(greaterThan(0)));
immutableMembers.forEach(m -> assertThat(copiers.copierClassFor(m), is(equalTo(Optional.empty()))));
}
}
| 3,590 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/rules/EndpointProviderInterfaceSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.rules;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.ClientTestModels;
public class EndpointProviderInterfaceSpecTest {
@Test
public void endpointProviderInterface() {
ClassSpec endpointProviderInterfaceSpec = new EndpointProviderInterfaceSpec(ClientTestModels.queryServiceModels());
assertThat(endpointProviderInterfaceSpec, generatesTo("endpoint-provider-interface.java"));
}
@Test
public void endpointParameters() {
ClassSpec endpointParametersClassSpec = new EndpointParametersClassSpec(ClientTestModels.queryServiceModels());
assertThat(endpointParametersClassSpec, generatesTo("endpoint-parameters.java"));
}
}
| 3,591 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/rules/EndpointRulesClientTestSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.rules;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.ClientTestModels;
public class EndpointRulesClientTestSpecTest {
@Test
public void endpointRulesTestClass() {
ClassSpec endpointProviderSpec = new EndpointRulesClientTestSpec(ClientTestModels.queryServiceModels());
assertThat(endpointProviderSpec, generatesTo("endpoint-rules-test-class.java"));
}
}
| 3,592 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/rules/RequestEndpointProviderInterceptorSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.rules;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.ClientTestModels;
public class RequestEndpointProviderInterceptorSpecTest {
@Test
public void requestSetEndpointInterceptorClass() {
ClassSpec endpointProviderInterceptor = new RequestEndpointInterceptorSpec(ClientTestModels.queryServiceModels());
assertThat(endpointProviderInterceptor, generatesTo("request-set-endpoint-interceptor.java"));
}
}
| 3,593 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/rules/EndpointProviderClassSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.rules;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.ClientTestModels;
public class EndpointProviderClassSpecTest {
@Test
public void endpointProviderClass() {
ClassSpec endpointProviderSpec = new EndpointProviderSpec(ClientTestModels.queryServiceModels());
assertThat(endpointProviderSpec, generatesTo("endpoint-provider-class.java"));
}
}
| 3,594 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/rules/EndpointResolverInterceptorSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.rules;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.ClientTestModels;
public class EndpointResolverInterceptorSpecTest {
@Test
public void endpointResolverInterceptorClass() {
ClassSpec endpointProviderInterceptor = new EndpointResolverInterceptorSpec(getModel(true));
assertThat(endpointProviderInterceptor, generatesTo("endpoint-resolve-interceptor.java"));
}
// TODO(post-sra-identity-auth): This can be deleted when useSraAuth is removed
@Test
public void endpointResolverInterceptorClass_preSra() {
ClassSpec endpointProviderInterceptor = new EndpointResolverInterceptorSpec(getModel(false));
assertThat(endpointProviderInterceptor, generatesTo("endpoint-resolve-interceptor-preSra.java"));
}
private static IntermediateModel getModel(boolean useSraAuth) {
IntermediateModel model = ClientTestModels.queryServiceModels();
model.getCustomizationConfig().setUseSraAuth(useSraAuth);
return model;
}
}
| 3,595 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/rules/ClientContextParamsClassSpecTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.rules;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.ClientTestModels;
public class ClientContextParamsClassSpecTest {
@Test
public void clientContextParams() {
ClassSpec endpointProviderInterfaceSpec = new ClientContextParamsClassSpec(ClientTestModels.queryServiceModels());
assertThat(endpointProviderInterfaceSpec, generatesTo("client-context-params.java"));
}
}
| 3,596 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/builder/BuilderClassTestUtils.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.builder;
import static org.hamcrest.MatcherAssert.assertThat;
import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo;
import java.util.function.Function;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.poet.ClassSpec;
public class BuilderClassTestUtils {
static void validateGeneration(Function<IntermediateModel, ClassSpec> generatorConstructor,
IntermediateModel model,
String expectedClassName) {
assertThat(generatorConstructor.apply(model), generatesTo(expectedClassName));
}
}
| 3,597 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/builder/AsyncClientBuilderInterfaceTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.builder;
import static software.amazon.awssdk.codegen.poet.ClientTestModels.restJsonServiceModels;
import static software.amazon.awssdk.codegen.poet.builder.BuilderClassTestUtils.validateGeneration;
import org.junit.jupiter.api.Test;
/**
* Validate AsyncClientBuilderInterface generation.
*/
public class AsyncClientBuilderInterfaceTest {
@Test
public void asyncClientBuilderInterface() {
validateGeneration(AsyncClientBuilderInterface::new, restJsonServiceModels(), "test-async-client-builder-interface.java");
}
}
| 3,598 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet | Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/builder/BaseClientBuilderInterfaceTest.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.poet.builder;
import static software.amazon.awssdk.codegen.poet.ClientTestModels.bearerAuthServiceModels;
import static software.amazon.awssdk.codegen.poet.ClientTestModels.composedClientJsonServiceModels;
import static software.amazon.awssdk.codegen.poet.ClientTestModels.restJsonServiceModels;
import static software.amazon.awssdk.codegen.poet.builder.BuilderClassTestUtils.validateGeneration;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
/**
* Validate BaseClientBuilderInterface generation.
*/
public class BaseClientBuilderInterfaceTest {
@Test
public void baseClientBuilderInterface() {
validateBaseClientBuilderInterfaceGeneration(restJsonServiceModels(), "test-client-builder-interface.java");
}
@Test
public void baseClientBuilderInterfaceWithBearerAuth() {
validateBaseClientBuilderInterfaceGeneration(bearerAuthServiceModels(), "test-bearer-auth-client-builder-interface.java");
}
@Test
public void syncHasCrossRegionAccessEnabledPropertyBuilderClass() {
validateBaseClientBuilderInterfaceGeneration(composedClientJsonServiceModels(),
"test-customcontextparams-sync-client-builder-class.java");
}
private void validateBaseClientBuilderInterfaceGeneration(IntermediateModel model, String expectedClassName) {
validateGeneration(BaseClientBuilderInterface::new, model, expectedClassName);
}
}
| 3,599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.