software.amazon.awssdk.services.codestarconnections.DefaultCodeStarConnectionsAsyncClient Maven / Gradle / Ivy
Show all versions of codestarconnections 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.codestarconnections;
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.codestarconnections.internal.CodeStarConnectionsServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.codestarconnections.model.AccessDeniedException;
import software.amazon.awssdk.services.codestarconnections.model.CodeStarConnectionsException;
import software.amazon.awssdk.services.codestarconnections.model.ConcurrentModificationException;
import software.amazon.awssdk.services.codestarconnections.model.ConditionalCheckFailedException;
import software.amazon.awssdk.services.codestarconnections.model.ConflictException;
import software.amazon.awssdk.services.codestarconnections.model.CreateConnectionRequest;
import software.amazon.awssdk.services.codestarconnections.model.CreateConnectionResponse;
import software.amazon.awssdk.services.codestarconnections.model.CreateHostRequest;
import software.amazon.awssdk.services.codestarconnections.model.CreateHostResponse;
import software.amazon.awssdk.services.codestarconnections.model.CreateRepositoryLinkRequest;
import software.amazon.awssdk.services.codestarconnections.model.CreateRepositoryLinkResponse;
import software.amazon.awssdk.services.codestarconnections.model.CreateSyncConfigurationRequest;
import software.amazon.awssdk.services.codestarconnections.model.CreateSyncConfigurationResponse;
import software.amazon.awssdk.services.codestarconnections.model.DeleteConnectionRequest;
import software.amazon.awssdk.services.codestarconnections.model.DeleteConnectionResponse;
import software.amazon.awssdk.services.codestarconnections.model.DeleteHostRequest;
import software.amazon.awssdk.services.codestarconnections.model.DeleteHostResponse;
import software.amazon.awssdk.services.codestarconnections.model.DeleteRepositoryLinkRequest;
import software.amazon.awssdk.services.codestarconnections.model.DeleteRepositoryLinkResponse;
import software.amazon.awssdk.services.codestarconnections.model.DeleteSyncConfigurationRequest;
import software.amazon.awssdk.services.codestarconnections.model.DeleteSyncConfigurationResponse;
import software.amazon.awssdk.services.codestarconnections.model.GetConnectionRequest;
import software.amazon.awssdk.services.codestarconnections.model.GetConnectionResponse;
import software.amazon.awssdk.services.codestarconnections.model.GetHostRequest;
import software.amazon.awssdk.services.codestarconnections.model.GetHostResponse;
import software.amazon.awssdk.services.codestarconnections.model.GetRepositoryLinkRequest;
import software.amazon.awssdk.services.codestarconnections.model.GetRepositoryLinkResponse;
import software.amazon.awssdk.services.codestarconnections.model.GetRepositorySyncStatusRequest;
import software.amazon.awssdk.services.codestarconnections.model.GetRepositorySyncStatusResponse;
import software.amazon.awssdk.services.codestarconnections.model.GetResourceSyncStatusRequest;
import software.amazon.awssdk.services.codestarconnections.model.GetResourceSyncStatusResponse;
import software.amazon.awssdk.services.codestarconnections.model.GetSyncBlockerSummaryRequest;
import software.amazon.awssdk.services.codestarconnections.model.GetSyncBlockerSummaryResponse;
import software.amazon.awssdk.services.codestarconnections.model.GetSyncConfigurationRequest;
import software.amazon.awssdk.services.codestarconnections.model.GetSyncConfigurationResponse;
import software.amazon.awssdk.services.codestarconnections.model.InternalServerException;
import software.amazon.awssdk.services.codestarconnections.model.InvalidInputException;
import software.amazon.awssdk.services.codestarconnections.model.LimitExceededException;
import software.amazon.awssdk.services.codestarconnections.model.ListConnectionsRequest;
import software.amazon.awssdk.services.codestarconnections.model.ListConnectionsResponse;
import software.amazon.awssdk.services.codestarconnections.model.ListHostsRequest;
import software.amazon.awssdk.services.codestarconnections.model.ListHostsResponse;
import software.amazon.awssdk.services.codestarconnections.model.ListRepositoryLinksRequest;
import software.amazon.awssdk.services.codestarconnections.model.ListRepositoryLinksResponse;
import software.amazon.awssdk.services.codestarconnections.model.ListRepositorySyncDefinitionsRequest;
import software.amazon.awssdk.services.codestarconnections.model.ListRepositorySyncDefinitionsResponse;
import software.amazon.awssdk.services.codestarconnections.model.ListSyncConfigurationsRequest;
import software.amazon.awssdk.services.codestarconnections.model.ListSyncConfigurationsResponse;
import software.amazon.awssdk.services.codestarconnections.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.codestarconnections.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.codestarconnections.model.ResourceAlreadyExistsException;
import software.amazon.awssdk.services.codestarconnections.model.ResourceNotFoundException;
import software.amazon.awssdk.services.codestarconnections.model.ResourceUnavailableException;
import software.amazon.awssdk.services.codestarconnections.model.RetryLatestCommitFailedException;
import software.amazon.awssdk.services.codestarconnections.model.SyncBlockerDoesNotExistException;
import software.amazon.awssdk.services.codestarconnections.model.SyncConfigurationStillExistsException;
import software.amazon.awssdk.services.codestarconnections.model.TagResourceRequest;
import software.amazon.awssdk.services.codestarconnections.model.TagResourceResponse;
import software.amazon.awssdk.services.codestarconnections.model.ThrottlingException;
import software.amazon.awssdk.services.codestarconnections.model.UnsupportedOperationException;
import software.amazon.awssdk.services.codestarconnections.model.UnsupportedProviderTypeException;
import software.amazon.awssdk.services.codestarconnections.model.UntagResourceRequest;
import software.amazon.awssdk.services.codestarconnections.model.UntagResourceResponse;
import software.amazon.awssdk.services.codestarconnections.model.UpdateHostRequest;
import software.amazon.awssdk.services.codestarconnections.model.UpdateHostResponse;
import software.amazon.awssdk.services.codestarconnections.model.UpdateOutOfSyncException;
import software.amazon.awssdk.services.codestarconnections.model.UpdateRepositoryLinkRequest;
import software.amazon.awssdk.services.codestarconnections.model.UpdateRepositoryLinkResponse;
import software.amazon.awssdk.services.codestarconnections.model.UpdateSyncBlockerRequest;
import software.amazon.awssdk.services.codestarconnections.model.UpdateSyncBlockerResponse;
import software.amazon.awssdk.services.codestarconnections.model.UpdateSyncConfigurationRequest;
import software.amazon.awssdk.services.codestarconnections.model.UpdateSyncConfigurationResponse;
import software.amazon.awssdk.services.codestarconnections.transform.CreateConnectionRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.CreateHostRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.CreateRepositoryLinkRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.CreateSyncConfigurationRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.DeleteConnectionRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.DeleteHostRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.DeleteRepositoryLinkRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.DeleteSyncConfigurationRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.GetConnectionRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.GetHostRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.GetRepositoryLinkRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.GetRepositorySyncStatusRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.GetResourceSyncStatusRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.GetSyncBlockerSummaryRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.GetSyncConfigurationRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.ListConnectionsRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.ListHostsRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.ListRepositoryLinksRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.ListRepositorySyncDefinitionsRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.ListSyncConfigurationsRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.UpdateHostRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.UpdateRepositoryLinkRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.UpdateSyncBlockerRequestMarshaller;
import software.amazon.awssdk.services.codestarconnections.transform.UpdateSyncConfigurationRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link CodeStarConnectionsAsyncClient}.
*
* @see CodeStarConnectionsAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultCodeStarConnectionsAsyncClient implements CodeStarConnectionsAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultCodeStarConnectionsAsyncClient.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 DefaultCodeStarConnectionsAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.SDK_CLIENT, this).build();
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
*
* Creates a connection that can then be given to other Amazon Web Services services like CodePipeline so that it
* can access third-party code repositories. The connection is in pending status until the third-party connection
* handshake is completed from the console.
*
*
* @param createConnectionRequest
* @return A Java Future containing the result of the CreateConnection 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.
*
* - LimitExceededException Exceeded the maximum limit for connections.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ResourceUnavailableException Resource not found. Verify the ARN for the host resource and try again.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.CreateConnection
* @see AWS API Documentation
*/
@Override
public CompletableFuture createConnection(CreateConnectionRequest createConnectionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createConnectionRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createConnectionRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateConnection");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateConnectionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateConnection").withProtocolMetadata(protocolMetadata)
.withMarshaller(new CreateConnectionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(createConnectionRequest));
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);
}
}
/**
*
* Creates a resource that represents the infrastructure where a third-party provider is installed. The host is used
* when you create connections to an installed third-party provider type, such as GitHub Enterprise Server. You
* create one host for all connections to that provider.
*
*
*
* A host created through the CLI or the SDK is in `PENDING` status by default. You can make its status `AVAILABLE`
* by setting up the host in the console.
*
*
*
* @param createHostRequest
* @return A Java Future containing the result of the CreateHost 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.
*
* - LimitExceededException Exceeded the maximum limit for connections.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.CreateHost
* @see AWS API Documentation
*/
@Override
public CompletableFuture createHost(CreateHostRequest createHostRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createHostRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createHostRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateHost");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CreateHostResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("CreateHost")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new CreateHostRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(createHostRequest));
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);
}
}
/**
*
* Creates a link to a specified external Git repository. A repository link allows Git sync to monitor and sync
* changes to files in a specified Git repository.
*
*
* @param createRepositoryLinkRequest
* @return A Java Future containing the result of the CreateRepositoryLink 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ConcurrentModificationException Exception thrown as a result of concurrent modification to an
* application. For example, two individuals attempting to edit the same application at the same time.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - LimitExceededException Exceeded the maximum limit for connections.
* - ResourceAlreadyExistsException Unable to create resource. Resource already exists.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.CreateRepositoryLink
* @see AWS API Documentation
*/
@Override
public CompletableFuture createRepositoryLink(
CreateRepositoryLinkRequest createRepositoryLinkRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createRepositoryLinkRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createRepositoryLinkRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateRepositoryLink");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateRepositoryLinkResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateRepositoryLink").withProtocolMetadata(protocolMetadata)
.withMarshaller(new CreateRepositoryLinkRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(createRepositoryLinkRequest));
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);
}
}
/**
*
* Creates a sync configuration which allows Amazon Web Services to sync content from a Git repository to update a
* specified Amazon Web Services resource. Parameters for the sync configuration are determined by the sync type.
*
*
* @param createSyncConfigurationRequest
* @return A Java Future containing the result of the CreateSyncConfiguration 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ConcurrentModificationException Exception thrown as a result of concurrent modification to an
* application. For example, two individuals attempting to edit the same application at the same time.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - LimitExceededException Exceeded the maximum limit for connections.
* - ResourceAlreadyExistsException Unable to create resource. Resource already exists.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.CreateSyncConfiguration
* @see AWS API Documentation
*/
@Override
public CompletableFuture createSyncConfiguration(
CreateSyncConfigurationRequest createSyncConfigurationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createSyncConfigurationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createSyncConfigurationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateSyncConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateSyncConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateSyncConfiguration").withProtocolMetadata(protocolMetadata)
.withMarshaller(new CreateSyncConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(createSyncConfigurationRequest));
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);
}
}
/**
*
* The connection to be deleted.
*
*
* @param deleteConnectionRequest
* @return A Java Future containing the result of the DeleteConnection 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.
*
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.DeleteConnection
* @see AWS API Documentation
*/
@Override
public CompletableFuture deleteConnection(DeleteConnectionRequest deleteConnectionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteConnectionRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteConnectionRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteConnection");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteConnectionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteConnection").withProtocolMetadata(protocolMetadata)
.withMarshaller(new DeleteConnectionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(deleteConnectionRequest));
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);
}
}
/**
*
* The host to be deleted. Before you delete a host, all connections associated to the host must be deleted.
*
*
*
* A host cannot be deleted if it is in the VPC_CONFIG_INITIALIZING or VPC_CONFIG_DELETING state.
*
*
*
* @param deleteHostRequest
* @return A Java Future containing the result of the DeleteHost 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.
*
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ResourceUnavailableException Resource not found. Verify the ARN for the host resource and try again.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.DeleteHost
* @see AWS API Documentation
*/
@Override
public CompletableFuture deleteHost(DeleteHostRequest deleteHostRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteHostRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteHostRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteHost");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteHostResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("DeleteHost")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new DeleteHostRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(deleteHostRequest));
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 association between your connection and a specified external Git repository.
*
*
* @param deleteRepositoryLinkRequest
* @return A Java Future containing the result of the DeleteRepositoryLink 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ConcurrentModificationException Exception thrown as a result of concurrent modification to an
* application. For example, two individuals attempting to edit the same application at the same time.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - SyncConfigurationStillExistsException Unable to continue. The sync blocker still exists.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ThrottlingException The request was denied due to request throttling.
* - UnsupportedProviderTypeException The specified provider type is not supported for connections.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.DeleteRepositoryLink
* @see AWS API Documentation
*/
@Override
public CompletableFuture deleteRepositoryLink(
DeleteRepositoryLinkRequest deleteRepositoryLinkRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteRepositoryLinkRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteRepositoryLinkRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteRepositoryLink");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteRepositoryLinkResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteRepositoryLink").withProtocolMetadata(protocolMetadata)
.withMarshaller(new DeleteRepositoryLinkRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(deleteRepositoryLinkRequest));
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 sync configuration for a specified repository and connection.
*
*
* @param deleteSyncConfigurationRequest
* @return A Java Future containing the result of the DeleteSyncConfiguration 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ConcurrentModificationException Exception thrown as a result of concurrent modification to an
* application. For example, two individuals attempting to edit the same application at the same time.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - LimitExceededException Exceeded the maximum limit for connections.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.DeleteSyncConfiguration
* @see AWS API Documentation
*/
@Override
public CompletableFuture deleteSyncConfiguration(
DeleteSyncConfigurationRequest deleteSyncConfigurationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteSyncConfigurationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteSyncConfigurationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteSyncConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteSyncConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteSyncConfiguration").withProtocolMetadata(protocolMetadata)
.withMarshaller(new DeleteSyncConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(deleteSyncConfigurationRequest));
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);
}
}
/**
*
* Returns the connection ARN and details such as status, owner, and provider type.
*
*
* @param getConnectionRequest
* @return A Java Future containing the result of the GetConnection 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.
*
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ResourceUnavailableException Resource not found. Verify the ARN for the host resource and try again.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.GetConnection
* @see AWS API Documentation
*/
@Override
public CompletableFuture getConnection(GetConnectionRequest getConnectionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getConnectionRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getConnectionRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetConnection");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetConnectionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetConnection").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetConnectionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getConnectionRequest));
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);
}
}
/**
*
* Returns the host ARN and details such as status, provider type, endpoint, and, if applicable, the VPC
* configuration.
*
*
* @param getHostRequest
* @return A Java Future containing the result of the GetHost 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.
*
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ResourceUnavailableException Resource not found. Verify the ARN for the host resource and try again.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.GetHost
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture getHost(GetHostRequest getHostRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getHostRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getHostRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetHost");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetHostResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("GetHost")
.withProtocolMetadata(protocolMetadata).withMarshaller(new GetHostRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getHostRequest));
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);
}
}
/**
*
* Returns details about a repository link. A repository link allows Git sync to monitor and sync changes from files
* in a specified Git repository.
*
*
* @param getRepositoryLinkRequest
* @return A Java Future containing the result of the GetRepositoryLink 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ConcurrentModificationException Exception thrown as a result of concurrent modification to an
* application. For example, two individuals attempting to edit the same application at the same time.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.GetRepositoryLink
* @see AWS API Documentation
*/
@Override
public CompletableFuture getRepositoryLink(GetRepositoryLinkRequest getRepositoryLinkRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getRepositoryLinkRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getRepositoryLinkRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetRepositoryLink");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetRepositoryLinkResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetRepositoryLink").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetRepositoryLinkRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getRepositoryLinkRequest));
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);
}
}
/**
*
* Returns details about the sync status for a repository. A repository sync uses Git sync to push and pull changes
* from your remote repository.
*
*
* @param getRepositorySyncStatusRequest
* @return A Java Future containing the result of the GetRepositorySyncStatus 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.GetRepositorySyncStatus
* @see AWS API Documentation
*/
@Override
public CompletableFuture getRepositorySyncStatus(
GetRepositorySyncStatusRequest getRepositorySyncStatusRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getRepositorySyncStatusRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getRepositorySyncStatusRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetRepositorySyncStatus");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetRepositorySyncStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetRepositorySyncStatus").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetRepositorySyncStatusRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getRepositorySyncStatusRequest));
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);
}
}
/**
*
* Returns the status of the sync with the Git repository for a specific Amazon Web Services resource.
*
*
* @param getResourceSyncStatusRequest
* @return A Java Future containing the result of the GetResourceSyncStatus 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.GetResourceSyncStatus
* @see AWS API Documentation
*/
@Override
public CompletableFuture getResourceSyncStatus(
GetResourceSyncStatusRequest getResourceSyncStatusRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getResourceSyncStatusRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getResourceSyncStatusRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetResourceSyncStatus");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetResourceSyncStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetResourceSyncStatus").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetResourceSyncStatusRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getResourceSyncStatusRequest));
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);
}
}
/**
*
* Returns a list of the most recent sync blockers.
*
*
* @param getSyncBlockerSummaryRequest
* @return A Java Future containing the result of the GetSyncBlockerSummary 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.GetSyncBlockerSummary
* @see AWS API Documentation
*/
@Override
public CompletableFuture getSyncBlockerSummary(
GetSyncBlockerSummaryRequest getSyncBlockerSummaryRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getSyncBlockerSummaryRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getSyncBlockerSummaryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetSyncBlockerSummary");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetSyncBlockerSummaryResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetSyncBlockerSummary").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetSyncBlockerSummaryRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getSyncBlockerSummaryRequest));
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);
}
}
/**
*
* Returns details about a sync configuration, including the sync type and resource name. A sync configuration
* allows the configuration to sync (push and pull) changes from the remote repository for a specified branch in a
* Git repository.
*
*
* @param getSyncConfigurationRequest
* @return A Java Future containing the result of the GetSyncConfiguration 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.GetSyncConfiguration
* @see AWS API Documentation
*/
@Override
public CompletableFuture getSyncConfiguration(
GetSyncConfigurationRequest getSyncConfigurationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getSyncConfigurationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getSyncConfigurationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetSyncConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetSyncConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetSyncConfiguration").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetSyncConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getSyncConfigurationRequest));
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 the connections associated with your account.
*
*
* @param listConnectionsRequest
* @return A Java Future containing the result of the ListConnections 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.
*
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.ListConnections
* @see AWS API Documentation
*/
@Override
public CompletableFuture listConnections(ListConnectionsRequest listConnectionsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listConnectionsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listConnectionsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListConnections");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListConnectionsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListConnections").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListConnectionsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listConnectionsRequest));
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 the hosts associated with your account.
*
*
* @param listHostsRequest
* @return A Java Future containing the result of the ListHosts 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.
*
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.ListHosts
* @see AWS API Documentation
*/
@Override
public CompletableFuture listHosts(ListHostsRequest listHostsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listHostsRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listHostsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListHosts");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListHostsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("ListHosts")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListHostsRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withInput(listHostsRequest));
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 the repository links created for connections in your account.
*
*
* @param listRepositoryLinksRequest
* @return A Java Future containing the result of the ListRepositoryLinks 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ConcurrentModificationException Exception thrown as a result of concurrent modification to an
* application. For example, two individuals attempting to edit the same application at the same time.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.ListRepositoryLinks
* @see AWS API Documentation
*/
@Override
public CompletableFuture listRepositoryLinks(
ListRepositoryLinksRequest listRepositoryLinksRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listRepositoryLinksRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listRepositoryLinksRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListRepositoryLinks");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListRepositoryLinksResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListRepositoryLinks").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListRepositoryLinksRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listRepositoryLinksRequest));
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 the repository sync definitions for repository links in your account.
*
*
* @param listRepositorySyncDefinitionsRequest
* @return A Java Future containing the result of the ListRepositorySyncDefinitions 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.ListRepositorySyncDefinitions
* @see AWS API Documentation
*/
@Override
public CompletableFuture listRepositorySyncDefinitions(
ListRepositorySyncDefinitionsRequest listRepositorySyncDefinitionsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listRepositorySyncDefinitionsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
listRepositorySyncDefinitionsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListRepositorySyncDefinitions");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListRepositorySyncDefinitionsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListRepositorySyncDefinitions").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListRepositorySyncDefinitionsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listRepositorySyncDefinitionsRequest));
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);
}
}
/**
*
* Returns a list of sync configurations for a specified repository.
*
*
* @param listSyncConfigurationsRequest
* @return A Java Future containing the result of the ListSyncConfigurations 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.ListSyncConfigurations
* @see AWS API Documentation
*/
@Override
public CompletableFuture listSyncConfigurations(
ListSyncConfigurationsRequest listSyncConfigurationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listSyncConfigurationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listSyncConfigurationsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListSyncConfigurations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListSyncConfigurationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListSyncConfigurations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListSyncConfigurationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listSyncConfigurationsRequest));
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 set of key-value pairs (metadata) that are used to manage the resource.
*
*
* @param listTagsForResourceRequest
* @return A Java Future containing the result of the ListTagsForResource 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.
*
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.ListTagsForResource
* @see AWS API Documentation
*/
@Override
public CompletableFuture listTagsForResource(
ListTagsForResourceRequest listTagsForResourceRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listTagsForResourceRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagsForResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListTagsForResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListTagsForResource").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listTagsForResourceRequest));
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);
}
}
/**
*
* Adds to or modifies the tags of the given resource. Tags are metadata that can be used to manage a resource.
*
*
* @param tagResourceRequest
* @return A Java Future containing the result of the TagResource 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.
*
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - LimitExceededException Exceeded the maximum limit for connections.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.TagResource
* @see AWS API Documentation
*/
@Override
public CompletableFuture tagResource(TagResourceRequest tagResourceRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(tagResourceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, tagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
TagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("TagResource").withProtocolMetadata(protocolMetadata)
.withMarshaller(new TagResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(tagResourceRequest));
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);
}
}
/**
*
* Removes tags from an Amazon Web Services resource.
*
*
* @param untagResourceRequest
* @return A Java Future containing the result of the UntagResource 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.
*
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.UntagResource
* @see AWS API Documentation
*/
@Override
public CompletableFuture untagResource(UntagResourceRequest untagResourceRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(untagResourceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, untagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UntagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UntagResource").withProtocolMetadata(protocolMetadata)
.withMarshaller(new UntagResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(untagResourceRequest));
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);
}
}
/**
*
* Updates a specified host with the provided configurations.
*
*
* @param updateHostRequest
* @return A Java Future containing the result of the UpdateHost 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.
*
* - ConflictException Two conflicting operations have been made on the same resource.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ResourceUnavailableException Resource not found. Verify the ARN for the host resource and try again.
* - UnsupportedOperationException The operation is not supported. Check the connection status and try
* again.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.UpdateHost
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateHost(UpdateHostRequest updateHostRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateHostRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateHostRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateHost");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UpdateHostResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("UpdateHost")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new UpdateHostRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(updateHostRequest));
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);
}
}
/**
*
* Updates the association between your connection and a specified external Git repository. A repository link allows
* Git sync to monitor and sync changes to files in a specified Git repository.
*
*
* @param updateRepositoryLinkRequest
* @return A Java Future containing the result of the UpdateRepositoryLink 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ConditionalCheckFailedException The conditional check failed. Try again later.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ThrottlingException The request was denied due to request throttling.
* - UpdateOutOfSyncException The update is out of sync. Try syncing again.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.UpdateRepositoryLink
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateRepositoryLink(
UpdateRepositoryLinkRequest updateRepositoryLinkRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateRepositoryLinkRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateRepositoryLinkRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateRepositoryLink");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateRepositoryLinkResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateRepositoryLink").withProtocolMetadata(protocolMetadata)
.withMarshaller(new UpdateRepositoryLinkRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(updateRepositoryLinkRequest));
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);
}
}
/**
*
* Allows you to update the status of a sync blocker, resolving the blocker and allowing syncing to continue.
*
*
* @param updateSyncBlockerRequest
* @return A Java Future containing the result of the UpdateSyncBlocker 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - RetryLatestCommitFailedException Retrying the latest commit failed. Try again later.
* - SyncBlockerDoesNotExistException Unable to continue. The sync blocker does not exist.
* - ThrottlingException The request was denied due to request throttling.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.UpdateSyncBlocker
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateSyncBlocker(UpdateSyncBlockerRequest updateSyncBlockerRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateSyncBlockerRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateSyncBlockerRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateSyncBlocker");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateSyncBlockerResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateSyncBlocker").withProtocolMetadata(protocolMetadata)
.withMarshaller(new UpdateSyncBlockerRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(updateSyncBlockerRequest));
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);
}
}
/**
*
* Updates the sync configuration for your connection and a specified external Git repository.
*
*
* @param updateSyncConfigurationRequest
* @return A Java Future containing the result of the UpdateSyncConfiguration 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.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ConcurrentModificationException Exception thrown as a result of concurrent modification to an
* application. For example, two individuals attempting to edit the same application at the same time.
* - InternalServerException Received an internal server exception. Try again later.
* - InvalidInputException The input is not valid. Verify that the action is typed correctly.
* - ResourceNotFoundException Resource not found. Verify the connection resource ARN and try again.
* - ThrottlingException The request was denied due to request throttling.
* - UpdateOutOfSyncException The update is out of sync. Try syncing again.
* - 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.
* - CodeStarConnectionsException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample CodeStarConnectionsAsyncClient.UpdateSyncConfiguration
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateSyncConfiguration(
UpdateSyncConfigurationRequest updateSyncConfigurationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateSyncConfigurationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateSyncConfigurationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeStar connections");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateSyncConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateSyncConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateSyncConfiguration").withProtocolMetadata(protocolMetadata)
.withMarshaller(new UpdateSyncConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(updateSyncConfigurationRequest));
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 CodeStarConnectionsServiceClientConfiguration serviceClientConfiguration() {
return new CodeStarConnectionsServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(CodeStarConnectionsException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.0")
.registerModeledException(
ExceptionMetadata.builder().errorCode("AccessDeniedException")
.exceptionBuilderSupplier(AccessDeniedException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ConcurrentModificationException")
.exceptionBuilderSupplier(ConcurrentModificationException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("SyncBlockerDoesNotExistException")
.exceptionBuilderSupplier(SyncBlockerDoesNotExistException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ConflictException")
.exceptionBuilderSupplier(ConflictException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("UnsupportedOperationException")
.exceptionBuilderSupplier(UnsupportedOperationException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInputException")
.exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("UnsupportedProviderTypeException")
.exceptionBuilderSupplier(UnsupportedProviderTypeException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceUnavailableException")
.exceptionBuilderSupplier(ResourceUnavailableException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ThrottlingException")
.exceptionBuilderSupplier(ThrottlingException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("SyncConfigurationStillExistsException")
.exceptionBuilderSupplier(SyncConfigurationStillExistsException::builder).httpStatusCode(400)
.build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("UpdateOutOfSyncException")
.exceptionBuilderSupplier(UpdateOutOfSyncException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("RetryLatestCommitFailedException")
.exceptionBuilderSupplier(RetryLatestCommitFailedException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ConditionalCheckFailedException")
.exceptionBuilderSupplier(ConditionalCheckFailedException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServerException")
.exceptionBuilderSupplier(InternalServerException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceAlreadyExistsException")
.exceptionBuilderSupplier(ResourceAlreadyExistsException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("LimitExceededException")
.exceptionBuilderSupplier(LimitExceededException::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();
}
CodeStarConnectionsServiceClientConfigurationBuilder serviceConfigBuilder = new CodeStarConnectionsServiceClientConfigurationBuilder(
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();
}
}