All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.costexplorer.DefaultCostExplorerAsyncClient Maven / Gradle / Ivy

/*
 * Copyright 2015-2020 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.costexplorer;

import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.ApiName;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.util.VersionInfo;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.costexplorer.model.BillExpirationException;
import software.amazon.awssdk.services.costexplorer.model.CostExplorerException;
import software.amazon.awssdk.services.costexplorer.model.CostExplorerRequest;
import software.amazon.awssdk.services.costexplorer.model.CreateCostCategoryDefinitionRequest;
import software.amazon.awssdk.services.costexplorer.model.CreateCostCategoryDefinitionResponse;
import software.amazon.awssdk.services.costexplorer.model.DataUnavailableException;
import software.amazon.awssdk.services.costexplorer.model.DeleteCostCategoryDefinitionRequest;
import software.amazon.awssdk.services.costexplorer.model.DeleteCostCategoryDefinitionResponse;
import software.amazon.awssdk.services.costexplorer.model.DescribeCostCategoryDefinitionRequest;
import software.amazon.awssdk.services.costexplorer.model.DescribeCostCategoryDefinitionResponse;
import software.amazon.awssdk.services.costexplorer.model.GetCostAndUsageRequest;
import software.amazon.awssdk.services.costexplorer.model.GetCostAndUsageResponse;
import software.amazon.awssdk.services.costexplorer.model.GetCostAndUsageWithResourcesRequest;
import software.amazon.awssdk.services.costexplorer.model.GetCostAndUsageWithResourcesResponse;
import software.amazon.awssdk.services.costexplorer.model.GetCostForecastRequest;
import software.amazon.awssdk.services.costexplorer.model.GetCostForecastResponse;
import software.amazon.awssdk.services.costexplorer.model.GetDimensionValuesRequest;
import software.amazon.awssdk.services.costexplorer.model.GetDimensionValuesResponse;
import software.amazon.awssdk.services.costexplorer.model.GetReservationCoverageRequest;
import software.amazon.awssdk.services.costexplorer.model.GetReservationCoverageResponse;
import software.amazon.awssdk.services.costexplorer.model.GetReservationPurchaseRecommendationRequest;
import software.amazon.awssdk.services.costexplorer.model.GetReservationPurchaseRecommendationResponse;
import software.amazon.awssdk.services.costexplorer.model.GetReservationUtilizationRequest;
import software.amazon.awssdk.services.costexplorer.model.GetReservationUtilizationResponse;
import software.amazon.awssdk.services.costexplorer.model.GetRightsizingRecommendationRequest;
import software.amazon.awssdk.services.costexplorer.model.GetRightsizingRecommendationResponse;
import software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansCoverageRequest;
import software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansCoverageResponse;
import software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansPurchaseRecommendationRequest;
import software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansPurchaseRecommendationResponse;
import software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansUtilizationDetailsRequest;
import software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansUtilizationDetailsResponse;
import software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansUtilizationRequest;
import software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansUtilizationResponse;
import software.amazon.awssdk.services.costexplorer.model.GetTagsRequest;
import software.amazon.awssdk.services.costexplorer.model.GetTagsResponse;
import software.amazon.awssdk.services.costexplorer.model.GetUsageForecastRequest;
import software.amazon.awssdk.services.costexplorer.model.GetUsageForecastResponse;
import software.amazon.awssdk.services.costexplorer.model.InvalidNextTokenException;
import software.amazon.awssdk.services.costexplorer.model.LimitExceededException;
import software.amazon.awssdk.services.costexplorer.model.ListCostCategoryDefinitionsRequest;
import software.amazon.awssdk.services.costexplorer.model.ListCostCategoryDefinitionsResponse;
import software.amazon.awssdk.services.costexplorer.model.RequestChangedException;
import software.amazon.awssdk.services.costexplorer.model.ResourceNotFoundException;
import software.amazon.awssdk.services.costexplorer.model.ServiceQuotaExceededException;
import software.amazon.awssdk.services.costexplorer.model.UnresolvableUsageUnitException;
import software.amazon.awssdk.services.costexplorer.model.UpdateCostCategoryDefinitionRequest;
import software.amazon.awssdk.services.costexplorer.model.UpdateCostCategoryDefinitionResponse;
import software.amazon.awssdk.services.costexplorer.paginators.GetSavingsPlansCoveragePublisher;
import software.amazon.awssdk.services.costexplorer.paginators.GetSavingsPlansUtilizationDetailsPublisher;
import software.amazon.awssdk.services.costexplorer.transform.CreateCostCategoryDefinitionRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.DeleteCostCategoryDefinitionRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.DescribeCostCategoryDefinitionRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetCostAndUsageRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetCostAndUsageWithResourcesRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetCostForecastRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetDimensionValuesRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetReservationCoverageRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetReservationPurchaseRecommendationRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetReservationUtilizationRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetRightsizingRecommendationRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetSavingsPlansCoverageRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetSavingsPlansPurchaseRecommendationRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetSavingsPlansUtilizationDetailsRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetSavingsPlansUtilizationRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetTagsRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.GetUsageForecastRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.ListCostCategoryDefinitionsRequestMarshaller;
import software.amazon.awssdk.services.costexplorer.transform.UpdateCostCategoryDefinitionRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;

/**
 * Internal implementation of {@link CostExplorerAsyncClient}.
 *
 * @see CostExplorerAsyncClient#builder()
 */
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultCostExplorerAsyncClient implements CostExplorerAsyncClient {
    private static final Logger log = LoggerFactory.getLogger(DefaultCostExplorerAsyncClient.class);

    private final AsyncClientHandler clientHandler;

    private final AwsJsonProtocolFactory protocolFactory;

    private final SdkClientConfiguration clientConfiguration;

    protected DefaultCostExplorerAsyncClient(SdkClientConfiguration clientConfiguration) {
        this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
        this.clientConfiguration = clientConfiguration;
        this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
    }

    @Override
    public final String serviceName() {
        return SERVICE_NAME;
    }

    /**
     * 
     * 

* Cost Category is in public beta for AWS Billing and Cost Management and is subject to change. Your use of * Cost Categories is subject to the Beta Service Participation terms of the AWS Service Terms (Section 1.10). *

*
*

* Creates a new Cost Category with the requested name and rules. *

* * @param createCostCategoryDefinitionRequest * @return A Java Future containing the result of the CreateCostCategoryDefinition operation returned by the * service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • ServiceQuotaExceededException You've reached the limit on the number of resources you can create, or * exceeded the size of an individual resources.
  • *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.CreateCostCategoryDefinition * @see AWS API Documentation */ @Override public CompletableFuture createCostCategoryDefinition( CreateCostCategoryDefinitionRequest createCostCategoryDefinitionRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, CreateCostCategoryDefinitionResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("CreateCostCategoryDefinition") .withMarshaller(new CreateCostCategoryDefinitionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(createCostCategoryDefinitionRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** * *

* Cost Category is in public beta for AWS Billing and Cost Management and is subject to change. Your use of * Cost Categories is subject to the Beta Service Participation terms of the AWS Service Terms (Section 1.10). *

*
*

* Deletes a Cost Category. Expenses from this month going forward will no longer be categorized with this Cost * Category. *

* * @param deleteCostCategoryDefinitionRequest * @return A Java Future containing the result of the DeleteCostCategoryDefinition operation returned by the * service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • ResourceNotFoundException The specified ARN in the request doesn't exist.
  • *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.DeleteCostCategoryDefinition * @see AWS API Documentation */ @Override public CompletableFuture deleteCostCategoryDefinition( DeleteCostCategoryDefinitionRequest deleteCostCategoryDefinitionRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DeleteCostCategoryDefinitionResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DeleteCostCategoryDefinition") .withMarshaller(new DeleteCostCategoryDefinitionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(deleteCostCategoryDefinitionRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** * *

* Cost Category is in public beta for AWS Billing and Cost Management and is subject to change. Your use of * Cost Categories is subject to the Beta Service Participation terms of the AWS Service Terms (Section 1.10). *

*
*

* Returns the name, ARN, rules, definition, and effective dates of a Cost Category that's defined in the account. *

*

* You have the option to use EffectiveOn to return a Cost Category that is active on a specific date. * If there is no EffectiveOn specified, you’ll see a Cost Category that is effective on the current * date. If Cost Category is still effective, EffectiveEnd is omitted in the response. *

* * @param describeCostCategoryDefinitionRequest * @return A Java Future containing the result of the DescribeCostCategoryDefinition operation returned by the * service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • ResourceNotFoundException The specified ARN in the request doesn't exist.
  • *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.DescribeCostCategoryDefinition * @see AWS API Documentation */ @Override public CompletableFuture describeCostCategoryDefinition( DescribeCostCategoryDefinitionRequest describeCostCategoryDefinitionRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DescribeCostCategoryDefinitionResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DescribeCostCategoryDefinition") .withMarshaller(new DescribeCostCategoryDefinitionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(describeCostCategoryDefinitionRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves cost and usage metrics for your account. You can specify which cost and usage-related metric, such as * BlendedCosts or UsageQuantity, that you want the request to return. You can also filter * and group your data by various dimensions, such as SERVICE or AZ, in a specific time * range. For a complete list of valid dimensions, see the GetDimensionValues operation. Master accounts in an organization in AWS Organizations have access to all * member accounts. *

* * @param getCostAndUsageRequest * @return A Java Future containing the result of the GetCostAndUsage operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • BillExpirationException The requested report expired. Update the date interval and try again.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • RequestChangedException Your request parameters changed between pages. Try again with the old * parameters or without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetCostAndUsage * @see AWS API * Documentation */ @Override public CompletableFuture getCostAndUsage(GetCostAndUsageRequest getCostAndUsageRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetCostAndUsageResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetCostAndUsage") .withMarshaller(new GetCostAndUsageRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getCostAndUsageRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves cost and usage metrics with resources for your account. You can specify which cost and usage-related * metric, such as BlendedCosts or UsageQuantity, that you want the request to return. You * can also filter and group your data by various dimensions, such as SERVICE or AZ, in a * specific time range. For a complete list of valid dimensions, see the GetDimensionValues operation. Master accounts in an organization in AWS Organizations have access to all * member accounts. This API is currently available for the Amazon Elastic Compute Cloud – Compute service only. *

* *

* This is an opt-in only feature. You can enable this feature from the Cost Explorer Settings page. For information * on how to access the Settings page, see Controlling Access for Cost * Explorer in the AWS Billing and Cost Management User Guide. *

*
* * @param getCostAndUsageWithResourcesRequest * @return A Java Future containing the result of the GetCostAndUsageWithResources operation returned by the * service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • DataUnavailableException The requested data is unavailable.
  • *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • BillExpirationException The requested report expired. Update the date interval and try again.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • RequestChangedException Your request parameters changed between pages. Try again with the old * parameters or without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetCostAndUsageWithResources * @see AWS API Documentation */ @Override public CompletableFuture getCostAndUsageWithResources( GetCostAndUsageWithResourcesRequest getCostAndUsageWithResourcesRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetCostAndUsageWithResourcesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetCostAndUsageWithResources") .withMarshaller(new GetCostAndUsageWithResourcesRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getCostAndUsageWithResourcesRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves a forecast for how much Amazon Web Services predicts that you will spend over the forecast time period * that you select, based on your past costs. *

* * @param getCostForecastRequest * @return A Java Future containing the result of the GetCostForecast operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetCostForecast * @see AWS API * Documentation */ @Override public CompletableFuture getCostForecast(GetCostForecastRequest getCostForecastRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetCostForecastResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetCostForecast") .withMarshaller(new GetCostForecastRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getCostForecastRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves all available filter values for a specified filter over a period of time. You can search the dimension * values for an arbitrary string. *

* * @param getDimensionValuesRequest * @return A Java Future containing the result of the GetDimensionValues operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • BillExpirationException The requested report expired. Update the date interval and try again.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • RequestChangedException Your request parameters changed between pages. Try again with the old * parameters or without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetDimensionValues * @see AWS API * Documentation */ @Override public CompletableFuture getDimensionValues(GetDimensionValuesRequest getDimensionValuesRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetDimensionValuesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetDimensionValues") .withMarshaller(new GetDimensionValuesRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getDimensionValuesRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves the reservation coverage for your account. This enables you to see how much of your Amazon Elastic * Compute Cloud, Amazon ElastiCache, Amazon Relational Database Service, or Amazon Redshift usage is covered by a * reservation. An organization's master account can see the coverage of the associated member accounts. For any * time period, you can filter data about reservation usage by the following dimensions: *

*
    *
  • *

    * AZ *

    *
  • *
  • *

    * CACHE_ENGINE *

    *
  • *
  • *

    * DATABASE_ENGINE *

    *
  • *
  • *

    * DEPLOYMENT_OPTION *

    *
  • *
  • *

    * INSTANCE_TYPE *

    *
  • *
  • *

    * LINKED_ACCOUNT *

    *
  • *
  • *

    * OPERATING_SYSTEM *

    *
  • *
  • *

    * PLATFORM *

    *
  • *
  • *

    * REGION *

    *
  • *
  • *

    * SERVICE *

    *
  • *
  • *

    * TAG *

    *
  • *
  • *

    * TENANCY *

    *
  • *
*

* To determine valid values for a dimension, use the GetDimensionValues operation. *

* * @param getReservationCoverageRequest * You can use the following request parameters to query for how much of your instance usage a reservation * covered. * @return A Java Future containing the result of the GetReservationCoverage operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetReservationCoverage * @see AWS API * Documentation */ @Override public CompletableFuture getReservationCoverage( GetReservationCoverageRequest getReservationCoverageRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetReservationCoverageResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetReservationCoverage") .withMarshaller(new GetReservationCoverageRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getReservationCoverageRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Gets recommendations for which reservations to purchase. These recommendations could help you reduce your costs. * Reservations provide a discounted hourly rate (up to 75%) compared to On-Demand pricing. *

*

* AWS generates your recommendations by identifying your On-Demand usage during a specific time period and * collecting your usage into categories that are eligible for a reservation. After AWS has these categories, it * simulates every combination of reservations in each category of usage to identify the best number of each type of * RI to purchase to maximize your estimated savings. *

*

* For example, AWS automatically aggregates your Amazon EC2 Linux, shared tenancy, and c4 family usage in the US * West (Oregon) Region and recommends that you buy size-flexible regional reservations to apply to the c4 family * usage. AWS recommends the smallest size instance in an instance family. This makes it easier to purchase a * size-flexible RI. AWS also shows the equal number of normalized units so that you can purchase any instance size * that you want. For this example, your RI recommendation would be for c4.large because that is the * smallest size instance in the c4 instance family. *

* * @param getReservationPurchaseRecommendationRequest * @return A Java Future containing the result of the GetReservationPurchaseRecommendation operation returned by the * service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetReservationPurchaseRecommendation * @see AWS API Documentation */ @Override public CompletableFuture getReservationPurchaseRecommendation( GetReservationPurchaseRecommendationRequest getReservationPurchaseRecommendationRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory .createResponseHandler(operationMetadata, GetReservationPurchaseRecommendationResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetReservationPurchaseRecommendation") .withMarshaller(new GetReservationPurchaseRecommendationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getReservationPurchaseRecommendationRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves the reservation utilization for your account. Master accounts in an organization have access to member * accounts. You can filter data by dimensions in a time period. You can use GetDimensionValues to * determine the possible dimension values. Currently, you can group only by SUBSCRIPTION_ID. *

* * @param getReservationUtilizationRequest * @return A Java Future containing the result of the GetReservationUtilization operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetReservationUtilization * @see AWS * API Documentation */ @Override public CompletableFuture getReservationUtilization( GetReservationUtilizationRequest getReservationUtilizationRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetReservationUtilizationResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetReservationUtilization") .withMarshaller(new GetReservationUtilizationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getReservationUtilizationRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Creates recommendations that helps you save cost by identifying idle and underutilized Amazon EC2 instances. *

*

* Recommendations are generated to either downsize or terminate instances, along with providing savings detail and * metrics. For details on calculation and function, see Optimizing Your Cost with * Rightsizing Recommendations. *

* * @param getRightsizingRecommendationRequest * @return A Java Future containing the result of the GetRightsizingRecommendation operation returned by the * service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetRightsizingRecommendation * @see AWS API Documentation */ @Override public CompletableFuture getRightsizingRecommendation( GetRightsizingRecommendationRequest getRightsizingRecommendationRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetRightsizingRecommendationResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetRightsizingRecommendation") .withMarshaller(new GetRightsizingRecommendationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getRightsizingRecommendationRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves the Savings Plans covered for your account. This enables you to see how much of your cost is covered by * a Savings Plan. An organization’s master account can see the coverage of the associated member accounts. For any * time period, you can filter data for Savings Plans usage with the following dimensions: *

*
    *
  • *

    * LINKED_ACCOUNT *

    *
  • *
  • *

    * REGION *

    *
  • *
  • *

    * SERVICE *

    *
  • *
  • *

    * INSTANCE_FAMILY *

    *
  • *
*

* To determine valid values for a dimension, use the GetDimensionValues operation. *

* * @param getSavingsPlansCoverageRequest * @return A Java Future containing the result of the GetSavingsPlansCoverage operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetSavingsPlansCoverage * @see AWS API * Documentation */ @Override public CompletableFuture getSavingsPlansCoverage( GetSavingsPlansCoverageRequest getSavingsPlansCoverageRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetSavingsPlansCoverageResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetSavingsPlansCoverage") .withMarshaller(new GetSavingsPlansCoverageRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getSavingsPlansCoverageRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves the Savings Plans covered for your account. This enables you to see how much of your cost is covered by * a Savings Plan. An organization’s master account can see the coverage of the associated member accounts. For any * time period, you can filter data for Savings Plans usage with the following dimensions: *

*
    *
  • *

    * LINKED_ACCOUNT *

    *
  • *
  • *

    * REGION *

    *
  • *
  • *

    * SERVICE *

    *
  • *
  • *

    * INSTANCE_FAMILY *

    *
  • *
*

* To determine valid values for a dimension, use the GetDimensionValues operation. *

*
*

* This is a variant of * {@link #getSavingsPlansCoverage(software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansCoverageRequest)} * operation. The return type is a custom publisher that can be subscribed to request a stream of response pages. * SDK will internally handle making service calls for you. *

*

* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet * and so there is no guarantee that the request is valid. If there are errors in your request, you will see the * failures only after you start streaming the data. The subscribe method should be called as a request to start * streaming data. For more info, see * {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe * method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the * starting request. *

* *

* The following are few ways to use the response class: *

* 1) Using the subscribe helper method * *
     * {@code
     * software.amazon.awssdk.services.costexplorer.paginators.GetSavingsPlansCoveragePublisher publisher = client.getSavingsPlansCoveragePaginator(request);
     * CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
     * future.get();
     * }
     * 
* * 2) Using a custom subscriber * *
     * {@code
     * software.amazon.awssdk.services.costexplorer.paginators.GetSavingsPlansCoveragePublisher publisher = client.getSavingsPlansCoveragePaginator(request);
     * publisher.subscribe(new Subscriber() {
     * 
     * public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
     * 
     * 
     * public void onNext(software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansCoverageResponse response) { //... };
     * });}
     * 
* * As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2. *

* Note: If you prefer to have control on service calls, use the * {@link #getSavingsPlansCoverage(software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansCoverageRequest)} * operation. *

* * @param getSavingsPlansCoverageRequest * @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetSavingsPlansCoverage * @see AWS API * Documentation */ public GetSavingsPlansCoveragePublisher getSavingsPlansCoveragePaginator( GetSavingsPlansCoverageRequest getSavingsPlansCoverageRequest) { return new GetSavingsPlansCoveragePublisher(this, applyPaginatorUserAgent(getSavingsPlansCoverageRequest)); } /** *

* Retrieves your request parameters, Savings Plan Recommendations Summary and Details. *

* * @param getSavingsPlansPurchaseRecommendationRequest * @return A Java Future containing the result of the GetSavingsPlansPurchaseRecommendation operation returned by * the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetSavingsPlansPurchaseRecommendation * @see AWS API Documentation */ @Override public CompletableFuture getSavingsPlansPurchaseRecommendation( GetSavingsPlansPurchaseRecommendationRequest getSavingsPlansPurchaseRecommendationRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory .createResponseHandler(operationMetadata, GetSavingsPlansPurchaseRecommendationResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetSavingsPlansPurchaseRecommendation") .withMarshaller(new GetSavingsPlansPurchaseRecommendationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getSavingsPlansPurchaseRecommendationRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves the Savings Plans utilization for your account across date ranges with daily or monthly granularity. * Master accounts in an organization have access to member accounts. You can use GetDimensionValues in * SAVINGS_PLANS to determine the possible dimension values. *

* *

* You cannot group by any dimension values for GetSavingsPlansUtilization. *

*
* * @param getSavingsPlansUtilizationRequest * @return A Java Future containing the result of the GetSavingsPlansUtilization operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetSavingsPlansUtilization * @see AWS * API Documentation */ @Override public CompletableFuture getSavingsPlansUtilization( GetSavingsPlansUtilizationRequest getSavingsPlansUtilizationRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetSavingsPlansUtilizationResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetSavingsPlansUtilization") .withMarshaller(new GetSavingsPlansUtilizationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getSavingsPlansUtilizationRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves attribute data along with aggregate utilization and savings data for a given time period. This doesn't * support granular or grouped data (daily/monthly) in response. You can't retrieve data by dates in a single * response similar to GetSavingsPlanUtilization, but you have the option to make multiple calls to * GetSavingsPlanUtilizationDetails by providing individual dates. You can use * GetDimensionValues in SAVINGS_PLANS to determine the possible dimension values. *

* *

* GetSavingsPlanUtilizationDetails internally groups data by SavingsPlansArn. *

*
* * @param getSavingsPlansUtilizationDetailsRequest * @return A Java Future containing the result of the GetSavingsPlansUtilizationDetails operation returned by the * service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetSavingsPlansUtilizationDetails * @see AWS API Documentation */ @Override public CompletableFuture getSavingsPlansUtilizationDetails( GetSavingsPlansUtilizationDetailsRequest getSavingsPlansUtilizationDetailsRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory .createResponseHandler(operationMetadata, GetSavingsPlansUtilizationDetailsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetSavingsPlansUtilizationDetails") .withMarshaller(new GetSavingsPlansUtilizationDetailsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getSavingsPlansUtilizationDetailsRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves attribute data along with aggregate utilization and savings data for a given time period. This doesn't * support granular or grouped data (daily/monthly) in response. You can't retrieve data by dates in a single * response similar to GetSavingsPlanUtilization, but you have the option to make multiple calls to * GetSavingsPlanUtilizationDetails by providing individual dates. You can use * GetDimensionValues in SAVINGS_PLANS to determine the possible dimension values. *

* *

* GetSavingsPlanUtilizationDetails internally groups data by SavingsPlansArn. *

*

*

* This is a variant of * {@link #getSavingsPlansUtilizationDetails(software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansUtilizationDetailsRequest)} * operation. The return type is a custom publisher that can be subscribed to request a stream of response pages. * SDK will internally handle making service calls for you. *

*

* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet * and so there is no guarantee that the request is valid. If there are errors in your request, you will see the * failures only after you start streaming the data. The subscribe method should be called as a request to start * streaming data. For more info, see * {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe * method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the * starting request. *

* *

* The following are few ways to use the response class: *

* 1) Using the subscribe helper method * *
     * {@code
     * software.amazon.awssdk.services.costexplorer.paginators.GetSavingsPlansUtilizationDetailsPublisher publisher = client.getSavingsPlansUtilizationDetailsPaginator(request);
     * CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
     * future.get();
     * }
     * 
* * 2) Using a custom subscriber * *
     * {@code
     * software.amazon.awssdk.services.costexplorer.paginators.GetSavingsPlansUtilizationDetailsPublisher publisher = client.getSavingsPlansUtilizationDetailsPaginator(request);
     * publisher.subscribe(new Subscriber() {
     * 
     * public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
     * 
     * 
     * public void onNext(software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansUtilizationDetailsResponse response) { //... };
     * });}
     * 
* * As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2. *

* Note: If you prefer to have control on service calls, use the * {@link #getSavingsPlansUtilizationDetails(software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansUtilizationDetailsRequest)} * operation. *

* * @param getSavingsPlansUtilizationDetailsRequest * @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetSavingsPlansUtilizationDetails * @see AWS API Documentation */ public GetSavingsPlansUtilizationDetailsPublisher getSavingsPlansUtilizationDetailsPaginator( GetSavingsPlansUtilizationDetailsRequest getSavingsPlansUtilizationDetailsRequest) { return new GetSavingsPlansUtilizationDetailsPublisher(this, applyPaginatorUserAgent(getSavingsPlansUtilizationDetailsRequest)); } /** *

* Queries for available tag keys and tag values for a specified period. You can search the tag values for an * arbitrary string. *

* * @param getTagsRequest * @return A Java Future containing the result of the GetTags operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • BillExpirationException The requested report expired. Update the date interval and try again.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • InvalidNextTokenException The pagination token is invalid. Try again without a pagination token.
  • *
  • RequestChangedException Your request parameters changed between pages. Try again with the old * parameters or without a pagination token.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetTags * @see AWS API * Documentation */ @Override public CompletableFuture getTags(GetTagsRequest getTagsRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, GetTagsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams().withOperationName("GetTags") .withMarshaller(new GetTagsRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(getTagsRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves a forecast for how much Amazon Web Services predicts that you will use over the forecast time period * that you select, based on your past usage. *

* * @param getUsageForecastRequest * @return A Java Future containing the result of the GetUsageForecast operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • DataUnavailableException The requested data is unavailable.
  • *
  • UnresolvableUsageUnitException Cost Explorer was unable to identify the usage unit. Provide * UsageType/UsageTypeGroup filter selections that contain matching units, for example: * hours.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.GetUsageForecast * @see AWS API * Documentation */ @Override public CompletableFuture getUsageForecast(GetUsageForecastRequest getUsageForecastRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetUsageForecastResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetUsageForecast") .withMarshaller(new GetUsageForecastRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getUsageForecastRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** * *

* Cost Category is in public beta for AWS Billing and Cost Management and is subject to change. Your use of * Cost Categories is subject to the Beta Service Participation terms of the AWS Service Terms (Section 1.10). *

*
*

* Returns the name, ARN and effective dates of all Cost Categories defined in the account. You have the option to * use EffectiveOn to return a list of Cost Categories that were active on a specific date. If there is * no EffectiveOn specified, you’ll see Cost Categories that are effective on the current date. If Cost * Category is still effective, EffectiveEnd is omitted in the response. *

* * @param listCostCategoryDefinitionsRequest * @return A Java Future containing the result of the ListCostCategoryDefinitions operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.ListCostCategoryDefinitions * @see AWS * API Documentation */ @Override public CompletableFuture listCostCategoryDefinitions( ListCostCategoryDefinitionsRequest listCostCategoryDefinitionsRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListCostCategoryDefinitionsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListCostCategoryDefinitions") .withMarshaller(new ListCostCategoryDefinitionsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(listCostCategoryDefinitionsRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } /** * *

* Cost Category is in public beta for AWS Billing and Cost Management and is subject to change. Your use of * Cost Categories is subject to the Beta Service Participation terms of the AWS Service Terms (Section 1.10). *

*
*

* Updates an existing Cost Category. Changes made to the Cost Category rules will be used to categorize the current * month’s expenses and future expenses. This won’t change categorization for the previous months. *

* * @param updateCostCategoryDefinitionRequest * @return A Java Future containing the result of the UpdateCostCategoryDefinition operation returned by the * service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • ResourceNotFoundException The specified ARN in the request doesn't exist.
  • *
  • ServiceQuotaExceededException You've reached the limit on the number of resources you can create, or * exceeded the size of an individual resources.
  • *
  • LimitExceededException You made too many calls in a short period of time. Try again later.
  • *
  • 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.
  • *
  • CostExplorerException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample CostExplorerAsyncClient.UpdateCostCategoryDefinition * @see AWS API Documentation */ @Override public CompletableFuture updateCostCategoryDefinition( UpdateCostCategoryDefinitionRequest updateCostCategoryDefinitionRequest) { try { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, UpdateCostCategoryDefinitionResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("UpdateCostCategoryDefinition") .withMarshaller(new UpdateCostCategoryDefinitionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(updateCostCategoryDefinitionRequest)); return executeFuture; } catch (Throwable t) { return CompletableFutureUtils.failedFuture(t); } } @Override public void close() { clientHandler.close(); } private > T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(CostExplorerException::builder) .protocol(AwsJsonProtocol.AWS_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("UnresolvableUsageUnitException") .exceptionBuilderSupplier(UnresolvableUsageUnitException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("RequestChangedException") .exceptionBuilderSupplier(RequestChangedException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("DataUnavailableException") .exceptionBuilderSupplier(DataUnavailableException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ServiceQuotaExceededException") .exceptionBuilderSupplier(ServiceQuotaExceededException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidNextTokenException") .exceptionBuilderSupplier(InvalidNextTokenException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("LimitExceededException") .exceptionBuilderSupplier(LimitExceededException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ResourceNotFoundException") .exceptionBuilderSupplier(ResourceNotFoundException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("BillExpirationException") .exceptionBuilderSupplier(BillExpirationException::builder).build()); } private T applyPaginatorUserAgent(T request) { Consumer userAgentApplier = b -> b.addApiName(ApiName.builder() .version(VersionInfo.SDK_VERSION).name("PAGINATED").build()); AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration() .map(c -> c.toBuilder().applyMutation(userAgentApplier).build()) .orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build())); return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy