software.amazon.awssdk.services.cognitosync.DefaultCognitoSyncAsyncClient Maven / Gradle / Ivy
Show all versions of cognitosync Show documentation
/*
* 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.services.cognitosync;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
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.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.awscore.retry.AwsRetryStrategy;
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.ClientOverrideConfiguration;
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.core.retry.RetryMode;
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.retries.api.RetryStrategy;
import software.amazon.awssdk.services.cognitosync.internal.CognitoSyncServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.cognitosync.model.AlreadyStreamedException;
import software.amazon.awssdk.services.cognitosync.model.BulkPublishRequest;
import software.amazon.awssdk.services.cognitosync.model.BulkPublishResponse;
import software.amazon.awssdk.services.cognitosync.model.CognitoSyncException;
import software.amazon.awssdk.services.cognitosync.model.ConcurrentModificationException;
import software.amazon.awssdk.services.cognitosync.model.DeleteDatasetRequest;
import software.amazon.awssdk.services.cognitosync.model.DeleteDatasetResponse;
import software.amazon.awssdk.services.cognitosync.model.DescribeDatasetRequest;
import software.amazon.awssdk.services.cognitosync.model.DescribeDatasetResponse;
import software.amazon.awssdk.services.cognitosync.model.DescribeIdentityPoolUsageRequest;
import software.amazon.awssdk.services.cognitosync.model.DescribeIdentityPoolUsageResponse;
import software.amazon.awssdk.services.cognitosync.model.DescribeIdentityUsageRequest;
import software.amazon.awssdk.services.cognitosync.model.DescribeIdentityUsageResponse;
import software.amazon.awssdk.services.cognitosync.model.DuplicateRequestException;
import software.amazon.awssdk.services.cognitosync.model.GetBulkPublishDetailsRequest;
import software.amazon.awssdk.services.cognitosync.model.GetBulkPublishDetailsResponse;
import software.amazon.awssdk.services.cognitosync.model.GetCognitoEventsRequest;
import software.amazon.awssdk.services.cognitosync.model.GetCognitoEventsResponse;
import software.amazon.awssdk.services.cognitosync.model.GetIdentityPoolConfigurationRequest;
import software.amazon.awssdk.services.cognitosync.model.GetIdentityPoolConfigurationResponse;
import software.amazon.awssdk.services.cognitosync.model.InternalErrorException;
import software.amazon.awssdk.services.cognitosync.model.InvalidConfigurationException;
import software.amazon.awssdk.services.cognitosync.model.InvalidLambdaFunctionOutputException;
import software.amazon.awssdk.services.cognitosync.model.InvalidParameterException;
import software.amazon.awssdk.services.cognitosync.model.LambdaThrottledException;
import software.amazon.awssdk.services.cognitosync.model.LimitExceededException;
import software.amazon.awssdk.services.cognitosync.model.ListDatasetsRequest;
import software.amazon.awssdk.services.cognitosync.model.ListDatasetsResponse;
import software.amazon.awssdk.services.cognitosync.model.ListIdentityPoolUsageRequest;
import software.amazon.awssdk.services.cognitosync.model.ListIdentityPoolUsageResponse;
import software.amazon.awssdk.services.cognitosync.model.ListRecordsRequest;
import software.amazon.awssdk.services.cognitosync.model.ListRecordsResponse;
import software.amazon.awssdk.services.cognitosync.model.NotAuthorizedException;
import software.amazon.awssdk.services.cognitosync.model.RegisterDeviceRequest;
import software.amazon.awssdk.services.cognitosync.model.RegisterDeviceResponse;
import software.amazon.awssdk.services.cognitosync.model.ResourceConflictException;
import software.amazon.awssdk.services.cognitosync.model.ResourceNotFoundException;
import software.amazon.awssdk.services.cognitosync.model.SetCognitoEventsRequest;
import software.amazon.awssdk.services.cognitosync.model.SetCognitoEventsResponse;
import software.amazon.awssdk.services.cognitosync.model.SetIdentityPoolConfigurationRequest;
import software.amazon.awssdk.services.cognitosync.model.SetIdentityPoolConfigurationResponse;
import software.amazon.awssdk.services.cognitosync.model.SubscribeToDatasetRequest;
import software.amazon.awssdk.services.cognitosync.model.SubscribeToDatasetResponse;
import software.amazon.awssdk.services.cognitosync.model.TooManyRequestsException;
import software.amazon.awssdk.services.cognitosync.model.UnsubscribeFromDatasetRequest;
import software.amazon.awssdk.services.cognitosync.model.UnsubscribeFromDatasetResponse;
import software.amazon.awssdk.services.cognitosync.model.UpdateRecordsRequest;
import software.amazon.awssdk.services.cognitosync.model.UpdateRecordsResponse;
import software.amazon.awssdk.services.cognitosync.transform.BulkPublishRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.DeleteDatasetRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.DescribeDatasetRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.DescribeIdentityPoolUsageRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.DescribeIdentityUsageRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.GetBulkPublishDetailsRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.GetCognitoEventsRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.GetIdentityPoolConfigurationRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.ListDatasetsRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.ListIdentityPoolUsageRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.ListRecordsRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.RegisterDeviceRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.SetCognitoEventsRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.SetIdentityPoolConfigurationRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.SubscribeToDatasetRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.UnsubscribeFromDatasetRequestMarshaller;
import software.amazon.awssdk.services.cognitosync.transform.UpdateRecordsRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link CognitoSyncAsyncClient}.
*
* @see CognitoSyncAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultCognitoSyncAsyncClient implements CognitoSyncAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultCognitoSyncAsyncClient.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 DefaultCognitoSyncAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.SDK_CLIENT, this).build();
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
*
* Initiates a bulk publish of all existing datasets for an Identity Pool to the configured stream. Customers are
* limited to one successful bulk publish per 24 hours. Bulk publish is an asynchronous request, customers can see
* the status of the request via the GetBulkPublishDetails operation.
*
*
* This API can only be called with developer credentials. You cannot call this API with the temporary user
* credentials provided by Cognito Identity.
*
*
* @param bulkPublishRequest
* The input for the BulkPublish operation.
* @return A Java Future containing the result of the BulkPublish operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - InternalErrorException Indicates an internal service error.
* - DuplicateRequestException An exception thrown when there is an IN_PROGRESS bulk publish operation for
* the given identity pool.
* - AlreadyStreamedException An exception thrown when a bulk publish operation is requested less than 24
* hours after a previous bulk publish operation completed successfully.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.BulkPublish
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture bulkPublish(BulkPublishRequest bulkPublishRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bulkPublishRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, bulkPublishRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BulkPublish");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
BulkPublishResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("BulkPublish").withProtocolMetadata(protocolMetadata)
.withMarshaller(new BulkPublishRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(bulkPublishRequest));
CompletableFuture 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);
}
}
/**
*
* Deletes the specific dataset. The dataset will be deleted permanently, and the action can't be undone. Datasets
* that this dataset was merged with will no longer report the merge. Any subsequent operation on this dataset will
* result in a ResourceNotFoundException.
*
*
* This API can be called with temporary user credentials provided by Cognito Identity or with developer
* credentials.
*
*
* @param deleteDatasetRequest
* A request to delete the specific dataset.
* @return A Java Future containing the result of the DeleteDataset operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - InternalErrorException Indicates an internal service error.
* - TooManyRequestsException Thrown if the request is throttled.
* - ResourceConflictException Thrown if an update can't be applied because the resource was changed by
* another call and this would result in a conflict.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.DeleteDataset
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture deleteDataset(DeleteDatasetRequest deleteDatasetRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteDatasetRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteDatasetRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteDataset");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteDatasetResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteDataset").withProtocolMetadata(protocolMetadata)
.withMarshaller(new DeleteDatasetRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(deleteDatasetRequest));
CompletableFuture 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);
}
}
/**
*
* Gets meta data about a dataset by identity and dataset name. With Amazon Cognito Sync, each identity has access
* only to its own data. Thus, the credentials used to make this API call need to have access to the identity data.
*
*
* This API can be called with temporary user credentials provided by Cognito Identity or with developer
* credentials. You should use Cognito Identity credentials to make this API call.
*
*
* @param describeDatasetRequest
* A request for meta data about a dataset (creation date, number of records, size) by owner and dataset
* name.
* @return A Java Future containing the result of the DescribeDataset operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - InternalErrorException Indicates an internal service error.
* - TooManyRequestsException Thrown if the request is throttled.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.DescribeDataset
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture describeDataset(DescribeDatasetRequest describeDatasetRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeDatasetRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeDatasetRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeDataset");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeDatasetResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeDataset").withProtocolMetadata(protocolMetadata)
.withMarshaller(new DescribeDatasetRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(describeDatasetRequest));
CompletableFuture 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);
}
}
/**
*
* Gets usage details (for example, data storage) about a particular identity pool.
*
*
* This API can only be called with developer credentials. You cannot call this API with the temporary user
* credentials provided by Cognito Identity.
*
*
* @param describeIdentityPoolUsageRequest
* A request for usage information about the identity pool.
* @return A Java Future containing the result of the DescribeIdentityPoolUsage operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - InternalErrorException Indicates an internal service error.
* - TooManyRequestsException Thrown if the request is throttled.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.DescribeIdentityPoolUsage
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeIdentityPoolUsage(
DescribeIdentityPoolUsageRequest describeIdentityPoolUsageRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeIdentityPoolUsageRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeIdentityPoolUsageRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeIdentityPoolUsage");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeIdentityPoolUsageResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeIdentityPoolUsage").withProtocolMetadata(protocolMetadata)
.withMarshaller(new DescribeIdentityPoolUsageRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(describeIdentityPoolUsageRequest));
CompletableFuture 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);
}
}
/**
*
* Gets usage information for an identity, including number of datasets and data usage.
*
*
* This API can be called with temporary user credentials provided by Cognito Identity or with developer
* credentials.
*
*
* @param describeIdentityUsageRequest
* A request for information about the usage of an identity pool.
* @return A Java Future containing the result of the DescribeIdentityUsage operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - InternalErrorException Indicates an internal service error.
* - TooManyRequestsException Thrown if the request is throttled.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.DescribeIdentityUsage
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeIdentityUsage(
DescribeIdentityUsageRequest describeIdentityUsageRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeIdentityUsageRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeIdentityUsageRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeIdentityUsage");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeIdentityUsageResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeIdentityUsage").withProtocolMetadata(protocolMetadata)
.withMarshaller(new DescribeIdentityUsageRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(describeIdentityUsageRequest));
CompletableFuture 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);
}
}
/**
*
* Get the status of the last BulkPublish operation for an identity pool.
*
*
* This API can only be called with developer credentials. You cannot call this API with the temporary user
* credentials provided by Cognito Identity.
*
*
* @param getBulkPublishDetailsRequest
* The input for the GetBulkPublishDetails operation.
* @return A Java Future containing the result of the GetBulkPublishDetails operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - InternalErrorException Indicates an internal service error.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.GetBulkPublishDetails
* @see AWS API Documentation
*/
@Override
public CompletableFuture getBulkPublishDetails(
GetBulkPublishDetailsRequest getBulkPublishDetailsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getBulkPublishDetailsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getBulkPublishDetailsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetBulkPublishDetails");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetBulkPublishDetailsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetBulkPublishDetails").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetBulkPublishDetailsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getBulkPublishDetailsRequest));
CompletableFuture 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);
}
}
/**
*
* Gets the events and the corresponding Lambda functions associated with an identity pool.
*
*
* This API can only be called with developer credentials. You cannot call this API with the temporary user
* credentials provided by Cognito Identity.
*
*
* @param getCognitoEventsRequest
* A request for a list of the configured Cognito Events
* @return A Java Future containing the result of the GetCognitoEvents operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InternalErrorException Indicates an internal service error.
* - TooManyRequestsException Thrown if the request is throttled.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.GetCognitoEvents
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture getCognitoEvents(GetCognitoEventsRequest getCognitoEventsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getCognitoEventsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getCognitoEventsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetCognitoEvents");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetCognitoEventsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetCognitoEvents").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetCognitoEventsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getCognitoEventsRequest));
CompletableFuture 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);
}
}
/**
*
* Gets the configuration settings of an identity pool.
*
*
* This API can only be called with developer credentials. You cannot call this API with the temporary user
* credentials provided by Cognito Identity.
*
*
* @param getIdentityPoolConfigurationRequest
* The input for the GetIdentityPoolConfiguration operation.
* @return A Java Future containing the result of the GetIdentityPoolConfiguration operation returned by the
* service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - InternalErrorException Indicates an internal service error.
* - TooManyRequestsException Thrown if the request is throttled.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.GetIdentityPoolConfiguration
* @see AWS API Documentation
*/
@Override
public CompletableFuture getIdentityPoolConfiguration(
GetIdentityPoolConfigurationRequest getIdentityPoolConfigurationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getIdentityPoolConfigurationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getIdentityPoolConfigurationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetIdentityPoolConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetIdentityPoolConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetIdentityPoolConfiguration").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetIdentityPoolConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getIdentityPoolConfigurationRequest));
CompletableFuture 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);
}
}
/**
*
* Lists datasets for an identity. With Amazon Cognito Sync, each identity has access only to its own data. Thus,
* the credentials used to make this API call need to have access to the identity data.
*
*
* ListDatasets can be called with temporary user credentials provided by Cognito Identity or with developer
* credentials. You should use the Cognito Identity credentials to make this API call.
*
*
* @param listDatasetsRequest
* Request for a list of datasets for an identity.
* @return A Java Future containing the result of the ListDatasets operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - InternalErrorException Indicates an internal service error.
* - TooManyRequestsException Thrown if the request is throttled.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.ListDatasets
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listDatasets(ListDatasetsRequest listDatasetsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listDatasetsRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listDatasetsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListDatasets");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListDatasetsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListDatasets").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListDatasetsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listDatasetsRequest));
CompletableFuture 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);
}
}
/**
*
* Gets a list of identity pools registered with Cognito.
*
*
* ListIdentityPoolUsage can only be called with developer credentials. You cannot make this API call with the
* temporary user credentials provided by Cognito Identity.
*
*
* @param listIdentityPoolUsageRequest
* A request for usage information on an identity pool.
* @return A Java Future containing the result of the ListIdentityPoolUsage operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - InternalErrorException Indicates an internal service error.
* - TooManyRequestsException Thrown if the request is throttled.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.ListIdentityPoolUsage
* @see AWS API Documentation
*/
@Override
public CompletableFuture listIdentityPoolUsage(
ListIdentityPoolUsageRequest listIdentityPoolUsageRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listIdentityPoolUsageRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listIdentityPoolUsageRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListIdentityPoolUsage");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListIdentityPoolUsageResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListIdentityPoolUsage").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListIdentityPoolUsageRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listIdentityPoolUsageRequest));
CompletableFuture 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);
}
}
/**
*
* Gets paginated records, optionally changed after a particular sync count for a dataset and identity. With Amazon
* Cognito Sync, each identity has access only to its own data. Thus, the credentials used to make this API call
* need to have access to the identity data.
*
*
* ListRecords can be called with temporary user credentials provided by Cognito Identity or with developer
* credentials. You should use Cognito Identity credentials to make this API call.
*
*
* @param listRecordsRequest
* A request for a list of records.
* @return A Java Future containing the result of the ListRecords operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - TooManyRequestsException Thrown if the request is throttled.
* - InternalErrorException Indicates an internal service error.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.ListRecords
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listRecords(ListRecordsRequest listRecordsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listRecordsRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listRecordsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListRecords");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListRecordsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListRecords").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListRecordsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listRecordsRequest));
CompletableFuture 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);
}
}
/**
*
* Registers a device to receive push sync notifications.
*
*
* This API can only be called with temporary credentials provided by Cognito Identity. You cannot call this API
* with developer credentials.
*
*
* @param registerDeviceRequest
* A request to RegisterDevice.
* @return A Java Future containing the result of the RegisterDevice operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - InternalErrorException Indicates an internal service error.
* - InvalidConfigurationException
* - TooManyRequestsException Thrown if the request is throttled.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.RegisterDevice
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture registerDevice(RegisterDeviceRequest registerDeviceRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(registerDeviceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, registerDeviceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "RegisterDevice");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, RegisterDeviceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("RegisterDevice").withProtocolMetadata(protocolMetadata)
.withMarshaller(new RegisterDeviceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(registerDeviceRequest));
CompletableFuture 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);
}
}
/**
*
* Sets the AWS Lambda function for a given event type for an identity pool. This request only updates the key/value
* pair specified. Other key/values pairs are not updated. To remove a key value pair, pass a empty value for the
* particular key.
*
*
* This API can only be called with developer credentials. You cannot call this API with the temporary user
* credentials provided by Cognito Identity.
*
*
* @param setCognitoEventsRequest
* A request to configure Cognito Events"
* @return A Java Future containing the result of the SetCognitoEvents operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InternalErrorException Indicates an internal service error.
* - TooManyRequestsException Thrown if the request is throttled.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.SetCognitoEvents
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture setCognitoEvents(SetCognitoEventsRequest setCognitoEventsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(setCognitoEventsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, setCognitoEventsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "SetCognitoEvents");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, SetCognitoEventsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("SetCognitoEvents").withProtocolMetadata(protocolMetadata)
.withMarshaller(new SetCognitoEventsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(setCognitoEventsRequest));
CompletableFuture 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);
}
}
/**
*
* Sets the necessary configuration for push sync.
*
*
* This API can only be called with developer credentials. You cannot call this API with the temporary user
* credentials provided by Cognito Identity.
*
*
* @param setIdentityPoolConfigurationRequest
* The input for the SetIdentityPoolConfiguration operation.
* @return A Java Future containing the result of the SetIdentityPoolConfiguration operation returned by the
* service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - InternalErrorException Indicates an internal service error.
* - TooManyRequestsException Thrown if the request is throttled.
* - ConcurrentModificationException Thrown if there are parallel requests to modify a resource.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.SetIdentityPoolConfiguration
* @see AWS API Documentation
*/
@Override
public CompletableFuture setIdentityPoolConfiguration(
SetIdentityPoolConfigurationRequest setIdentityPoolConfigurationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(setIdentityPoolConfigurationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, setIdentityPoolConfigurationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "SetIdentityPoolConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, SetIdentityPoolConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("SetIdentityPoolConfiguration").withProtocolMetadata(protocolMetadata)
.withMarshaller(new SetIdentityPoolConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(setIdentityPoolConfigurationRequest));
CompletableFuture 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);
}
}
/**
*
* Subscribes to receive notifications when a dataset is modified by another device.
*
*
* This API can only be called with temporary credentials provided by Cognito Identity. You cannot call this API
* with developer credentials.
*
*
* @param subscribeToDatasetRequest
* A request to SubscribeToDatasetRequest.
* @return A Java Future containing the result of the SubscribeToDataset operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - InternalErrorException Indicates an internal service error.
* - InvalidConfigurationException
* - TooManyRequestsException Thrown if the request is throttled.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.SubscribeToDataset
* @see AWS API Documentation
*/
@Override
public CompletableFuture subscribeToDataset(SubscribeToDatasetRequest subscribeToDatasetRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(subscribeToDatasetRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, subscribeToDatasetRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "SubscribeToDataset");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, SubscribeToDatasetResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("SubscribeToDataset").withProtocolMetadata(protocolMetadata)
.withMarshaller(new SubscribeToDatasetRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(subscribeToDatasetRequest));
CompletableFuture 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);
}
}
/**
*
* Unsubscribes from receiving notifications when a dataset is modified by another device.
*
*
* This API can only be called with temporary credentials provided by Cognito Identity. You cannot call this API
* with developer credentials.
*
*
* @param unsubscribeFromDatasetRequest
* A request to UnsubscribeFromDataset.
* @return A Java Future containing the result of the UnsubscribeFromDataset operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - InternalErrorException Indicates an internal service error.
* - InvalidConfigurationException
* - TooManyRequestsException Thrown if the request is throttled.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.UnsubscribeFromDataset
* @see AWS API Documentation
*/
@Override
public CompletableFuture unsubscribeFromDataset(
UnsubscribeFromDatasetRequest unsubscribeFromDatasetRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(unsubscribeFromDatasetRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, unsubscribeFromDatasetRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UnsubscribeFromDataset");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UnsubscribeFromDatasetResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UnsubscribeFromDataset").withProtocolMetadata(protocolMetadata)
.withMarshaller(new UnsubscribeFromDatasetRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(unsubscribeFromDatasetRequest));
CompletableFuture 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);
}
}
/**
*
* Posts updates to records and adds and deletes records for a dataset and user.
*
*
* The sync count in the record patch is your last known sync count for that record. The server will reject an
* UpdateRecords request with a ResourceConflictException if you try to patch a record with a new value but a stale
* sync count.
*
*
* For example, if the sync count on the server is 5 for a key called highScore and you try and submit a new
* highScore with sync count of 4, the request will be rejected. To obtain the current sync count for a record, call
* ListRecords. On a successful update of the record, the response returns the new sync count for that record. You
* should present that sync count the next time you try to update that same record. When the record does not exist,
* specify the sync count as 0.
*
*
* This API can be called with temporary user credentials provided by Cognito Identity or with developer
* credentials.
*
*
* @param updateRecordsRequest
* A request to post updates to records or add and delete records for a dataset and user.
* @return A Java Future containing the result of the UpdateRecords operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - InvalidParameterException Thrown when a request parameter does not comply with the associated
* constraints.
* - LimitExceededException Thrown when the limit on the number of objects or operations has been
* exceeded.
* - NotAuthorizedException Thrown when a user is not authorized to access the requested resource.
* - ResourceNotFoundException Thrown if the resource doesn't exist.
* - ResourceConflictException Thrown if an update can't be applied because the resource was changed by
* another call and this would result in a conflict.
* - InvalidLambdaFunctionOutputException The AWS Lambda function returned invalid output or an exception.
*
* - LambdaThrottledException AWS Lambda throttled your account, please contact AWS Support
* - TooManyRequestsException Thrown if the request is throttled.
* - InternalErrorException Indicates an internal service error.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - CognitoSyncException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample CognitoSyncAsyncClient.UpdateRecords
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture updateRecords(UpdateRecordsRequest updateRecordsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateRecordsRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateRecordsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Cognito Sync");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateRecords");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UpdateRecordsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateRecords").withProtocolMetadata(protocolMetadata)
.withMarshaller(new UpdateRecordsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(updateRecordsRequest));
CompletableFuture 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 CognitoSyncServiceClientConfiguration serviceClientConfiguration() {
return new CognitoSyncServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(CognitoSyncException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("ConcurrentModificationException")
.exceptionBuilderSupplier(ConcurrentModificationException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidConfigurationException")
.exceptionBuilderSupplier(InvalidConfigurationException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidParameterException")
.exceptionBuilderSupplier(InvalidParameterException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(404).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("DuplicateRequestException")
.exceptionBuilderSupplier(DuplicateRequestException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceConflictException")
.exceptionBuilderSupplier(ResourceConflictException::builder).httpStatusCode(409).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("LambdaThrottledException")
.exceptionBuilderSupplier(LambdaThrottledException::builder).httpStatusCode(429).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("NotAuthorizedException")
.exceptionBuilderSupplier(NotAuthorizedException::builder).httpStatusCode(403).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalErrorException")
.exceptionBuilderSupplier(InternalErrorException::builder).httpStatusCode(500).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("TooManyRequestsException")
.exceptionBuilderSupplier(TooManyRequestsException::builder).httpStatusCode(429).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidLambdaFunctionOutputException")
.exceptionBuilderSupplier(InvalidLambdaFunctionOutputException::builder).httpStatusCode(400)
.build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("LimitExceededException")
.exceptionBuilderSupplier(LimitExceededException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("AlreadyStreamedException")
.exceptionBuilderSupplier(AlreadyStreamedException::builder).httpStatusCode(400).build());
}
private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List 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 void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) {
ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder();
RetryMode retryMode = builder.retryMode();
if (retryMode != null) {
configuration.option(SdkClientOption.RETRY_STRATEGY, AwsRetryStrategy.forRetryMode(retryMode));
} else {
Consumer> configurator = builder.retryStrategyConfigurator();
if (configurator != null) {
RetryStrategy.Builder defaultBuilder = AwsRetryStrategy.defaultRetryStrategy().toBuilder();
configurator.accept(defaultBuilder);
configuration.option(SdkClientOption.RETRY_STRATEGY, defaultBuilder.build());
} else {
RetryStrategy retryStrategy = builder.retryStrategy();
if (retryStrategy != null) {
configuration.option(SdkClientOption.RETRY_STRATEGY, retryStrategy);
}
}
}
configuration.option(SdkClientOption.CONFIGURED_RETRY_MODE, null);
configuration.option(SdkClientOption.CONFIGURED_RETRY_STRATEGY, null);
configuration.option(SdkClientOption.CONFIGURED_RETRY_CONFIGURATOR, null);
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
if (plugins.isEmpty()) {
return configuration.build();
}
CognitoSyncServiceClientConfigurationBuilder serviceConfigBuilder = new CognitoSyncServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
updateRetryStrategyClientConfiguration(configuration);
return configuration.build();
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
@Override
public void close() {
clientHandler.close();
}
}