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

com.amazonaws.services.pi.AWSPIClient Maven / Gradle / Ivy

Go to download

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

There is a newer version: 1.12.778
Show newest version
/*
 * Copyright 2017-2022 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.pi;

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.pi.AWSPIClientBuilder;

import com.amazonaws.AmazonServiceException;

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

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

* Amazon RDS Performance Insights *

* Amazon RDS Performance Insights enables you to monitor and explore different dimensions of database load based on * data captured from a running DB instance. The guide provides detailed information about Performance Insights data * types, parameters and errors. *

*

* When Performance Insights is enabled, the Amazon RDS Performance Insights API provides visibility into the * performance of your DB instance. Amazon CloudWatch provides the authoritative source for Amazon Web Services * service-vended monitoring metrics. Performance Insights offers a domain-specific view of DB load. *

*

* DB load is measured as average active sessions. Performance Insights provides the data to API consumers as a * two-dimensional time-series dataset. The time dimension provides DB load data for each time point in the queried time * range. Each time point decomposes overall load in relation to the requested dimensions, measured at that time point. * Examples include SQL, Wait event, User, and Host. *

* */ @ThreadSafe @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AWSPIClient extends AmazonWebServiceClient implements AWSPI { /** Provider for AWS credentials. */ private final AWSCredentialsProvider awsCredentialsProvider; private static final Log log = LogFactory.getLog(AWSPI.class); /** Default signing name for the service. */ private static final String DEFAULT_SIGNING_NAME = "pi"; /** 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("NotAuthorizedException").withExceptionUnmarshaller( com.amazonaws.services.pi.model.transform.NotAuthorizedExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("InvalidArgumentException").withExceptionUnmarshaller( com.amazonaws.services.pi.model.transform.InvalidArgumentExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("InternalServiceError").withExceptionUnmarshaller( com.amazonaws.services.pi.model.transform.InternalServiceErrorExceptionUnmarshaller.getInstance())) .withBaseServiceExceptionClass(com.amazonaws.services.pi.model.AWSPIException.class)); public static AWSPIClientBuilder builder() { return AWSPIClientBuilder.standard(); } /** * Constructs a new client to invoke service methods on AWS PI 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. */ AWSPIClient(AwsSyncClientParams clientParams) { this(clientParams, false); } /** * Constructs a new client to invoke service methods on AWS PI 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. */ AWSPIClient(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("pi.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/pi/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/pi/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); } /** *

* For a specific time period, retrieve the top N dimension keys for a metric. *

* *

* Each response element returns a maximum of 500 bytes. For larger elements, such as SQL statements, only the first * 500 bytes are returned. *

*
* * @param describeDimensionKeysRequest * @return Result of the DescribeDimensionKeys operation returned by the service. * @throws InvalidArgumentException * One of the arguments provided is invalid for this request. * @throws InternalServiceErrorException * The request failed due to an unknown error. * @throws NotAuthorizedException * The user is not authorized to perform this request. * @sample AWSPI.DescribeDimensionKeys * @see AWS API * Documentation */ @Override public DescribeDimensionKeysResult describeDimensionKeys(DescribeDimensionKeysRequest request) { request = beforeClientExecution(request); return executeDescribeDimensionKeys(request); } @SdkInternalApi final DescribeDimensionKeysResult executeDescribeDimensionKeys(DescribeDimensionKeysRequest describeDimensionKeysRequest) { ExecutionContext executionContext = createExecutionContext(describeDimensionKeysRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request request = null; Response response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new DescribeDimensionKeysRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(describeDimensionKeysRequest)); // 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, "PI"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DescribeDimensionKeys"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler> responseHandler = protocolFactory .createResponseHandler(new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new DescribeDimensionKeysResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } } /** *

* Get the attributes of the specified dimension group for a DB instance or data source. For example, if you specify * a SQL ID, GetDimensionKeyDetails retrieves the full text of the dimension * db.sql.statement associated with this ID. This operation is useful because * GetResourceMetrics and DescribeDimensionKeys don't support retrieval of large SQL * statement text. *

* * @param getDimensionKeyDetailsRequest * @return Result of the GetDimensionKeyDetails operation returned by the service. * @throws InvalidArgumentException * One of the arguments provided is invalid for this request. * @throws InternalServiceErrorException * The request failed due to an unknown error. * @throws NotAuthorizedException * The user is not authorized to perform this request. * @sample AWSPI.GetDimensionKeyDetails * @see AWS API * Documentation */ @Override public GetDimensionKeyDetailsResult getDimensionKeyDetails(GetDimensionKeyDetailsRequest request) { request = beforeClientExecution(request); return executeGetDimensionKeyDetails(request); } @SdkInternalApi final GetDimensionKeyDetailsResult executeGetDimensionKeyDetails(GetDimensionKeyDetailsRequest getDimensionKeyDetailsRequest) { ExecutionContext executionContext = createExecutionContext(getDimensionKeyDetailsRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request request = null; Response response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new GetDimensionKeyDetailsRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(getDimensionKeyDetailsRequest)); // 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, "PI"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetDimensionKeyDetails"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new GetDimensionKeyDetailsResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } } /** *

* Retrieve the metadata for different features. For example, the metadata might indicate that a feature is turned * on or off on a specific DB instance. *

* * @param getResourceMetadataRequest * @return Result of the GetResourceMetadata operation returned by the service. * @throws InvalidArgumentException * One of the arguments provided is invalid for this request. * @throws InternalServiceErrorException * The request failed due to an unknown error. * @throws NotAuthorizedException * The user is not authorized to perform this request. * @sample AWSPI.GetResourceMetadata * @see AWS API * Documentation */ @Override public GetResourceMetadataResult getResourceMetadata(GetResourceMetadataRequest request) { request = beforeClientExecution(request); return executeGetResourceMetadata(request); } @SdkInternalApi final GetResourceMetadataResult executeGetResourceMetadata(GetResourceMetadataRequest getResourceMetadataRequest) { ExecutionContext executionContext = createExecutionContext(getResourceMetadataRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request request = null; Response response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new GetResourceMetadataRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(getResourceMetadataRequest)); // 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, "PI"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetResourceMetadata"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new GetResourceMetadataResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } } /** *

* Retrieve Performance Insights metrics for a set of data sources over a time period. You can provide specific * dimension groups and dimensions, and provide aggregation and filtering criteria for each group. *

* *

* Each response element returns a maximum of 500 bytes. For larger elements, such as SQL statements, only the first * 500 bytes are returned. *

*
* * @param getResourceMetricsRequest * @return Result of the GetResourceMetrics operation returned by the service. * @throws InvalidArgumentException * One of the arguments provided is invalid for this request. * @throws InternalServiceErrorException * The request failed due to an unknown error. * @throws NotAuthorizedException * The user is not authorized to perform this request. * @sample AWSPI.GetResourceMetrics * @see AWS API * Documentation */ @Override public GetResourceMetricsResult getResourceMetrics(GetResourceMetricsRequest request) { request = beforeClientExecution(request); return executeGetResourceMetrics(request); } @SdkInternalApi final GetResourceMetricsResult executeGetResourceMetrics(GetResourceMetricsRequest getResourceMetricsRequest) { ExecutionContext executionContext = createExecutionContext(getResourceMetricsRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request request = null; Response response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new GetResourceMetricsRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(getResourceMetricsRequest)); // 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, "PI"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetResourceMetrics"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new GetResourceMetricsResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } } /** *

* Retrieve the dimensions that can be queried for each specified metric type on a specified DB instance. *

* * @param listAvailableResourceDimensionsRequest * @return Result of the ListAvailableResourceDimensions operation returned by the service. * @throws InvalidArgumentException * One of the arguments provided is invalid for this request. * @throws InternalServiceErrorException * The request failed due to an unknown error. * @throws NotAuthorizedException * The user is not authorized to perform this request. * @sample AWSPI.ListAvailableResourceDimensions * @see AWS API Documentation */ @Override public ListAvailableResourceDimensionsResult listAvailableResourceDimensions(ListAvailableResourceDimensionsRequest request) { request = beforeClientExecution(request); return executeListAvailableResourceDimensions(request); } @SdkInternalApi final ListAvailableResourceDimensionsResult executeListAvailableResourceDimensions( ListAvailableResourceDimensionsRequest listAvailableResourceDimensionsRequest) { ExecutionContext executionContext = createExecutionContext(listAvailableResourceDimensionsRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request request = null; Response response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new ListAvailableResourceDimensionsRequestProtocolMarshaller(protocolFactory).marshall(super .beforeMarshalling(listAvailableResourceDimensionsRequest)); // 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, "PI"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListAvailableResourceDimensions"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new ListAvailableResourceDimensionsResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } } /** *

* Retrieve metrics of the specified types that can be queried for a specified DB instance. *

* * @param listAvailableResourceMetricsRequest * @return Result of the ListAvailableResourceMetrics operation returned by the service. * @throws InvalidArgumentException * One of the arguments provided is invalid for this request. * @throws InternalServiceErrorException * The request failed due to an unknown error. * @throws NotAuthorizedException * The user is not authorized to perform this request. * @sample AWSPI.ListAvailableResourceMetrics * @see AWS API Documentation */ @Override public ListAvailableResourceMetricsResult listAvailableResourceMetrics(ListAvailableResourceMetricsRequest request) { request = beforeClientExecution(request); return executeListAvailableResourceMetrics(request); } @SdkInternalApi final ListAvailableResourceMetricsResult executeListAvailableResourceMetrics(ListAvailableResourceMetricsRequest listAvailableResourceMetricsRequest) { ExecutionContext executionContext = createExecutionContext(listAvailableResourceMetricsRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request request = null; Response response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new ListAvailableResourceMetricsRequestProtocolMarshaller(protocolFactory).marshall(super .beforeMarshalling(listAvailableResourceMetricsRequest)); // 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, "PI"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListAvailableResourceMetrics"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new ListAvailableResourceMetricsResultJsonUnmarshaller()); 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 - 2025 Weber Informatics LLC | Privacy Policy