/*
* Copyright 2018-2023 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.managedblockchainquery;
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.managedblockchainquery.AmazonManagedBlockchainQueryClientBuilder;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.managedblockchainquery.model.*;
import com.amazonaws.services.managedblockchainquery.model.transform.*;
/**
* Client for accessing Amazon Managed Blockchain Query. All service calls made using this client are blocking, and will
* not return until the service call completes.
*
*
* Amazon Managed Blockchain (AMB) Query provides you with convenient access to multi-blockchain network data, which
* makes it easier for you to extract contextual data related to blockchain activity. You can use AMB Query to read data
* from public blockchain networks, such as Bitcoin Mainnet and Ethereum Mainnet. You can also get information such as
* the current and historical balances of addresses, or you can get a list of blockchain transactions for a given time
* period. Additionally, you can get details of a given transaction, such as transaction events, which you can further
* analyze or use in business logic for your applications.
*
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AmazonManagedBlockchainQueryClient extends AmazonWebServiceClient implements AmazonManagedBlockchainQuery {
/** Provider for AWS credentials. */
private final AWSCredentialsProvider awsCredentialsProvider;
private static final Log log = LogFactory.getLog(AmazonManagedBlockchainQuery.class);
/** Default signing name for the service. */
private static final String DEFAULT_SIGNING_NAME = "managedblockchain-query";
/** 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)
.withContentTypeOverride("application/json")
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("AccessDeniedException").withExceptionUnmarshaller(
com.amazonaws.services.managedblockchainquery.model.transform.AccessDeniedExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("ValidationException").withExceptionUnmarshaller(
com.amazonaws.services.managedblockchainquery.model.transform.ValidationExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("ResourceNotFoundException").withExceptionUnmarshaller(
com.amazonaws.services.managedblockchainquery.model.transform.ResourceNotFoundExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("ServiceQuotaExceededException").withExceptionUnmarshaller(
com.amazonaws.services.managedblockchainquery.model.transform.ServiceQuotaExceededExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("InternalServerException").withExceptionUnmarshaller(
com.amazonaws.services.managedblockchainquery.model.transform.InternalServerExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("ThrottlingException").withExceptionUnmarshaller(
com.amazonaws.services.managedblockchainquery.model.transform.ThrottlingExceptionUnmarshaller.getInstance()))
.withBaseServiceExceptionClass(com.amazonaws.services.managedblockchainquery.model.AmazonManagedBlockchainQueryException.class));
public static AmazonManagedBlockchainQueryClientBuilder builder() {
return AmazonManagedBlockchainQueryClientBuilder.standard();
}
/**
* Constructs a new client to invoke service methods on Amazon Managed Blockchain Query 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.
*/
AmazonManagedBlockchainQueryClient(AwsSyncClientParams clientParams) {
this(clientParams, false);
}
/**
* Constructs a new client to invoke service methods on Amazon Managed Blockchain Query 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.
*/
AmazonManagedBlockchainQueryClient(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("managedblockchain-query.us-east-1.amazonaws.com");
HandlerChainFactory chainFactory = new HandlerChainFactory();
requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/managedblockchainquery/request.handlers"));
requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/managedblockchainquery/request.handler2s"));
requestHandler2s.addAll(chainFactory.getGlobalHandlers());
}
/**
*
* Gets the token balance for a batch of tokens by using the GetTokenBalance
action for every token in
* the request.
*
*
*
* Only the native tokens BTC,ETH, and the ERC-20, ERC-721, and ERC 1155 token standards are supported.
*
*
*
* @param batchGetTokenBalanceRequest
* @return Result of the BatchGetTokenBalance operation returned by the service.
* @throws ThrottlingException
* The request or operation couldn't be performed because a service is throttling requests. The most common
* source of throttling errors is when you create resources that exceed your service limit for this resource
* type. Request a limit increase or delete unused resources, if possible.
* @throws ValidationException
* The resource passed is invalid.
* @throws ResourceNotFoundException
* The resource was not found.
* @throws AccessDeniedException
* The Amazon Web Services account doesn’t have access to this resource.
* @throws InternalServerException
* The request processing has failed because of an internal error in the service.
* @throws ServiceQuotaExceededException
* The service quota has been exceeded for this resource.
* @sample AmazonManagedBlockchainQuery.BatchGetTokenBalance
* @see AWS API Documentation
*/
@Override
public BatchGetTokenBalanceResult batchGetTokenBalance(BatchGetTokenBalanceRequest request) {
request = beforeClientExecution(request);
return executeBatchGetTokenBalance(request);
}
@SdkInternalApi
final BatchGetTokenBalanceResult executeBatchGetTokenBalance(BatchGetTokenBalanceRequest batchGetTokenBalanceRequest) {
ExecutionContext executionContext = createExecutionContext(batchGetTokenBalanceRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new BatchGetTokenBalanceRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(batchGetTokenBalanceRequest));
// 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, "ManagedBlockchain Query");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "BatchGetTokenBalance");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new BatchGetTokenBalanceResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
*
* Gets the balance of a specific token, including native tokens, for a given address (wallet or contract) on the
* blockchain.
*
*
*
* Only the native tokens BTC,ETH, and the ERC-20, ERC-721, and ERC 1155 token standards are supported.
*
*
*
* @param getTokenBalanceRequest
* @return Result of the GetTokenBalance operation returned by the service.
* @throws ThrottlingException
* The request or operation couldn't be performed because a service is throttling requests. The most common
* source of throttling errors is when you create resources that exceed your service limit for this resource
* type. Request a limit increase or delete unused resources, if possible.
* @throws ValidationException
* The resource passed is invalid.
* @throws ResourceNotFoundException
* The resource was not found.
* @throws AccessDeniedException
* The Amazon Web Services account doesn’t have access to this resource.
* @throws InternalServerException
* The request processing has failed because of an internal error in the service.
* @throws ServiceQuotaExceededException
* The service quota has been exceeded for this resource.
* @sample AmazonManagedBlockchainQuery.GetTokenBalance
* @see AWS API Documentation
*/
@Override
public GetTokenBalanceResult getTokenBalance(GetTokenBalanceRequest request) {
request = beforeClientExecution(request);
return executeGetTokenBalance(request);
}
@SdkInternalApi
final GetTokenBalanceResult executeGetTokenBalance(GetTokenBalanceRequest getTokenBalanceRequest) {
ExecutionContext executionContext = createExecutionContext(getTokenBalanceRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new GetTokenBalanceRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(getTokenBalanceRequest));
// 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, "ManagedBlockchain Query");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetTokenBalance");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new GetTokenBalanceResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
*
* Get the details of a transaction.
*
*
* @param getTransactionRequest
* @return Result of the GetTransaction operation returned by the service.
* @throws ThrottlingException
* The request or operation couldn't be performed because a service is throttling requests. The most common
* source of throttling errors is when you create resources that exceed your service limit for this resource
* type. Request a limit increase or delete unused resources, if possible.
* @throws ValidationException
* The resource passed is invalid.
* @throws ResourceNotFoundException
* The resource was not found.
* @throws AccessDeniedException
* The Amazon Web Services account doesn’t have access to this resource.
* @throws InternalServerException
* The request processing has failed because of an internal error in the service.
* @throws ServiceQuotaExceededException
* The service quota has been exceeded for this resource.
* @sample AmazonManagedBlockchainQuery.GetTransaction
* @see AWS API Documentation
*/
@Override
public GetTransactionResult getTransaction(GetTransactionRequest request) {
request = beforeClientExecution(request);
return executeGetTransaction(request);
}
@SdkInternalApi
final GetTransactionResult executeGetTransaction(GetTransactionRequest getTransactionRequest) {
ExecutionContext executionContext = createExecutionContext(getTransactionRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new GetTransactionRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(getTransactionRequest));
// 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, "ManagedBlockchain Query");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetTransaction");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new GetTransactionResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
*
* This action returns the following for a given a blockchain network:
*
*
* -
*
* Lists all token balances owned by an address (either a contact address or a wallet address).
*
*
* -
*
* Lists all token balances for all tokens created by a contract.
*
*
* -
*
* Lists all token balances for a given token.
*
*
*
*
*
* You must always specify the network property of the tokenFilter
when using this operation.
*
*
*
* @param listTokenBalancesRequest
* @return Result of the ListTokenBalances operation returned by the service.
* @throws ThrottlingException
* The request or operation couldn't be performed because a service is throttling requests. The most common
* source of throttling errors is when you create resources that exceed your service limit for this resource
* type. Request a limit increase or delete unused resources, if possible.
* @throws ValidationException
* The resource passed is invalid.
* @throws AccessDeniedException
* The Amazon Web Services account doesn’t have access to this resource.
* @throws InternalServerException
* The request processing has failed because of an internal error in the service.
* @throws ServiceQuotaExceededException
* The service quota has been exceeded for this resource.
* @sample AmazonManagedBlockchainQuery.ListTokenBalances
* @see AWS API Documentation
*/
@Override
public ListTokenBalancesResult listTokenBalances(ListTokenBalancesRequest request) {
request = beforeClientExecution(request);
return executeListTokenBalances(request);
}
@SdkInternalApi
final ListTokenBalancesResult executeListTokenBalances(ListTokenBalancesRequest listTokenBalancesRequest) {
ExecutionContext executionContext = createExecutionContext(listTokenBalancesRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ListTokenBalancesRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(listTokenBalancesRequest));
// 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, "ManagedBlockchain Query");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListTokenBalances");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new ListTokenBalancesResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
*
* An array of TransactionEvent
objects. Each object contains details about the transaction event.
*
*
* @param listTransactionEventsRequest
* @return Result of the ListTransactionEvents operation returned by the service.
* @throws ThrottlingException
* The request or operation couldn't be performed because a service is throttling requests. The most common
* source of throttling errors is when you create resources that exceed your service limit for this resource
* type. Request a limit increase or delete unused resources, if possible.
* @throws ValidationException
* The resource passed is invalid.
* @throws AccessDeniedException
* The Amazon Web Services account doesn’t have access to this resource.
* @throws InternalServerException
* The request processing has failed because of an internal error in the service.
* @throws ServiceQuotaExceededException
* The service quota has been exceeded for this resource.
* @sample AmazonManagedBlockchainQuery.ListTransactionEvents
* @see AWS API Documentation
*/
@Override
public ListTransactionEventsResult listTransactionEvents(ListTransactionEventsRequest request) {
request = beforeClientExecution(request);
return executeListTransactionEvents(request);
}
@SdkInternalApi
final ListTransactionEventsResult executeListTransactionEvents(ListTransactionEventsRequest listTransactionEventsRequest) {
ExecutionContext executionContext = createExecutionContext(listTransactionEventsRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ListTransactionEventsRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(listTransactionEventsRequest));
// 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, "ManagedBlockchain Query");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListTransactionEvents");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory
.createResponseHandler(new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new ListTransactionEventsResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
*
* Lists all of the transactions on a given wallet address or to a specific contract.
*
*
* @param listTransactionsRequest
* @return Result of the ListTransactions operation returned by the service.
* @throws ThrottlingException
* The request or operation couldn't be performed because a service is throttling requests. The most common
* source of throttling errors is when you create resources that exceed your service limit for this resource
* type. Request a limit increase or delete unused resources, if possible.
* @throws ValidationException
* The resource passed is invalid.
* @throws AccessDeniedException
* The Amazon Web Services account doesn’t have access to this resource.
* @throws InternalServerException
* The request processing has failed because of an internal error in the service.
* @throws ServiceQuotaExceededException
* The service quota has been exceeded for this resource.
* @sample AmazonManagedBlockchainQuery.ListTransactions
* @see AWS API Documentation
*/
@Override
public ListTransactionsResult listTransactions(ListTransactionsRequest request) {
request = beforeClientExecution(request);
return executeListTransactions(request);
}
@SdkInternalApi
final ListTransactionsResult executeListTransactions(ListTransactionsRequest listTransactionsRequest) {
ExecutionContext executionContext = createExecutionContext(listTransactionsRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ListTransactionsRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(listTransactionsRequest));
// 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, "ManagedBlockchain Query");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListTransactions");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new ListTransactionsResultJsonUnmarshaller());
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();
}
}