software.amazon.awssdk.services.computeoptimizer.DefaultComputeOptimizerAsyncClient Maven / Gradle / Ivy
Show all versions of computeoptimizer 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.computeoptimizer;
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.computeoptimizer.internal.ComputeOptimizerServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.computeoptimizer.model.AccessDeniedException;
import software.amazon.awssdk.services.computeoptimizer.model.ComputeOptimizerException;
import software.amazon.awssdk.services.computeoptimizer.model.DeleteRecommendationPreferencesRequest;
import software.amazon.awssdk.services.computeoptimizer.model.DeleteRecommendationPreferencesResponse;
import software.amazon.awssdk.services.computeoptimizer.model.DescribeRecommendationExportJobsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.DescribeRecommendationExportJobsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.ExportAutoScalingGroupRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.ExportAutoScalingGroupRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.ExportEbsVolumeRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.ExportEbsVolumeRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.ExportEc2InstanceRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.ExportEc2InstanceRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.ExportEcsServiceRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.ExportEcsServiceRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.ExportLambdaFunctionRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.ExportLambdaFunctionRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.ExportLicenseRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.ExportLicenseRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.ExportRdsDatabaseRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.ExportRdsDatabaseRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetAutoScalingGroupRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetAutoScalingGroupRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetEbsVolumeRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetEbsVolumeRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetEc2InstanceRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetEc2InstanceRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetEc2RecommendationProjectedMetricsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetEc2RecommendationProjectedMetricsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetEcsServiceRecommendationProjectedMetricsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetEcsServiceRecommendationProjectedMetricsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetEcsServiceRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetEcsServiceRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetEffectiveRecommendationPreferencesRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetEffectiveRecommendationPreferencesResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetEnrollmentStatusRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetEnrollmentStatusResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetEnrollmentStatusesForOrganizationRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetEnrollmentStatusesForOrganizationResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetLambdaFunctionRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetLambdaFunctionRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetLicenseRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetLicenseRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetRdsDatabaseRecommendationProjectedMetricsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetRdsDatabaseRecommendationProjectedMetricsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetRdsDatabaseRecommendationsRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetRdsDatabaseRecommendationsResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetRecommendationPreferencesRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetRecommendationPreferencesResponse;
import software.amazon.awssdk.services.computeoptimizer.model.GetRecommendationSummariesRequest;
import software.amazon.awssdk.services.computeoptimizer.model.GetRecommendationSummariesResponse;
import software.amazon.awssdk.services.computeoptimizer.model.InternalServerException;
import software.amazon.awssdk.services.computeoptimizer.model.InvalidParameterValueException;
import software.amazon.awssdk.services.computeoptimizer.model.LimitExceededException;
import software.amazon.awssdk.services.computeoptimizer.model.MissingAuthenticationTokenException;
import software.amazon.awssdk.services.computeoptimizer.model.OptInRequiredException;
import software.amazon.awssdk.services.computeoptimizer.model.PutRecommendationPreferencesRequest;
import software.amazon.awssdk.services.computeoptimizer.model.PutRecommendationPreferencesResponse;
import software.amazon.awssdk.services.computeoptimizer.model.ResourceNotFoundException;
import software.amazon.awssdk.services.computeoptimizer.model.ServiceUnavailableException;
import software.amazon.awssdk.services.computeoptimizer.model.ThrottlingException;
import software.amazon.awssdk.services.computeoptimizer.model.UpdateEnrollmentStatusRequest;
import software.amazon.awssdk.services.computeoptimizer.model.UpdateEnrollmentStatusResponse;
import software.amazon.awssdk.services.computeoptimizer.transform.DeleteRecommendationPreferencesRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.DescribeRecommendationExportJobsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.ExportAutoScalingGroupRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.ExportEbsVolumeRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.ExportEc2InstanceRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.ExportEcsServiceRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.ExportLambdaFunctionRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.ExportLicenseRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.ExportRdsDatabaseRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetAutoScalingGroupRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetEbsVolumeRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetEc2InstanceRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetEc2RecommendationProjectedMetricsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetEcsServiceRecommendationProjectedMetricsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetEcsServiceRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetEffectiveRecommendationPreferencesRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetEnrollmentStatusRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetEnrollmentStatusesForOrganizationRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetLambdaFunctionRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetLicenseRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetRdsDatabaseRecommendationProjectedMetricsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetRdsDatabaseRecommendationsRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetRecommendationPreferencesRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.GetRecommendationSummariesRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.PutRecommendationPreferencesRequestMarshaller;
import software.amazon.awssdk.services.computeoptimizer.transform.UpdateEnrollmentStatusRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link ComputeOptimizerAsyncClient}.
*
* @see ComputeOptimizerAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultComputeOptimizerAsyncClient implements ComputeOptimizerAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultComputeOptimizerAsyncClient.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 DefaultComputeOptimizerAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.SDK_CLIENT, this).build();
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
*
* Deletes a recommendation preference, such as enhanced infrastructure metrics.
*
*
* For more information, see Activating
* enhanced infrastructure metrics in the Compute Optimizer User Guide.
*
*
* @param deleteRecommendationPreferencesRequest
* @return A Java Future containing the result of the DeleteRecommendationPreferences 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.DeleteRecommendationPreferences
* @see AWS API Documentation
*/
@Override
public CompletableFuture deleteRecommendationPreferences(
DeleteRecommendationPreferencesRequest deleteRecommendationPreferencesRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteRecommendationPreferencesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
deleteRecommendationPreferencesRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteRecommendationPreferences");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteRecommendationPreferencesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteRecommendationPreferences").withProtocolMetadata(protocolMetadata)
.withMarshaller(new DeleteRecommendationPreferencesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(deleteRecommendationPreferencesRequest));
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 recommendation export jobs created in the last seven days.
*
*
* Use the ExportAutoScalingGroupRecommendations or ExportEC2InstanceRecommendations actions to
* request an export of your recommendations. Then use the DescribeRecommendationExportJobs action to view
* your export jobs.
*
*
* @param describeRecommendationExportJobsRequest
* @return A Java Future containing the result of the DescribeRecommendationExportJobs 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.DescribeRecommendationExportJobs
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeRecommendationExportJobs(
DescribeRecommendationExportJobsRequest describeRecommendationExportJobsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeRecommendationExportJobsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
describeRecommendationExportJobsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeRecommendationExportJobs");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, DescribeRecommendationExportJobsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeRecommendationExportJobs").withProtocolMetadata(protocolMetadata)
.withMarshaller(new DescribeRecommendationExportJobsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(describeRecommendationExportJobsRequest));
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);
}
}
/**
*
* Exports optimization recommendations for Auto Scaling groups.
*
*
* Recommendations are exported in a comma-separated values (.csv) file, and its metadata in a JavaScript Object
* Notation (JSON) (.json) file, to an existing Amazon Simple Storage Service (Amazon S3) bucket that you specify.
* For more information, see Exporting
* Recommendations in the Compute Optimizer User Guide.
*
*
* You can have only one Auto Scaling group export job in progress per Amazon Web Services Region.
*
*
* @param exportAutoScalingGroupRecommendationsRequest
* @return A Java Future containing the result of the ExportAutoScalingGroupRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - ThrottlingException The request was denied due to request throttling.
* - LimitExceededException The request exceeds a limit of the service.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.ExportAutoScalingGroupRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture exportAutoScalingGroupRecommendations(
ExportAutoScalingGroupRecommendationsRequest exportAutoScalingGroupRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(exportAutoScalingGroupRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
exportAutoScalingGroupRecommendationsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ExportAutoScalingGroupRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, ExportAutoScalingGroupRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ExportAutoScalingGroupRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ExportAutoScalingGroupRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(exportAutoScalingGroupRecommendationsRequest));
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);
}
}
/**
*
* Exports optimization recommendations for Amazon EBS volumes.
*
*
* Recommendations are exported in a comma-separated values (.csv) file, and its metadata in a JavaScript Object
* Notation (JSON) (.json) file, to an existing Amazon Simple Storage Service (Amazon S3) bucket that you specify.
* For more information, see Exporting
* Recommendations in the Compute Optimizer User Guide.
*
*
* You can have only one Amazon EBS volume export job in progress per Amazon Web Services Region.
*
*
* @param exportEbsVolumeRecommendationsRequest
* @return A Java Future containing the result of the ExportEBSVolumeRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - ThrottlingException The request was denied due to request throttling.
* - LimitExceededException The request exceeds a limit of the service.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.ExportEBSVolumeRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture exportEBSVolumeRecommendations(
ExportEbsVolumeRecommendationsRequest exportEbsVolumeRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(exportEbsVolumeRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
exportEbsVolumeRecommendationsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ExportEBSVolumeRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ExportEbsVolumeRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ExportEBSVolumeRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ExportEbsVolumeRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(exportEbsVolumeRecommendationsRequest));
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);
}
}
/**
*
* Exports optimization recommendations for Amazon EC2 instances.
*
*
* Recommendations are exported in a comma-separated values (.csv) file, and its metadata in a JavaScript Object
* Notation (JSON) (.json) file, to an existing Amazon Simple Storage Service (Amazon S3) bucket that you specify.
* For more information, see Exporting
* Recommendations in the Compute Optimizer User Guide.
*
*
* You can have only one Amazon EC2 instance export job in progress per Amazon Web Services Region.
*
*
* @param exportEc2InstanceRecommendationsRequest
* @return A Java Future containing the result of the ExportEC2InstanceRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - ThrottlingException The request was denied due to request throttling.
* - LimitExceededException The request exceeds a limit of the service.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.ExportEC2InstanceRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture exportEC2InstanceRecommendations(
ExportEc2InstanceRecommendationsRequest exportEc2InstanceRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(exportEc2InstanceRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
exportEc2InstanceRecommendationsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ExportEC2InstanceRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, ExportEc2InstanceRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ExportEC2InstanceRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ExportEc2InstanceRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(exportEc2InstanceRecommendationsRequest));
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);
}
}
/**
*
* Exports optimization recommendations for Amazon ECS services on Fargate.
*
*
* Recommendations are exported in a CSV file, and its metadata in a JSON file, to an existing Amazon Simple Storage
* Service (Amazon S3) bucket that you specify. For more information, see Exporting
* Recommendations in the Compute Optimizer User Guide.
*
*
* You can only have one Amazon ECS service export job in progress per Amazon Web Services Region.
*
*
* @param exportEcsServiceRecommendationsRequest
* @return A Java Future containing the result of the ExportECSServiceRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - ThrottlingException The request was denied due to request throttling.
* - LimitExceededException The request exceeds a limit of the service.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.ExportECSServiceRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture exportECSServiceRecommendations(
ExportEcsServiceRecommendationsRequest exportEcsServiceRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(exportEcsServiceRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
exportEcsServiceRecommendationsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ExportECSServiceRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ExportEcsServiceRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ExportECSServiceRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ExportEcsServiceRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(exportEcsServiceRecommendationsRequest));
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);
}
}
/**
*
* Exports optimization recommendations for Lambda functions.
*
*
* Recommendations are exported in a comma-separated values (.csv) file, and its metadata in a JavaScript Object
* Notation (JSON) (.json) file, to an existing Amazon Simple Storage Service (Amazon S3) bucket that you specify.
* For more information, see Exporting
* Recommendations in the Compute Optimizer User Guide.
*
*
* You can have only one Lambda function export job in progress per Amazon Web Services Region.
*
*
* @param exportLambdaFunctionRecommendationsRequest
* @return A Java Future containing the result of the ExportLambdaFunctionRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - ThrottlingException The request was denied due to request throttling.
* - LimitExceededException The request exceeds a limit of the service.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.ExportLambdaFunctionRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture exportLambdaFunctionRecommendations(
ExportLambdaFunctionRecommendationsRequest exportLambdaFunctionRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(exportLambdaFunctionRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
exportLambdaFunctionRecommendationsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ExportLambdaFunctionRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, ExportLambdaFunctionRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ExportLambdaFunctionRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ExportLambdaFunctionRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(exportLambdaFunctionRecommendationsRequest));
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);
}
}
/**
*
* Export optimization recommendations for your licenses.
*
*
* Recommendations are exported in a comma-separated values (CSV) file, and its metadata in a JavaScript Object
* Notation (JSON) file, to an existing Amazon Simple Storage Service (Amazon S3) bucket that you specify. For more
* information, see Exporting
* Recommendations in the Compute Optimizer User Guide.
*
*
* You can have only one license export job in progress per Amazon Web Services Region.
*
*
* @param exportLicenseRecommendationsRequest
* @return A Java Future containing the result of the ExportLicenseRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - ThrottlingException The request was denied due to request throttling.
* - LimitExceededException The request exceeds a limit of the service.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.ExportLicenseRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture exportLicenseRecommendations(
ExportLicenseRecommendationsRequest exportLicenseRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(exportLicenseRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, exportLicenseRecommendationsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ExportLicenseRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ExportLicenseRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ExportLicenseRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ExportLicenseRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(exportLicenseRecommendationsRequest));
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);
}
}
/**
*
* Export optimization recommendations for your Amazon Relational Database Service (Amazon RDS).
*
*
* Recommendations are exported in a comma-separated values (CSV) file, and its metadata in a JavaScript Object
* Notation (JSON) file, to an existing Amazon Simple Storage Service (Amazon S3) bucket that you specify. For more
* information, see Exporting
* Recommendations in the Compute Optimizer User Guide.
*
*
* You can have only one Amazon RDS export job in progress per Amazon Web Services Region.
*
*
* @param exportRdsDatabaseRecommendationsRequest
* @return A Java Future containing the result of the ExportRDSDatabaseRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - ThrottlingException The request was denied due to request throttling.
* - LimitExceededException The request exceeds a limit of the service.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.ExportRDSDatabaseRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture exportRDSDatabaseRecommendations(
ExportRdsDatabaseRecommendationsRequest exportRdsDatabaseRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(exportRdsDatabaseRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
exportRdsDatabaseRecommendationsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ExportRDSDatabaseRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, ExportRdsDatabaseRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ExportRDSDatabaseRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ExportRdsDatabaseRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(exportRdsDatabaseRecommendationsRequest));
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 Auto Scaling group recommendations.
*
*
* Compute Optimizer generates recommendations for Amazon EC2 Auto Scaling groups that meet a specific set of
* requirements. For more information, see the Supported resources and
* requirements in the Compute Optimizer User Guide.
*
*
* @param getAutoScalingGroupRecommendationsRequest
* @return A Java Future containing the result of the GetAutoScalingGroupRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetAutoScalingGroupRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture getAutoScalingGroupRecommendations(
GetAutoScalingGroupRecommendationsRequest getAutoScalingGroupRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getAutoScalingGroupRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getAutoScalingGroupRecommendationsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetAutoScalingGroupRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, GetAutoScalingGroupRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetAutoScalingGroupRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetAutoScalingGroupRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getAutoScalingGroupRecommendationsRequest));
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 Amazon Elastic Block Store (Amazon EBS) volume recommendations.
*
*
* Compute Optimizer generates recommendations for Amazon EBS volumes that meet a specific set of requirements. For
* more information, see the Supported resources and
* requirements in the Compute Optimizer User Guide.
*
*
* @param getEbsVolumeRecommendationsRequest
* @return A Java Future containing the result of the GetEBSVolumeRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetEBSVolumeRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture getEBSVolumeRecommendations(
GetEbsVolumeRecommendationsRequest getEbsVolumeRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getEbsVolumeRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getEbsVolumeRecommendationsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetEBSVolumeRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetEbsVolumeRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetEBSVolumeRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetEbsVolumeRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getEbsVolumeRecommendationsRequest));
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 Amazon EC2 instance recommendations.
*
*
* Compute Optimizer generates recommendations for Amazon Elastic Compute Cloud (Amazon EC2) instances that meet a
* specific set of requirements. For more information, see the Supported resources and
* requirements in the Compute Optimizer User Guide.
*
*
* @param getEc2InstanceRecommendationsRequest
* @return A Java Future containing the result of the GetEC2InstanceRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetEC2InstanceRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture getEC2InstanceRecommendations(
GetEc2InstanceRecommendationsRequest getEc2InstanceRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getEc2InstanceRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getEc2InstanceRecommendationsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetEC2InstanceRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetEc2InstanceRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetEC2InstanceRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetEc2InstanceRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getEc2InstanceRecommendationsRequest));
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 projected utilization metrics of Amazon EC2 instance recommendations.
*
*
*
* The Cpu
and Memory
metrics are the only projected utilization metrics returned when you
* run this action. Additionally, the Memory
metric is returned only for resources that have the
* unified CloudWatch agent installed on them. For more information, see Enabling Memory Utilization
* with the CloudWatch Agent.
*
*
*
* @param getEc2RecommendationProjectedMetricsRequest
* @return A Java Future containing the result of the GetEC2RecommendationProjectedMetrics 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetEC2RecommendationProjectedMetrics
* @see AWS API Documentation
*/
@Override
public CompletableFuture getEC2RecommendationProjectedMetrics(
GetEc2RecommendationProjectedMetricsRequest getEc2RecommendationProjectedMetricsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getEc2RecommendationProjectedMetricsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getEc2RecommendationProjectedMetricsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetEC2RecommendationProjectedMetrics");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, GetEc2RecommendationProjectedMetricsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetEC2RecommendationProjectedMetrics").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetEc2RecommendationProjectedMetricsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getEc2RecommendationProjectedMetricsRequest));
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 projected metrics of Amazon ECS service recommendations.
*
*
* @param getEcsServiceRecommendationProjectedMetricsRequest
* @return A Java Future containing the result of the GetECSServiceRecommendationProjectedMetrics 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetECSServiceRecommendationProjectedMetrics
* @see AWS API Documentation
*/
@Override
public CompletableFuture getECSServiceRecommendationProjectedMetrics(
GetEcsServiceRecommendationProjectedMetricsRequest getEcsServiceRecommendationProjectedMetricsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(
getEcsServiceRecommendationProjectedMetricsRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getEcsServiceRecommendationProjectedMetricsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetECSServiceRecommendationProjectedMetrics");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, GetEcsServiceRecommendationProjectedMetricsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetECSServiceRecommendationProjectedMetrics")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetEcsServiceRecommendationProjectedMetricsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getEcsServiceRecommendationProjectedMetricsRequest));
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 Amazon ECS service recommendations.
*
*
* Compute Optimizer generates recommendations for Amazon ECS services on Fargate that meet a specific set of
* requirements. For more information, see the Supported resources and
* requirements in the Compute Optimizer User Guide.
*
*
* @param getEcsServiceRecommendationsRequest
* @return A Java Future containing the result of the GetECSServiceRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetECSServiceRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture getECSServiceRecommendations(
GetEcsServiceRecommendationsRequest getEcsServiceRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getEcsServiceRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getEcsServiceRecommendationsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetECSServiceRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetEcsServiceRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetECSServiceRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetEcsServiceRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getEcsServiceRecommendationsRequest));
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 recommendation preferences that are in effect for a given resource, such as enhanced infrastructure
* metrics. Considers all applicable preferences that you might have set at the resource, account, and organization
* level.
*
*
* When you create a recommendation preference, you can set its status to Active
or
* Inactive
. Use this action to view the recommendation preferences that are in effect, or
* Active
.
*
*
* @param getEffectiveRecommendationPreferencesRequest
* @return A Java Future containing the result of the GetEffectiveRecommendationPreferences 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetEffectiveRecommendationPreferences
* @see AWS API Documentation
*/
@Override
public CompletableFuture getEffectiveRecommendationPreferences(
GetEffectiveRecommendationPreferencesRequest getEffectiveRecommendationPreferencesRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getEffectiveRecommendationPreferencesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getEffectiveRecommendationPreferencesRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetEffectiveRecommendationPreferences");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, GetEffectiveRecommendationPreferencesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetEffectiveRecommendationPreferences").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetEffectiveRecommendationPreferencesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getEffectiveRecommendationPreferencesRequest));
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 enrollment (opt in) status of an account to the Compute Optimizer service.
*
*
* If the account is the management account of an organization, this action also confirms the enrollment status of
* member accounts of the organization. Use the GetEnrollmentStatusesForOrganization action to get detailed
* information about the enrollment status of member accounts of an organization.
*
*
* @param getEnrollmentStatusRequest
* @return A Java Future containing the result of the GetEnrollmentStatus 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.
*
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetEnrollmentStatus
* @see AWS API Documentation
*/
@Override
public CompletableFuture getEnrollmentStatus(
GetEnrollmentStatusRequest getEnrollmentStatusRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getEnrollmentStatusRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getEnrollmentStatusRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetEnrollmentStatus");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetEnrollmentStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetEnrollmentStatus").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetEnrollmentStatusRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getEnrollmentStatusRequest));
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 Compute Optimizer enrollment (opt-in) status of organization member accounts, if your account is an
* organization management account.
*
*
* To get the enrollment status of standalone accounts, use the GetEnrollmentStatus action.
*
*
* @param getEnrollmentStatusesForOrganizationRequest
* @return A Java Future containing the result of the GetEnrollmentStatusesForOrganization 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.
*
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetEnrollmentStatusesForOrganization
* @see AWS API Documentation
*/
@Override
public CompletableFuture getEnrollmentStatusesForOrganization(
GetEnrollmentStatusesForOrganizationRequest getEnrollmentStatusesForOrganizationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getEnrollmentStatusesForOrganizationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getEnrollmentStatusesForOrganizationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetEnrollmentStatusesForOrganization");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, GetEnrollmentStatusesForOrganizationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetEnrollmentStatusesForOrganization").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetEnrollmentStatusesForOrganizationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getEnrollmentStatusesForOrganizationRequest));
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 Lambda function recommendations.
*
*
* Compute Optimizer generates recommendations for functions that meet a specific set of requirements. For more
* information, see the Supported resources and
* requirements in the Compute Optimizer User Guide.
*
*
* @param getLambdaFunctionRecommendationsRequest
* @return A Java Future containing the result of the GetLambdaFunctionRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - ThrottlingException The request was denied due to request throttling.
* - LimitExceededException The request exceeds a limit of the service.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetLambdaFunctionRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture getLambdaFunctionRecommendations(
GetLambdaFunctionRecommendationsRequest getLambdaFunctionRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getLambdaFunctionRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getLambdaFunctionRecommendationsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetLambdaFunctionRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, GetLambdaFunctionRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetLambdaFunctionRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetLambdaFunctionRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getLambdaFunctionRecommendationsRequest));
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 license recommendations for Amazon EC2 instances that run on a specific license.
*
*
* Compute Optimizer generates recommendations for licenses that meet a specific set of requirements. For more
* information, see the Supported resources and
* requirements in the Compute Optimizer User Guide.
*
*
* @param getLicenseRecommendationsRequest
* @return A Java Future containing the result of the GetLicenseRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetLicenseRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture getLicenseRecommendations(
GetLicenseRecommendationsRequest getLicenseRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getLicenseRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getLicenseRecommendationsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetLicenseRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetLicenseRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetLicenseRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetLicenseRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getLicenseRecommendationsRequest));
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 projected metrics of Amazon RDS recommendations.
*
*
* @param getRdsDatabaseRecommendationProjectedMetricsRequest
* @return A Java Future containing the result of the GetRDSDatabaseRecommendationProjectedMetrics 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetRDSDatabaseRecommendationProjectedMetrics
* @see AWS API Documentation
*/
@Override
public CompletableFuture getRDSDatabaseRecommendationProjectedMetrics(
GetRdsDatabaseRecommendationProjectedMetricsRequest getRdsDatabaseRecommendationProjectedMetricsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(
getRdsDatabaseRecommendationProjectedMetricsRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getRdsDatabaseRecommendationProjectedMetricsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetRDSDatabaseRecommendationProjectedMetrics");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, GetRdsDatabaseRecommendationProjectedMetricsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetRDSDatabaseRecommendationProjectedMetrics")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetRdsDatabaseRecommendationProjectedMetricsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getRdsDatabaseRecommendationProjectedMetricsRequest));
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 Amazon RDS recommendations.
*
*
* Compute Optimizer generates recommendations for Amazon RDS that meet a specific set of requirements. For more
* information, see the Supported resources and
* requirements in the Compute Optimizer User Guide.
*
*
* @param getRdsDatabaseRecommendationsRequest
* @return A Java Future containing the result of the GetRDSDatabaseRecommendations 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetRDSDatabaseRecommendations
* @see AWS API Documentation
*/
@Override
public CompletableFuture getRDSDatabaseRecommendations(
GetRdsDatabaseRecommendationsRequest getRdsDatabaseRecommendationsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getRdsDatabaseRecommendationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getRdsDatabaseRecommendationsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetRDSDatabaseRecommendations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetRdsDatabaseRecommendationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetRDSDatabaseRecommendations").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetRdsDatabaseRecommendationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getRdsDatabaseRecommendationsRequest));
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 existing recommendation preferences, such as enhanced infrastructure metrics.
*
*
* Use the scope
parameter to specify which preferences to return. You can specify to return
* preferences for an organization, a specific account ID, or a specific EC2 instance or Auto Scaling group Amazon
* Resource Name (ARN).
*
*
* For more information, see Activating
* enhanced infrastructure metrics in the Compute Optimizer User Guide.
*
*
* @param getRecommendationPreferencesRequest
* @return A Java Future containing the result of the GetRecommendationPreferences 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetRecommendationPreferences
* @see AWS API Documentation
*/
@Override
public CompletableFuture getRecommendationPreferences(
GetRecommendationPreferencesRequest getRecommendationPreferencesRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getRecommendationPreferencesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getRecommendationPreferencesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetRecommendationPreferences");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetRecommendationPreferencesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetRecommendationPreferences").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetRecommendationPreferencesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getRecommendationPreferencesRequest));
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 optimization findings for an account.
*
*
* It returns the number of:
*
*
* -
*
* Amazon EC2 instances in an account that are Underprovisioned
, Overprovisioned
, or
* Optimized
.
*
*
* -
*
* Auto Scaling groups in an account that are NotOptimized
, or Optimized
.
*
*
* -
*
* Amazon EBS volumes in an account that are NotOptimized
, or Optimized
.
*
*
* -
*
* Lambda functions in an account that are NotOptimized
, or Optimized
.
*
*
* -
*
* Amazon ECS services in an account that are Underprovisioned
, Overprovisioned
, or
* Optimized
.
*
*
*
*
* @param getRecommendationSummariesRequest
* @return A Java Future containing the result of the GetRecommendationSummaries 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.GetRecommendationSummaries
* @see AWS API Documentation
*/
@Override
public CompletableFuture getRecommendationSummaries(
GetRecommendationSummariesRequest getRecommendationSummariesRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getRecommendationSummariesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getRecommendationSummariesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetRecommendationSummaries");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetRecommendationSummariesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetRecommendationSummaries").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetRecommendationSummariesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getRecommendationSummariesRequest));
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 new recommendation preference or updates an existing recommendation preference, such as enhanced
* infrastructure metrics.
*
*
* For more information, see Activating
* enhanced infrastructure metrics in the Compute Optimizer User Guide.
*
*
* @param putRecommendationPreferencesRequest
* @return A Java Future containing the result of the PutRecommendationPreferences 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.
*
* - OptInRequiredException The account is not opted in to Compute Optimizer.
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - ResourceNotFoundException A resource that is required for the action doesn't exist.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.PutRecommendationPreferences
* @see AWS API Documentation
*/
@Override
public CompletableFuture putRecommendationPreferences(
PutRecommendationPreferencesRequest putRecommendationPreferencesRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putRecommendationPreferencesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, putRecommendationPreferencesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutRecommendationPreferences");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutRecommendationPreferencesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("PutRecommendationPreferences").withProtocolMetadata(protocolMetadata)
.withMarshaller(new PutRecommendationPreferencesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(putRecommendationPreferencesRequest));
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 enrollment (opt in and opt out) status of an account to the Compute Optimizer service.
*
*
* If the account is a management account of an organization, this action can also be used to enroll member accounts
* of the organization.
*
*
* You must have the appropriate permissions to opt in to Compute Optimizer, to view its recommendations, and to opt
* out. For more information, see Controlling access with Amazon
* Web Services Identity and Access Management in the Compute Optimizer User Guide.
*
*
* When you opt in, Compute Optimizer automatically creates a service-linked role in your account to access its
* data. For more information, see Using
* Service-Linked Roles for Compute Optimizer in the Compute Optimizer User Guide.
*
*
* @param updateEnrollmentStatusRequest
* @return A Java Future containing the result of the UpdateEnrollmentStatus 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.
*
* - InternalServerException An internal error has occurred. Try your call again.
* - ServiceUnavailableException The request has failed due to a temporary failure of the server.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - InvalidParameterValueException The value supplied for the input parameter is out of range or not
* valid.
* - MissingAuthenticationTokenException The request must contain either a valid (registered) Amazon Web
* Services access key ID or X.509 certificate.
* - 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.
* - ComputeOptimizerException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ComputeOptimizerAsyncClient.UpdateEnrollmentStatus
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateEnrollmentStatus(
UpdateEnrollmentStatusRequest updateEnrollmentStatusRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateEnrollmentStatusRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateEnrollmentStatusRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Compute Optimizer");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateEnrollmentStatus");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateEnrollmentStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateEnrollmentStatus").withProtocolMetadata(protocolMetadata)
.withMarshaller(new UpdateEnrollmentStatusRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(updateEnrollmentStatusRequest));
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 ComputeOptimizerServiceClientConfiguration serviceClientConfiguration() {
return new ComputeOptimizerServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(ComputeOptimizerException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.0")
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServerException")
.exceptionBuilderSupplier(InternalServerException::builder).httpStatusCode(500).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("LimitExceededException")
.exceptionBuilderSupplier(LimitExceededException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("MissingAuthenticationToken")
.exceptionBuilderSupplier(MissingAuthenticationTokenException::builder).httpStatusCode(400)
.build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidParameterValueException")
.exceptionBuilderSupplier(InvalidParameterValueException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ThrottlingException")
.exceptionBuilderSupplier(ThrottlingException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("OptInRequiredException")
.exceptionBuilderSupplier(OptInRequiredException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("AccessDeniedException")
.exceptionBuilderSupplier(AccessDeniedException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceUnavailableException")
.exceptionBuilderSupplier(ServiceUnavailableException::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 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();
}
ComputeOptimizerServiceClientConfigurationBuilder serviceConfigBuilder = new ComputeOptimizerServiceClientConfigurationBuilder(
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();
}
}