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

com.amazonaws.services.pricing.AWSPricingClient Maven / Gradle / Ivy

Go to download

The AWS Java SDK for AWS Pricing module holds the client classes that are used for communicating with AWS Pricing Service

There is a newer version: 1.12.772
Show newest version
/*
 * Copyright 2019-2024 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 com.amazonaws.services.pricing;

import org.w3c.dom.*;

import java.net.*;
import java.util.*;

import javax.annotation.Generated;

import org.apache.commons.logging.*;

import com.amazonaws.*;
import com.amazonaws.annotation.SdkInternalApi;
import com.amazonaws.auth.*;

import com.amazonaws.handlers.*;
import com.amazonaws.http.*;
import com.amazonaws.internal.*;
import com.amazonaws.internal.auth.*;
import com.amazonaws.metrics.*;
import com.amazonaws.regions.*;
import com.amazonaws.transform.*;
import com.amazonaws.util.*;
import com.amazonaws.protocol.json.*;
import com.amazonaws.util.AWSRequestMetrics.Field;
import com.amazonaws.annotation.ThreadSafe;
import com.amazonaws.client.AwsSyncClientParams;
import com.amazonaws.client.builder.AdvancedConfig;

import com.amazonaws.services.pricing.AWSPricingClientBuilder;

import com.amazonaws.AmazonServiceException;

import com.amazonaws.services.pricing.model.*;

import com.amazonaws.services.pricing.model.transform.*;

/**
 * Client for accessing AWS Pricing. All service calls made using this client are blocking, and will not return until
 * the service call completes.
 * 

*

* The Amazon Web Services Price List API is a centralized and convenient way to programmatically query Amazon Web * Services for services, products, and pricing information. The Amazon Web Services Price List uses standardized * product attributes such as Location, Storage Class, and Operating System, and * provides prices at the SKU level. You can use the Amazon Web Services Price List to do the following: *

*
    *
  • *

    * Build cost control and scenario planning tools *

    *
  • *
  • *

    * Reconcile billing data *

    *
  • *
  • *

    * Forecast future spend for budgeting purposes *

    *
  • *
  • *

    * Provide cost benefit analysis that compare your internal workloads with Amazon Web Services *

    *
  • *
*

* Use GetServices without a service code to retrieve the service codes for all Amazon Web Services, then * GetServices with a service code to retrieve the attribute names for that service. After you have the * service code and attribute names, you can use GetAttributeValues to see what values are available for an * attribute. With the service code and an attribute name and value, you can use GetProducts to find * specific products that you're interested in, such as an AmazonEC2 instance, with a * Provisioned IOPS volumeType. *

*

* For more information, see Using the Amazon Web Services * Price List API in the Billing User Guide. *

*/ @ThreadSafe @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AWSPricingClient extends AmazonWebServiceClient implements AWSPricing { /** Provider for AWS credentials. */ private final AWSCredentialsProvider awsCredentialsProvider; private static final Log log = LogFactory.getLog(AWSPricing.class); /** Default signing name for the service. */ private static final String DEFAULT_SIGNING_NAME = "pricing"; /** Client configuration factory providing ClientConfigurations tailored to this client */ protected static final ClientConfigurationFactory configFactory = new ClientConfigurationFactory(); private final AdvancedConfig advancedConfig; private static final com.amazonaws.protocol.json.SdkJsonProtocolFactory protocolFactory = new com.amazonaws.protocol.json.SdkJsonProtocolFactory( new JsonClientMetadata() .withProtocolVersion("1.1") .withSupportsCbor(false) .withSupportsIon(false) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("AccessDeniedException").withExceptionUnmarshaller( com.amazonaws.services.pricing.model.transform.AccessDeniedExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("NotFoundException").withExceptionUnmarshaller( com.amazonaws.services.pricing.model.transform.NotFoundExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("InternalErrorException").withExceptionUnmarshaller( com.amazonaws.services.pricing.model.transform.InternalErrorExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("InvalidParameterException").withExceptionUnmarshaller( com.amazonaws.services.pricing.model.transform.InvalidParameterExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("InvalidNextTokenException").withExceptionUnmarshaller( com.amazonaws.services.pricing.model.transform.InvalidNextTokenExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ExpiredNextTokenException").withExceptionUnmarshaller( com.amazonaws.services.pricing.model.transform.ExpiredNextTokenExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ThrottlingException").withExceptionUnmarshaller( com.amazonaws.services.pricing.model.transform.ThrottlingExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ResourceNotFoundException").withExceptionUnmarshaller( com.amazonaws.services.pricing.model.transform.ResourceNotFoundExceptionUnmarshaller.getInstance())) .withBaseServiceExceptionClass(com.amazonaws.services.pricing.model.AWSPricingException.class)); public static AWSPricingClientBuilder builder() { return AWSPricingClientBuilder.standard(); } /** * Constructs a new client to invoke service methods on AWS Pricing using the specified parameters. * *

* All service calls made using this new client object are blocking, and will not return until the service call * completes. * * @param clientParams * Object providing client parameters. */ AWSPricingClient(AwsSyncClientParams clientParams) { this(clientParams, false); } /** * Constructs a new client to invoke service methods on AWS Pricing using the specified parameters. * *

* All service calls made using this new client object are blocking, and will not return until the service call * completes. * * @param clientParams * Object providing client parameters. */ AWSPricingClient(AwsSyncClientParams clientParams, boolean endpointDiscoveryEnabled) { super(clientParams); this.awsCredentialsProvider = clientParams.getCredentialsProvider(); this.advancedConfig = clientParams.getAdvancedConfig(); init(); } private void init() { setServiceNameIntern(DEFAULT_SIGNING_NAME); setEndpointPrefix(ENDPOINT_PREFIX); // calling this.setEndPoint(...) will also modify the signer accordingly setEndpoint("api.pricing.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/pricing/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/pricing/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); } /** *

* Returns the metadata for one service or a list of the metadata for all services. Use this without a service code * to get the service codes for all services. Use it with a service code, such as AmazonEC2, to get * information specific to that service, such as the attribute names available for that service. For example, some * of the attribute names available for EC2 are volumeType, maxIopsVolume, * operation, locationType, and instanceCapacity10xlarge. *

* * @param describeServicesRequest * @return Result of the DescribeServices operation returned by the service. * @throws InvalidParameterException * One or more parameters had an invalid value. * @throws InvalidNextTokenException * The pagination token is invalid. Try again without a pagination token. * @throws NotFoundException * The requested resource can't be found. * @throws InternalErrorException * An error on the server occurred during the processing of your request. Try again later. * @throws ThrottlingException * You've made too many requests exceeding service quotas. * @throws ExpiredNextTokenException * The pagination token expired. Try again without a pagination token. * @sample AWSPricing.DescribeServices * @see AWS API * Documentation */ @Override public DescribeServicesResult describeServices(DescribeServicesRequest request) { request = beforeClientExecution(request); return executeDescribeServices(request); } @SdkInternalApi final DescribeServicesResult executeDescribeServices(DescribeServicesRequest describeServicesRequest) { ExecutionContext executionContext = createExecutionContext(describeServicesRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request request = null; Response response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new DescribeServicesRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(describeServicesRequest)); // Binds the request metrics to the current request. request.setAWSRequestMetrics(awsRequestMetrics); request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint); request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden()); request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion()); request.addHandlerContext(HandlerContextKey.SERVICE_ID, "Pricing"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DescribeServices"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new DescribeServicesResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } } /** *

* Returns a list of attribute values. Attributes are similar to the details in a Price List API offer file. For a * list of available attributes, see Offer File * Definitions in the Billing and Cost * Management User Guide. *

* * @param getAttributeValuesRequest * @return Result of the GetAttributeValues operation returned by the service. * @throws InvalidParameterException * One or more parameters had an invalid value. * @throws InvalidNextTokenException * The pagination token is invalid. Try again without a pagination token. * @throws NotFoundException * The requested resource can't be found. * @throws InternalErrorException * An error on the server occurred during the processing of your request. Try again later. * @throws ThrottlingException * You've made too many requests exceeding service quotas. * @throws ExpiredNextTokenException * The pagination token expired. Try again without a pagination token. * @sample AWSPricing.GetAttributeValues * @see AWS API * Documentation */ @Override public GetAttributeValuesResult getAttributeValues(GetAttributeValuesRequest request) { request = beforeClientExecution(request); return executeGetAttributeValues(request); } @SdkInternalApi final GetAttributeValuesResult executeGetAttributeValues(GetAttributeValuesRequest getAttributeValuesRequest) { ExecutionContext executionContext = createExecutionContext(getAttributeValuesRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request request = null; Response response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new GetAttributeValuesRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(getAttributeValuesRequest)); // Binds the request metrics to the current request. request.setAWSRequestMetrics(awsRequestMetrics); request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint); request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden()); request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion()); request.addHandlerContext(HandlerContextKey.SERVICE_ID, "Pricing"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetAttributeValues"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new GetAttributeValuesResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } } /** *

* This feature is in preview release and is subject to change. Your use of Amazon Web Services Price List * API is subject to the Beta Service Participation terms of the Amazon Web Services Service Terms (Section 1.10). *

*

* This returns the URL that you can retrieve your Price List file from. This URL is based on the * PriceListArn and FileFormat that you retrieve from the ListPriceLists response. *

* * @param getPriceListFileUrlRequest * @return Result of the GetPriceListFileUrl operation returned by the service. * @throws InvalidParameterException * One or more parameters had an invalid value. * @throws NotFoundException * The requested resource can't be found. * @throws AccessDeniedException * General authentication failure. The request wasn't signed correctly. * @throws InternalErrorException * An error on the server occurred during the processing of your request. Try again later. * @throws ThrottlingException * You've made too many requests exceeding service quotas. * @throws ResourceNotFoundException * The requested resource can't be found. * @sample AWSPricing.GetPriceListFileUrl * @see AWS * API Documentation */ @Override public GetPriceListFileUrlResult getPriceListFileUrl(GetPriceListFileUrlRequest request) { request = beforeClientExecution(request); return executeGetPriceListFileUrl(request); } @SdkInternalApi final GetPriceListFileUrlResult executeGetPriceListFileUrl(GetPriceListFileUrlRequest getPriceListFileUrlRequest) { ExecutionContext executionContext = createExecutionContext(getPriceListFileUrlRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request request = null; Response response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new GetPriceListFileUrlRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(getPriceListFileUrlRequest)); // Binds the request metrics to the current request. request.setAWSRequestMetrics(awsRequestMetrics); request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint); request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden()); request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion()); request.addHandlerContext(HandlerContextKey.SERVICE_ID, "Pricing"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetPriceListFileUrl"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new GetPriceListFileUrlResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } } /** *

* Returns a list of all products that match the filter criteria. *

* * @param getProductsRequest * @return Result of the GetProducts operation returned by the service. * @throws InvalidParameterException * One or more parameters had an invalid value. * @throws InvalidNextTokenException * The pagination token is invalid. Try again without a pagination token. * @throws NotFoundException * The requested resource can't be found. * @throws InternalErrorException * An error on the server occurred during the processing of your request. Try again later. * @throws ThrottlingException * You've made too many requests exceeding service quotas. * @throws ExpiredNextTokenException * The pagination token expired. Try again without a pagination token. * @sample AWSPricing.GetProducts * @see AWS API * Documentation */ @Override public GetProductsResult getProducts(GetProductsRequest request) { request = beforeClientExecution(request); return executeGetProducts(request); } @SdkInternalApi final GetProductsResult executeGetProducts(GetProductsRequest getProductsRequest) { ExecutionContext executionContext = createExecutionContext(getProductsRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request request = null; Response response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new GetProductsRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(getProductsRequest)); // Binds the request metrics to the current request. request.setAWSRequestMetrics(awsRequestMetrics); request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint); request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden()); request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion()); request.addHandlerContext(HandlerContextKey.SERVICE_ID, "Pricing"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetProducts"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new GetProductsResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } } /** *

* This feature is in preview release and is subject to change. Your use of Amazon Web Services Price List * API is subject to the Beta Service Participation terms of the Amazon Web Services Service Terms (Section 1.10). *

*

* This returns a list of Price List references that the requester if authorized to view, given a * ServiceCode, CurrencyCode, and an EffectiveDate. Use without a * RegionCode filter to list Price List references from all available Amazon Web Services Regions. Use * with a RegionCode filter to get the Price List reference that's specific to a specific Amazon Web * Services Region. You can use the PriceListArn from the response to get your preferred Price List * files through the GetPriceListFileUrl API. *

* * @param listPriceListsRequest * @return Result of the ListPriceLists operation returned by the service. * @throws InvalidParameterException * One or more parameters had an invalid value. * @throws InvalidNextTokenException * The pagination token is invalid. Try again without a pagination token. * @throws NotFoundException * The requested resource can't be found. * @throws AccessDeniedException * General authentication failure. The request wasn't signed correctly. * @throws InternalErrorException * An error on the server occurred during the processing of your request. Try again later. * @throws ThrottlingException * You've made too many requests exceeding service quotas. * @throws ResourceNotFoundException * The requested resource can't be found. * @throws ExpiredNextTokenException * The pagination token expired. Try again without a pagination token. * @sample AWSPricing.ListPriceLists * @see AWS API * Documentation */ @Override public ListPriceListsResult listPriceLists(ListPriceListsRequest request) { request = beforeClientExecution(request); return executeListPriceLists(request); } @SdkInternalApi final ListPriceListsResult executeListPriceLists(ListPriceListsRequest listPriceListsRequest) { ExecutionContext executionContext = createExecutionContext(listPriceListsRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request request = null; Response response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new ListPriceListsRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(listPriceListsRequest)); // Binds the request metrics to the current request. request.setAWSRequestMetrics(awsRequestMetrics); request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint); request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden()); request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion()); request.addHandlerContext(HandlerContextKey.SERVICE_ID, "Pricing"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListPriceLists"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new ListPriceListsResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } } /** * Returns additional metadata for a previously executed successful, request, typically used for debugging issues * where a service isn't acting as expected. This data isn't considered part of the result data returned by an * operation, so it's available through this separate, diagnostic interface. *

* Response metadata is only cached for a limited period of time, so if you need to access this extra diagnostic * information for an executed request, you should use this method to retrieve it as soon as possible after * executing the request. * * @param request * The originally executed request * * @return The response metadata for the specified request, or null if none is available. */ public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) { return client.getResponseMetadataForRequest(request); } /** * Normal invoke with authentication. Credentials are required and may be overriden at the request level. **/ private Response invoke(Request request, HttpResponseHandler> responseHandler, ExecutionContext executionContext) { return invoke(request, responseHandler, executionContext, null, null); } /** * Normal invoke with authentication. Credentials are required and may be overriden at the request level. **/ private Response invoke(Request request, HttpResponseHandler> responseHandler, ExecutionContext executionContext, URI cachedEndpoint, URI uriFromEndpointTrait) { executionContext.setCredentialsProvider(CredentialUtils.getCredentialsProvider(request.getOriginalRequest(), awsCredentialsProvider)); return doInvoke(request, responseHandler, executionContext, cachedEndpoint, uriFromEndpointTrait); } /** * Invoke with no authentication. Credentials are not required and any credentials set on the client or request will * be ignored for this operation. **/ private Response anonymousInvoke(Request request, HttpResponseHandler> responseHandler, ExecutionContext executionContext) { return doInvoke(request, responseHandler, executionContext, null, null); } /** * Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the * ExecutionContext beforehand. **/ private Response doInvoke(Request request, HttpResponseHandler> responseHandler, ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) { if (discoveredEndpoint != null) { request.setEndpoint(discoveredEndpoint); request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery"); } else if (uriFromEndpointTrait != null) { request.setEndpoint(uriFromEndpointTrait); } else { request.setEndpoint(endpoint); } request.setTimeOffset(timeOffset); HttpResponseHandler errorResponseHandler = protocolFactory.createErrorResponseHandler(new JsonErrorResponseMetadata()); return client.execute(request, responseHandler, errorResponseHandler, executionContext); } @com.amazonaws.annotation.SdkInternalApi static com.amazonaws.protocol.json.SdkJsonProtocolFactory getProtocolFactory() { return protocolFactory; } @Override public void shutdown() { super.shutdown(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy