software.amazon.awssdk.services.codegurureviewer.DefaultCodeGuruReviewerAsyncClient Maven / Gradle / Ivy
Show all versions of codegurureviewer 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.codegurureviewer;
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.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.ApiName;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
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.util.VersionInfo;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.codegurureviewer.model.AccessDeniedException;
import software.amazon.awssdk.services.codegurureviewer.model.AssociateRepositoryRequest;
import software.amazon.awssdk.services.codegurureviewer.model.AssociateRepositoryResponse;
import software.amazon.awssdk.services.codegurureviewer.model.CodeGuruReviewerException;
import software.amazon.awssdk.services.codegurureviewer.model.CodeGuruReviewerRequest;
import software.amazon.awssdk.services.codegurureviewer.model.ConflictException;
import software.amazon.awssdk.services.codegurureviewer.model.CreateCodeReviewRequest;
import software.amazon.awssdk.services.codegurureviewer.model.CreateCodeReviewResponse;
import software.amazon.awssdk.services.codegurureviewer.model.DescribeCodeReviewRequest;
import software.amazon.awssdk.services.codegurureviewer.model.DescribeCodeReviewResponse;
import software.amazon.awssdk.services.codegurureviewer.model.DescribeRecommendationFeedbackRequest;
import software.amazon.awssdk.services.codegurureviewer.model.DescribeRecommendationFeedbackResponse;
import software.amazon.awssdk.services.codegurureviewer.model.DescribeRepositoryAssociationRequest;
import software.amazon.awssdk.services.codegurureviewer.model.DescribeRepositoryAssociationResponse;
import software.amazon.awssdk.services.codegurureviewer.model.DisassociateRepositoryRequest;
import software.amazon.awssdk.services.codegurureviewer.model.DisassociateRepositoryResponse;
import software.amazon.awssdk.services.codegurureviewer.model.InternalServerException;
import software.amazon.awssdk.services.codegurureviewer.model.ListCodeReviewsRequest;
import software.amazon.awssdk.services.codegurureviewer.model.ListCodeReviewsResponse;
import software.amazon.awssdk.services.codegurureviewer.model.ListRecommendationFeedbackRequest;
import software.amazon.awssdk.services.codegurureviewer.model.ListRecommendationFeedbackResponse;
import software.amazon.awssdk.services.codegurureviewer.model.ListRecommendationsRequest;
import software.amazon.awssdk.services.codegurureviewer.model.ListRecommendationsResponse;
import software.amazon.awssdk.services.codegurureviewer.model.ListRepositoryAssociationsRequest;
import software.amazon.awssdk.services.codegurureviewer.model.ListRepositoryAssociationsResponse;
import software.amazon.awssdk.services.codegurureviewer.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.codegurureviewer.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.codegurureviewer.model.NotFoundException;
import software.amazon.awssdk.services.codegurureviewer.model.PutRecommendationFeedbackRequest;
import software.amazon.awssdk.services.codegurureviewer.model.PutRecommendationFeedbackResponse;
import software.amazon.awssdk.services.codegurureviewer.model.ResourceNotFoundException;
import software.amazon.awssdk.services.codegurureviewer.model.TagResourceRequest;
import software.amazon.awssdk.services.codegurureviewer.model.TagResourceResponse;
import software.amazon.awssdk.services.codegurureviewer.model.ThrottlingException;
import software.amazon.awssdk.services.codegurureviewer.model.UntagResourceRequest;
import software.amazon.awssdk.services.codegurureviewer.model.UntagResourceResponse;
import software.amazon.awssdk.services.codegurureviewer.model.ValidationException;
import software.amazon.awssdk.services.codegurureviewer.paginators.ListCodeReviewsPublisher;
import software.amazon.awssdk.services.codegurureviewer.paginators.ListRecommendationFeedbackPublisher;
import software.amazon.awssdk.services.codegurureviewer.paginators.ListRecommendationsPublisher;
import software.amazon.awssdk.services.codegurureviewer.paginators.ListRepositoryAssociationsPublisher;
import software.amazon.awssdk.services.codegurureviewer.transform.AssociateRepositoryRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.CreateCodeReviewRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.DescribeCodeReviewRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.DescribeRecommendationFeedbackRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.DescribeRepositoryAssociationRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.DisassociateRepositoryRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.ListCodeReviewsRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.ListRecommendationFeedbackRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.ListRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.ListRepositoryAssociationsRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.PutRecommendationFeedbackRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.codegurureviewer.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link CodeGuruReviewerAsyncClient}.
*
* @see CodeGuruReviewerAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultCodeGuruReviewerAsyncClient implements CodeGuruReviewerAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultCodeGuruReviewerAsyncClient.class);
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultCodeGuruReviewerAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
/**
*
* Use to associate an AWS CodeCommit repository or a repostory managed by AWS CodeStar Connections with Amazon
* CodeGuru Reviewer. When you associate a repository, CodeGuru Reviewer reviews source code changes in the
* repository's pull requests and provides automatic recommendations. You can view recommendations using the
* CodeGuru Reviewer console. For more information, see Recommendations in Amazon
* CodeGuru Reviewer in the Amazon CodeGuru Reviewer User Guide.
*
*
* If you associate a CodeCommit repository, it must be in the same AWS Region and AWS account where its CodeGuru
* Reviewer code reviews are configured.
*
*
* Bitbucket and GitHub Enterprise Server repositories are managed by AWS CodeStar Connections to connect to
* CodeGuru Reviewer. For more information, see Connect to a repository source provider in the Amazon CodeGuru Reviewer User Guide.
*
*
*
* You cannot use the CodeGuru Reviewer SDK or the AWS CLI to associate a GitHub repository with Amazon CodeGuru
* Reviewer. To associate a GitHub repository, use the console. For more information, see Getting started
* with CodeGuru Reviewer in the CodeGuru Reviewer User Guide.
*
*
*
* @param associateRepositoryRequest
* @return A Java Future containing the result of the AssociateRepository operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ConflictException The requested operation would cause a conflict with the current state of a service
* resource associated with the request. Resolve the conflict before retrying this request.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.AssociateRepository
* @see AWS API Documentation
*/
@Override
public CompletableFuture associateRepository(
AssociateRepositoryRequest associateRepositoryRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, associateRepositoryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "AssociateRepository");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, AssociateRepositoryResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("AssociateRepository")
.withMarshaller(new AssociateRepositoryRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(associateRepositoryRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = associateRepositoryRequest.overrideConfiguration().orElse(
null);
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);
}
}
/**
*
* Use to create a code review with a
* CodeReviewType
of RepositoryAnalysis
. This type of code review analyzes all code
* under a specified branch in an associated repository. PullRequest
code reviews are automatically
* triggered by a pull request so cannot be created using this method.
*
*
* @param createCodeReviewRequest
* @return A Java Future containing the result of the CreateCodeReview operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The resource specified in the request was not found.
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - ConflictException The requested operation would cause a conflict with the current state of a service
* resource associated with the request. Resolve the conflict before retrying this request.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.CreateCodeReview
* @see AWS API Documentation
*/
@Override
public CompletableFuture createCodeReview(CreateCodeReviewRequest createCodeReviewRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, createCodeReviewRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateCodeReview");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateCodeReviewResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateCodeReview")
.withMarshaller(new CreateCodeReviewRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(createCodeReviewRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = createCodeReviewRequest.overrideConfiguration().orElse(null);
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 metadata associated with the code review along with its status.
*
*
* @param describeCodeReviewRequest
* @return A Java Future containing the result of the DescribeCodeReview operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The resource specified in the request was not found.
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.DescribeCodeReview
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeCodeReview(DescribeCodeReviewRequest describeCodeReviewRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeCodeReviewRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeCodeReview");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeCodeReviewResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeCodeReview")
.withMarshaller(new DescribeCodeReviewRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(describeCodeReviewRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = describeCodeReviewRequest.overrideConfiguration()
.orElse(null);
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);
}
}
/**
*
* Describes the customer feedback for a CodeGuru Reviewer recommendation.
*
*
* @param describeRecommendationFeedbackRequest
* @return A Java Future containing the result of the DescribeRecommendationFeedback operation returned by the
* service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The resource specified in the request was not found.
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.DescribeRecommendationFeedback
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeRecommendationFeedback(
DescribeRecommendationFeedbackRequest describeRecommendationFeedbackRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration,
describeRecommendationFeedbackRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeRecommendationFeedback");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeRecommendationFeedbackResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeRecommendationFeedback")
.withMarshaller(new DescribeRecommendationFeedbackRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(describeRecommendationFeedbackRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = describeRecommendationFeedbackRequest.overrideConfiguration()
.orElse(null);
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
* RepositoryAssociation
object that contains information about the requested repository
* association.
*
*
* @param describeRepositoryAssociationRequest
* @return A Java Future containing the result of the DescribeRepositoryAssociation operation returned by the
* service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - NotFoundException The resource specified in the request was not found.
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.DescribeRepositoryAssociation
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeRepositoryAssociation(
DescribeRepositoryAssociationRequest describeRepositoryAssociationRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration,
describeRepositoryAssociationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeRepositoryAssociation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeRepositoryAssociationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeRepositoryAssociation")
.withMarshaller(new DescribeRepositoryAssociationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(describeRepositoryAssociationRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = describeRepositoryAssociationRequest.overrideConfiguration()
.orElse(null);
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 the association between Amazon CodeGuru Reviewer and a repository.
*
*
* @param disassociateRepositoryRequest
* @return A Java Future containing the result of the DisassociateRepository operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - NotFoundException The resource specified in the request was not found.
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ConflictException The requested operation would cause a conflict with the current state of a service
* resource associated with the request. Resolve the conflict before retrying this request.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.DisassociateRepository
* @see AWS API Documentation
*/
@Override
public CompletableFuture disassociateRepository(
DisassociateRepositoryRequest disassociateRepositoryRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, disassociateRepositoryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DisassociateRepository");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DisassociateRepositoryResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DisassociateRepository")
.withMarshaller(new DisassociateRepositoryRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(disassociateRepositoryRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = disassociateRepositoryRequest.overrideConfiguration().orElse(
null);
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 all the code reviews that the customer has created in the past 90 days.
*
*
* @param listCodeReviewsRequest
* @return A Java Future containing the result of the ListCodeReviews operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - ThrottlingException The request was denied due to request throttling.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.ListCodeReviews
* @see AWS API Documentation
*/
@Override
public CompletableFuture listCodeReviews(ListCodeReviewsRequest listCodeReviewsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listCodeReviewsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListCodeReviews");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListCodeReviewsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListCodeReviews")
.withMarshaller(new ListCodeReviewsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listCodeReviewsRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listCodeReviewsRequest.overrideConfiguration().orElse(null);
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 all the code reviews that the customer has created in the past 90 days.
*
*
*
* This is a variant of
* {@link #listCodeReviews(software.amazon.awssdk.services.codegurureviewer.model.ListCodeReviewsRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.codegurureviewer.paginators.ListCodeReviewsPublisher publisher = client.listCodeReviewsPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.codegurureviewer.paginators.ListCodeReviewsPublisher publisher = client.listCodeReviewsPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.codegurureviewer.model.ListCodeReviewsResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listCodeReviews(software.amazon.awssdk.services.codegurureviewer.model.ListCodeReviewsRequest)}
* operation.
*
*
* @param listCodeReviewsRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - ThrottlingException The request was denied due to request throttling.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.ListCodeReviews
* @see AWS API Documentation
*/
public ListCodeReviewsPublisher listCodeReviewsPaginator(ListCodeReviewsRequest listCodeReviewsRequest) {
return new ListCodeReviewsPublisher(this, applyPaginatorUserAgent(listCodeReviewsRequest));
}
/**
*
* Returns a list of
* RecommendationFeedbackSummary
objects that contain customer recommendation feedback for all
* CodeGuru Reviewer users.
*
*
* @param listRecommendationFeedbackRequest
* @return A Java Future containing the result of the ListRecommendationFeedback operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The resource specified in the request was not found.
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.ListRecommendationFeedback
* @see AWS API Documentation
*/
@Override
public CompletableFuture listRecommendationFeedback(
ListRecommendationFeedbackRequest listRecommendationFeedbackRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listRecommendationFeedbackRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListRecommendationFeedback");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListRecommendationFeedbackResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListRecommendationFeedback")
.withMarshaller(new ListRecommendationFeedbackRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listRecommendationFeedbackRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listRecommendationFeedbackRequest.overrideConfiguration()
.orElse(null);
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
* RecommendationFeedbackSummary
objects that contain customer recommendation feedback for all
* CodeGuru Reviewer users.
*
*
*
* This is a variant of
* {@link #listRecommendationFeedback(software.amazon.awssdk.services.codegurureviewer.model.ListRecommendationFeedbackRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.codegurureviewer.paginators.ListRecommendationFeedbackPublisher publisher = client.listRecommendationFeedbackPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.codegurureviewer.paginators.ListRecommendationFeedbackPublisher publisher = client.listRecommendationFeedbackPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.codegurureviewer.model.ListRecommendationFeedbackResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listRecommendationFeedback(software.amazon.awssdk.services.codegurureviewer.model.ListRecommendationFeedbackRequest)}
* operation.
*
*
* @param listRecommendationFeedbackRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The resource specified in the request was not found.
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.ListRecommendationFeedback
* @see AWS API Documentation
*/
public ListRecommendationFeedbackPublisher listRecommendationFeedbackPaginator(
ListRecommendationFeedbackRequest listRecommendationFeedbackRequest) {
return new ListRecommendationFeedbackPublisher(this, applyPaginatorUserAgent(listRecommendationFeedbackRequest));
}
/**
*
* Returns the list of all recommendations for a completed code review.
*
*
* @param listRecommendationsRequest
* @return A Java Future containing the result of the ListRecommendations operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The resource specified in the request was not found.
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.ListRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture listRecommendations(
ListRecommendationsRequest listRecommendationsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listRecommendationsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListRecommendations")
.withMarshaller(new ListRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listRecommendationsRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listRecommendationsRequest.overrideConfiguration().orElse(
null);
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 list of all recommendations for a completed code review.
*
*
*
* This is a variant of
* {@link #listRecommendations(software.amazon.awssdk.services.codegurureviewer.model.ListRecommendationsRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.codegurureviewer.paginators.ListRecommendationsPublisher publisher = client.listRecommendationsPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.codegurureviewer.paginators.ListRecommendationsPublisher publisher = client.listRecommendationsPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.codegurureviewer.model.ListRecommendationsResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listRecommendations(software.amazon.awssdk.services.codegurureviewer.model.ListRecommendationsRequest)}
* operation.
*
*
* @param listRecommendationsRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The resource specified in the request was not found.
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.ListRecommendations
* @see AWS API Documentation
*/
public ListRecommendationsPublisher listRecommendationsPaginator(ListRecommendationsRequest listRecommendationsRequest) {
return new ListRecommendationsPublisher(this, applyPaginatorUserAgent(listRecommendationsRequest));
}
/**
*
* Returns a list of
* RepositoryAssociationSummary
objects that contain summary information about a repository
* association. You can filter the returned list by ProviderType
, Name
, State
, and Owner
.
*
*
* @param listRepositoryAssociationsRequest
* @return A Java Future containing the result of the ListRepositoryAssociations operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.ListRepositoryAssociations
* @see AWS API Documentation
*/
@Override
public CompletableFuture listRepositoryAssociations(
ListRepositoryAssociationsRequest listRepositoryAssociationsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listRepositoryAssociationsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListRepositoryAssociations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListRepositoryAssociationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListRepositoryAssociations")
.withMarshaller(new ListRepositoryAssociationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listRepositoryAssociationsRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listRepositoryAssociationsRequest.overrideConfiguration()
.orElse(null);
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
* RepositoryAssociationSummary
objects that contain summary information about a repository
* association. You can filter the returned list by ProviderType
, Name
, State
, and Owner
.
*
*
*
* This is a variant of
* {@link #listRepositoryAssociations(software.amazon.awssdk.services.codegurureviewer.model.ListRepositoryAssociationsRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.codegurureviewer.paginators.ListRepositoryAssociationsPublisher publisher = client.listRepositoryAssociationsPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.codegurureviewer.paginators.ListRepositoryAssociationsPublisher publisher = client.listRepositoryAssociationsPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.codegurureviewer.model.ListRepositoryAssociationsResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listRepositoryAssociations(software.amazon.awssdk.services.codegurureviewer.model.ListRepositoryAssociationsRequest)}
* operation.
*
*
* @param listRepositoryAssociationsRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.ListRepositoryAssociations
* @see AWS API Documentation
*/
public ListRepositoryAssociationsPublisher listRepositoryAssociationsPaginator(
ListRepositoryAssociationsRequest listRepositoryAssociationsRequest) {
return new ListRepositoryAssociationsPublisher(this, applyPaginatorUserAgent(listRepositoryAssociationsRequest));
}
/**
*
* Returns the list of tags associated with an associated repository 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.
*
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - ResourceNotFoundException The resource specified in the request was not found.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.ListTagsForResource
* @see AWS API Documentation
*/
@Override
public CompletableFuture listTagsForResource(
ListTagsForResourceRequest listTagsForResourceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagsForResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
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")
.withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listTagsForResourceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listTagsForResourceRequest.overrideConfiguration().orElse(
null);
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);
}
}
/**
*
* Stores customer feedback for a CodeGuru Reviewer recommendation. When this API is called again with different
* reactions the previous feedback is overwritten.
*
*
* @param putRecommendationFeedbackRequest
* @return A Java Future containing the result of the PutRecommendationFeedback operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The resource specified in the request was not found.
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.PutRecommendationFeedback
* @see AWS API Documentation
*/
@Override
public CompletableFuture putRecommendationFeedback(
PutRecommendationFeedbackRequest putRecommendationFeedbackRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, putRecommendationFeedbackRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutRecommendationFeedback");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutRecommendationFeedbackResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("PutRecommendationFeedback")
.withMarshaller(new PutRecommendationFeedbackRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(putRecommendationFeedbackRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = putRecommendationFeedbackRequest.overrideConfiguration()
.orElse(null);
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 one or more tags to an associated repository.
*
*
* @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.
*
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - ResourceNotFoundException The resource specified in the request was not found.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.TagResource
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture tagResource(TagResourceRequest tagResourceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, tagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
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").withMarshaller(new TagResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(tagResourceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = tagResourceRequest.overrideConfiguration().orElse(null);
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 a tag from an associated repository.
*
*
* @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.
*
* - InternalServerException The server encountered an internal error and is unable to complete the
* request.
* - ValidationException The input fails to satisfy the specified constraints.
* - ResourceNotFoundException The resource specified in the request was not found.
* - 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.
* - CodeGuruReviewerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample CodeGuruReviewerAsyncClient.UntagResource
* @see AWS API Documentation
*/
@Override
public CompletableFuture untagResource(UntagResourceRequest untagResourceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, untagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "CodeGuru Reviewer");
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")
.withMarshaller(new UntagResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(untagResourceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = untagResourceRequest.overrideConfiguration().orElse(null);
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 void close() {
clientHandler.close();
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(CodeGuruReviewerException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("AccessDeniedException")
.exceptionBuilderSupplier(AccessDeniedException::builder).httpStatusCode(403).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ConflictException")
.exceptionBuilderSupplier(ConflictException::builder).httpStatusCode(409).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(404).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ThrottlingException")
.exceptionBuilderSupplier(ThrottlingException::builder).httpStatusCode(429).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ValidationException")
.exceptionBuilderSupplier(ValidationException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("NotFoundException")
.exceptionBuilderSupplier(NotFoundException::builder).httpStatusCode(404).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServerException")
.exceptionBuilderSupplier(InternalServerException::builder).httpStatusCode(500).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 T applyPaginatorUserAgent(T request) {
Consumer userAgentApplier = b -> b.addApiName(ApiName.builder()
.version(VersionInfo.SDK_VERSION).name("PAGINATED").build());
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(userAgentApplier).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
}