/*
* Copyright 2010-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.translate;
import java.util.*;
import com.amazonaws.*;
import com.amazonaws.auth.*;
import com.amazonaws.handlers.*;
import com.amazonaws.http.*;
import com.amazonaws.internal.*;
import com.amazonaws.metrics.*;
import com.amazonaws.transform.*;
import com.amazonaws.util.*;
import com.amazonaws.util.AWSRequestMetrics.Field;
import com.amazonaws.services.translate.model.*;
import com.amazonaws.services.translate.model.transform.*;
/**
* Client for accessing Amazon Translate. All service calls made using this
* client are blocking, and will not return until the service call completes.
*
* Provides translation of the input content from the source language to the
* target language.
*
*/
public class AmazonTranslateClient extends AmazonWebServiceClient implements AmazonTranslate {
/** Provider for AWS credentials. */
private AWSCredentialsProvider awsCredentialsProvider;
/**
* List of exception unmarshallers for all Amazon Translate exceptions.
*/
protected List jsonErrorUnmarshallers;
/**
* Constructs a new client to invoke service methods on AmazonTranslate. A
* credentials provider chain will be used that searches for credentials in
* this order:
*
* - Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY
* - Java System Properties - aws.accessKeyId and aws.secretKey
* - Instance profile credentials delivered through the Amazon EC2
* metadata service
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @see DefaultAWSCredentialsProviderChain
*/
@Deprecated
public AmazonTranslateClient() {
this(new DefaultAWSCredentialsProviderChain(), new ClientConfiguration());
}
/**
* Constructs a new client to invoke service methods on AmazonTranslate. A
* credentials provider chain will be used that searches for credentials in
* this order:
*
* - Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY
* - Java System Properties - aws.accessKeyId and aws.secretKey
* - Instance profile credentials delivered through the Amazon EC2
* metadata service
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param clientConfiguration The client configuration options controlling
* how this client connects to AmazonTranslate (ex: proxy
* settings, retry counts, etc.).
* @see DefaultAWSCredentialsProviderChain
*/
@Deprecated
public AmazonTranslateClient(ClientConfiguration clientConfiguration) {
this(new DefaultAWSCredentialsProviderChain(), clientConfiguration);
}
/**
* Constructs a new client to invoke service methods on AmazonTranslate
* using the specified AWS account credentials.
*
* The client requests are authenticated using the {@link AWSCredentials}
* provided in this constructor. Static AWSCredentials can be passed for
* quick testing. However, it is strongly recommended to use Amazon Cognito
* vended temporary credentials for use in production. This can be achieved
* by using {@link AWSMobileClient}. Please see
* https://aws-amplify.github.io/docs/android/authentication for
* instructions on how to enable {@link AWSMobileClient}.
*
*
* AWSMobileClient.getInstance().initialize(getApplicationContext(), new Callback<UserStateDetails>() {
* @Override
* public void onResult(final UserStateDetails details) {
* AmazonTranslateClient client = new AmazonTranslateClient(AWSMobileClient.getInstance());
* }
*
* @Override
* public void onError(final Exception e) {
* e.printStackTrace();
* }
* });
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param awsCredentials The AWS credentials (access key ID and secret key)
* to use when authenticating with AWS services.
*/
public AmazonTranslateClient(AWSCredentials awsCredentials) {
this(awsCredentials, new ClientConfiguration());
}
/**
* Constructs a new client to invoke service methods on AmazonTranslate
* using the specified AWS account credentials and client configuration
* options.
*
* The client requests are authenticated using the {@link AWSCredentials}
* provided in this constructor. Static AWSCredentials can be passed for
* quick testing. However, it is strongly recommended to use Amazon Cognito
* vended temporary credentials for use in production. This can be achieved
* by using {@link AWSMobileClient}. Please see
* https://aws-amplify.github.io/docs/android/authentication for
* instructions on how to enable {@link AWSMobileClient}.
*
*
* AWSMobileClient.getInstance().initialize(getApplicationContext(), new Callback<UserStateDetails>() {
* @Override
* public void onResult(final UserStateDetails details) {
* AmazonTranslateClient client = new AmazonTranslateClient(AWSMobileClient.getInstance());
* }
*
* @Override
* public void onError(final Exception e) {
* e.printStackTrace();
* }
* });
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param awsCredentials The AWS credentials (access key ID and secret key)
* to use when authenticating with AWS services.
* @param clientConfiguration The client configuration options controlling
* how this client connects to AmazonTranslate (ex: proxy
* settings, retry counts, etc.).
*/
public AmazonTranslateClient(AWSCredentials awsCredentials,
ClientConfiguration clientConfiguration) {
this(new StaticCredentialsProvider(awsCredentials), clientConfiguration);
}
/**
* Constructs a new client to invoke service methods on AmazonTranslate
* using the specified AWS account credentials provider.
*
* The client requests are authenticated using the {@link AWSCredentials}
* provided by the {@link AWSCredentialsProvider}. Static AWSCredentials can
* be passed for quick testing. However, it is strongly recommended to use
* Amazon Cognito vended temporary credentials for use in production. This
* can be achieved by using {@link AWSMobileClient}. Please see
* https://aws-amplify.github.io/docs/android/authentication for
* instructions on how to enable {@link AWSMobileClient}.
*
*
* AWSMobileClient.getInstance().initialize(getApplicationContext(), new Callback<UserStateDetails>() {
* @Override
* public void onResult(final UserStateDetails details) {
* AmazonTranslateClient client = new AmazonTranslateClient(AWSMobileClient.getInstance());
* }
*
* @Override
* public void onError(final Exception e) {
* e.printStackTrace();
* }
* });
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param awsCredentialsProvider The AWS credentials provider which will
* provide credentials to authenticate requests with AWS
* services.
*/
public AmazonTranslateClient(AWSCredentialsProvider awsCredentialsProvider) {
this(awsCredentialsProvider, new ClientConfiguration());
}
/**
* Constructs a new client to invoke service methods on AmazonTranslate
* using the specified AWS account credentials provider and client
* configuration options.
*
* The client requests are authenticated using the {@link AWSCredentials}
* provided by the {@link AWSCredentialsProvider}. Static AWSCredentials can
* be passed for quick testing. However, it is strongly recommended to use
* Amazon Cognito vended temporary credentials for use in production. This
* can be achieved by using {@link AWSMobileClient}. Please see
* https://aws-amplify.github.io/docs/android/authentication for
* instructions on how to enable {@link AWSMobileClient}.
*
*
* AWSMobileClient.getInstance().initialize(getApplicationContext(), new Callback<UserStateDetails>() {
* @Override
* public void onResult(final UserStateDetails details) {
* AmazonTranslateClient client = new AmazonTranslateClient(AWSMobileClient.getInstance());
* }
*
* @Override
* public void onError(final Exception e) {
* e.printStackTrace();
* }
* });
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param awsCredentialsProvider The AWS credentials provider which will
* provide credentials to authenticate requests with AWS
* services.
* @param clientConfiguration The client configuration options controlling
* how this client connects to AmazonTranslate (ex: proxy
* settings, retry counts, etc.).
*/
public AmazonTranslateClient(AWSCredentialsProvider awsCredentialsProvider,
ClientConfiguration clientConfiguration) {
this(awsCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}
/**
* Constructs a new client to invoke service methods on AmazonTranslate
* using the specified AWS account credentials provider, client
* configuration options and request metric collector.
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param awsCredentialsProvider The AWS credentials provider which will
* provide credentials to authenticate requests with AWS
* services.
* @param clientConfiguration The client configuration options controlling
* how this client connects to AmazonTranslate (ex: proxy
* settings, retry counts, etc.).
* @param requestMetricCollector optional request metric collector
*/
@Deprecated
public AmazonTranslateClient(AWSCredentialsProvider awsCredentialsProvider,
ClientConfiguration clientConfiguration,
RequestMetricCollector requestMetricCollector) {
super(adjustClientConfiguration(clientConfiguration), requestMetricCollector);
this.awsCredentialsProvider = awsCredentialsProvider;
init();
}
/**
* Constructs a new client to invoke service methods on AmazonTranslate
* using the specified AWS account credentials provider, client
* configuration options and request metric collector.
*
* The client requests are authenticated using the {@link AWSCredentials}
* provided by the {@link AWSCredentialsProvider}. Static AWSCredentials can
* be passed for quick testing. However, it is strongly recommended to use
* Amazon Cognito vended temporary credentials for use in production. This
* can be achieved by using {@link AWSMobileClient}. Please see
* https://aws-amplify.github.io/docs/android/authentication for
* instructions on how to enable {@link AWSMobileClient}.
*
*
* AWSMobileClient.getInstance().initialize(getApplicationContext(), new Callback<UserStateDetails>() {
* @Override
* public void onResult(final UserStateDetails details) {
* AmazonTranslateClient client = new AmazonTranslateClient(AWSMobileClient.getInstance());
* }
*
* @Override
* public void onError(final Exception e) {
* e.printStackTrace();
* }
* });
*
*
* All service calls made using this new client object are blocking, and
* will not return until the service call completes.
*
* @param awsCredentialsProvider The AWS credentials provider which will
* provide credentials to authenticate requests with AWS
* services.
* @param clientConfiguration The client configuration options controlling
* how this client connects to AmazonTranslate (ex: proxy
* settings, retry counts, etc.).
* @param httpClient A http client
*/
public AmazonTranslateClient(AWSCredentialsProvider awsCredentialsProvider,
ClientConfiguration clientConfiguration, HttpClient httpClient) {
super(adjustClientConfiguration(clientConfiguration), httpClient);
this.awsCredentialsProvider = awsCredentialsProvider;
init();
}
private void init() {
jsonErrorUnmarshallers = new ArrayList();
jsonErrorUnmarshallers.add(new ConcurrentModificationExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new ConflictExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new DetectedLanguageLowConfidenceExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new InternalServerExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new InvalidFilterExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new InvalidParameterValueExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new InvalidRequestExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new LimitExceededExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new ResourceNotFoundExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new ServiceUnavailableExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new TextSizeLimitExceededExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new TooManyRequestsExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new TooManyTagsExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new UnsupportedDisplayLanguageCodeExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new UnsupportedLanguagePairExceptionUnmarshaller());
jsonErrorUnmarshallers.add(new JsonErrorUnmarshaller());
// calling this.setEndPoint(...) will also modify the signer accordingly
setServiceNameIntern("translate");
this.setEndpoint("translate.us-east-1.amazonaws.com");
this.endpointPrefix = "translate";
HandlerChainFactory chainFactory = new HandlerChainFactory();
requestHandler2s.addAll(chainFactory.newRequestHandlerChain(
"/com/amazonaws/services/translate/request.handlers"));
requestHandler2s.addAll(chainFactory.newRequestHandler2Chain(
"/com/amazonaws/services/translate/request.handler2s"));
}
private static ClientConfiguration adjustClientConfiguration(ClientConfiguration orig) {
ClientConfiguration config = orig;
return config;
}
/**
*
* Creates a parallel data resource in Amazon Translate by importing an
* input file from Amazon S3. Parallel data files contain examples that show
* how you want segments of text to be translated. By adding parallel data,
* you can influence the style, tone, and word choice in your translation
* output.
*
*
* @param createParallelDataRequest
* @return createParallelDataResult The response from the CreateParallelData
* service method, as returned by Amazon Translate.
* @throws InvalidParameterValueException
* @throws InvalidRequestException
* @throws LimitExceededException
* @throws TooManyRequestsException
* @throws TooManyTagsException
* @throws ConflictException
* @throws ConcurrentModificationException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public CreateParallelDataResult createParallelData(
CreateParallelDataRequest createParallelDataRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(createParallelDataRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new CreateParallelDataRequestMarshaller()
.marshall(createParallelDataRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new CreateParallelDataResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Deletes a parallel data resource in Amazon Translate.
*
*
* @param deleteParallelDataRequest
* @return deleteParallelDataResult The response from the DeleteParallelData
* service method, as returned by Amazon Translate.
* @throws ConcurrentModificationException
* @throws ResourceNotFoundException
* @throws TooManyRequestsException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public DeleteParallelDataResult deleteParallelData(
DeleteParallelDataRequest deleteParallelDataRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(deleteParallelDataRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new DeleteParallelDataRequestMarshaller()
.marshall(deleteParallelDataRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new DeleteParallelDataResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* A synchronous action that deletes a custom terminology.
*
*
* @param deleteTerminologyRequest
* @throws ResourceNotFoundException
* @throws TooManyRequestsException
* @throws InvalidParameterValueException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public void deleteTerminology(DeleteTerminologyRequest deleteTerminologyRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(deleteTerminologyRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new DeleteTerminologyRequestMarshaller()
.marshall(deleteTerminologyRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
JsonResponseHandler responseHandler = new JsonResponseHandler(null);
invoke(request, responseHandler, executionContext);
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Gets the properties associated with an asynchronous batch translation job
* including name, ID, status, source and target languages, input/output S3
* buckets, and so on.
*
*
* @param describeTextTranslationJobRequest
* @return describeTextTranslationJobResult The response from the
* DescribeTextTranslationJob service method, as returned by Amazon
* Translate.
* @throws ResourceNotFoundException
* @throws TooManyRequestsException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public DescribeTextTranslationJobResult describeTextTranslationJob(
DescribeTextTranslationJobRequest describeTextTranslationJobRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(describeTextTranslationJobRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new DescribeTextTranslationJobRequestMarshaller()
.marshall(describeTextTranslationJobRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new DescribeTextTranslationJobResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Provides information about a parallel data resource.
*
*
* @param getParallelDataRequest
* @return getParallelDataResult The response from the GetParallelData
* service method, as returned by Amazon Translate.
* @throws ResourceNotFoundException
* @throws InvalidParameterValueException
* @throws TooManyRequestsException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public GetParallelDataResult getParallelData(GetParallelDataRequest getParallelDataRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(getParallelDataRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new GetParallelDataRequestMarshaller().marshall(getParallelDataRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new GetParallelDataResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Retrieves a custom terminology.
*
*
* @param getTerminologyRequest
* @return getTerminologyResult The response from the GetTerminology service
* method, as returned by Amazon Translate.
* @throws ResourceNotFoundException
* @throws InvalidParameterValueException
* @throws TooManyRequestsException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public GetTerminologyResult getTerminology(GetTerminologyRequest getTerminologyRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(getTerminologyRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new GetTerminologyRequestMarshaller().marshall(getTerminologyRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new GetTerminologyResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Creates or updates a custom terminology, depending on whether one already
* exists for the given terminology name. Importing a terminology with the
* same name as an existing one will merge the terminologies based on the
* chosen merge strategy. The only supported merge strategy is OVERWRITE,
* where the imported terminology overwrites the existing terminology of the
* same name.
*
*
* If you import a terminology that overwrites an existing one, the new
* terminology takes up to 10 minutes to fully propagate. After that,
* translations have access to the new terminology.
*
*
* @param importTerminologyRequest
* @return importTerminologyResult The response from the ImportTerminology
* service method, as returned by Amazon Translate.
* @throws InvalidParameterValueException
* @throws LimitExceededException
* @throws TooManyRequestsException
* @throws TooManyTagsException
* @throws ConcurrentModificationException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public ImportTerminologyResult importTerminology(
ImportTerminologyRequest importTerminologyRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(importTerminologyRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ImportTerminologyRequestMarshaller()
.marshall(importTerminologyRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new ImportTerminologyResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Provides a list of languages (RFC-5646 codes and names) that Amazon
* Translate supports.
*
*
* @param listLanguagesRequest
* @return listLanguagesResult The response from the ListLanguages service
* method, as returned by Amazon Translate.
* @throws InvalidParameterValueException
* @throws TooManyRequestsException
* @throws UnsupportedDisplayLanguageCodeException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public ListLanguagesResult listLanguages(ListLanguagesRequest listLanguagesRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(listLanguagesRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ListLanguagesRequestMarshaller().marshall(listLanguagesRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new ListLanguagesResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Provides a list of your parallel data resources in Amazon Translate.
*
*
* @param listParallelDataRequest
* @return listParallelDataResult The response from the ListParallelData
* service method, as returned by Amazon Translate.
* @throws InvalidParameterValueException
* @throws TooManyRequestsException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public ListParallelDataResult listParallelData(ListParallelDataRequest listParallelDataRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(listParallelDataRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ListParallelDataRequestMarshaller().marshall(listParallelDataRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new ListParallelDataResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Lists all tags associated with a given Amazon Translate resource. For
* more information, see
* Tagging your resources.
*
*
* @param listTagsForResourceRequest
* @return listTagsForResourceResult The response from the
* ListTagsForResource service method, as returned by Amazon
* Translate.
* @throws InvalidParameterValueException
* @throws ResourceNotFoundException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public ListTagsForResourceResult listTagsForResource(
ListTagsForResourceRequest listTagsForResourceRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(listTagsForResourceRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ListTagsForResourceRequestMarshaller()
.marshall(listTagsForResourceRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new ListTagsForResourceResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Provides a list of custom terminologies associated with your account.
*
*
* @param listTerminologiesRequest
* @return listTerminologiesResult The response from the ListTerminologies
* service method, as returned by Amazon Translate.
* @throws InvalidParameterValueException
* @throws TooManyRequestsException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public ListTerminologiesResult listTerminologies(
ListTerminologiesRequest listTerminologiesRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(listTerminologiesRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ListTerminologiesRequestMarshaller()
.marshall(listTerminologiesRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new ListTerminologiesResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Gets a list of the batch translation jobs that you have submitted.
*
*
* @param listTextTranslationJobsRequest
* @return listTextTranslationJobsResult The response from the
* ListTextTranslationJobs service method, as returned by Amazon
* Translate.
* @throws InvalidRequestException
* @throws TooManyRequestsException
* @throws InvalidFilterException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public ListTextTranslationJobsResult listTextTranslationJobs(
ListTextTranslationJobsRequest listTextTranslationJobsRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(listTextTranslationJobsRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ListTextTranslationJobsRequestMarshaller()
.marshall(listTextTranslationJobsRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new ListTextTranslationJobsResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Starts an asynchronous batch translation job. Use batch translation jobs
* to translate large volumes of text across multiple documents at once. For
* batch translation, you can input documents with different source
* languages (specify auto
as the source language). You can
* specify one or more target languages. Batch translation translates each
* input document into each of the target languages. For more information,
* see
* Asynchronous batch processing.
*
*
* Batch translation jobs can be described with the
* DescribeTextTranslationJob operation, listed with the
* ListTextTranslationJobs operation, and stopped with the
* StopTextTranslationJob operation.
*
*
* @param startTextTranslationJobRequest
* @return startTextTranslationJobResult The response from the
* StartTextTranslationJob service method, as returned by Amazon
* Translate.
* @throws TooManyRequestsException
* @throws UnsupportedLanguagePairException
* @throws InvalidRequestException
* @throws ResourceNotFoundException
* @throws InvalidParameterValueException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public StartTextTranslationJobResult startTextTranslationJob(
StartTextTranslationJobRequest startTextTranslationJobRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(startTextTranslationJobRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new StartTextTranslationJobRequestMarshaller()
.marshall(startTextTranslationJobRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new StartTextTranslationJobResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Stops an asynchronous batch translation job that is in progress.
*
*
* If the job's state is IN_PROGRESS
, the job will be marked
* for termination and put into the STOP_REQUESTED
state. If
* the job completes before it can be stopped, it is put into the
* COMPLETED
state. Otherwise, the job is put into the
* STOPPED
state.
*
*
* Asynchronous batch translation jobs are started with the
* StartTextTranslationJob operation. You can use the
* DescribeTextTranslationJob or ListTextTranslationJobs
* operations to get a batch translation job's JobId
.
*
*
* @param stopTextTranslationJobRequest
* @return stopTextTranslationJobResult The response from the
* StopTextTranslationJob service method, as returned by Amazon
* Translate.
* @throws ResourceNotFoundException
* @throws TooManyRequestsException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public StopTextTranslationJobResult stopTextTranslationJob(
StopTextTranslationJobRequest stopTextTranslationJobRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(stopTextTranslationJobRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new StopTextTranslationJobRequestMarshaller()
.marshall(stopTextTranslationJobRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new StopTextTranslationJobResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Associates a specific tag with a resource. A tag is a key-value pair that
* adds as a metadata to a resource. For more information, see
* Tagging your resources.
*
*
* @param tagResourceRequest
* @return tagResourceResult The response from the TagResource service
* method, as returned by Amazon Translate.
* @throws InvalidParameterValueException
* @throws ConcurrentModificationException
* @throws ResourceNotFoundException
* @throws TooManyTagsException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public TagResourceResult tagResource(TagResourceRequest tagResourceRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(tagResourceRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new TagResourceRequestMarshaller().marshall(tagResourceRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new TagResourceResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Translates the input document from the source language to the target
* language. This synchronous operation supports plain text or HTML for the
* input document. TranslateDocument
supports translations from
* English to any supported language, and from any supported language to
* English. Therefore, specify either the source language code or the target
* language code as “en” (English).
*
*
* TranslateDocument
does not support language auto-detection.
*
*
* If you set the Formality
parameter, the request will fail if
* the target language does not support formality. For a list of target
* languages that support formality, see Setting formality.
*
*
* @param translateDocumentRequest
* @return translateDocumentResult The response from the TranslateDocument
* service method, as returned by Amazon Translate.
* @throws InvalidRequestException
* @throws LimitExceededException
* @throws TooManyRequestsException
* @throws ResourceNotFoundException
* @throws UnsupportedLanguagePairException
* @throws InternalServerException
* @throws ServiceUnavailableException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public TranslateDocumentResult translateDocument(
TranslateDocumentRequest translateDocumentRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(translateDocumentRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new TranslateDocumentRequestMarshaller()
.marshall(translateDocumentRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new TranslateDocumentResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Translates input text from the source language to the target language.
* For a list of available languages and language codes, see Supported languages.
*
*
* @param translateTextRequest
* @return translateTextResult The response from the TranslateText service
* method, as returned by Amazon Translate.
* @throws InvalidRequestException
* @throws TextSizeLimitExceededException
* @throws TooManyRequestsException
* @throws UnsupportedLanguagePairException
* @throws DetectedLanguageLowConfidenceException
* @throws ResourceNotFoundException
* @throws InternalServerException
* @throws ServiceUnavailableException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public TranslateTextResult translateText(TranslateTextRequest translateTextRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(translateTextRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new TranslateTextRequestMarshaller().marshall(translateTextRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new TranslateTextResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Removes a specific tag associated with an Amazon Translate resource. For
* more information, see
* Tagging your resources.
*
*
* @param untagResourceRequest
* @return untagResourceResult The response from the UntagResource service
* method, as returned by Amazon Translate.
* @throws InvalidParameterValueException
* @throws ConcurrentModificationException
* @throws ResourceNotFoundException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public UntagResourceResult untagResource(UntagResourceRequest untagResourceRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(untagResourceRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new UntagResourceRequestMarshaller().marshall(untagResourceRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new UntagResourceResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
*
* Updates a previously created parallel data resource by importing a new
* input file from Amazon S3.
*
*
* @param updateParallelDataRequest
* @return updateParallelDataResult The response from the UpdateParallelData
* service method, as returned by Amazon Translate.
* @throws ConcurrentModificationException
* @throws InvalidParameterValueException
* @throws InvalidRequestException
* @throws LimitExceededException
* @throws TooManyRequestsException
* @throws ConflictException
* @throws ResourceNotFoundException
* @throws InternalServerException
* @throws AmazonClientException If any internal errors are encountered
* inside the client while attempting to make the request or
* handle the response. For example if a network connection is
* not available.
* @throws AmazonServiceException If an error response is returned by Amazon
* Translate indicating either a problem with the data in the
* request, or a server side issue.
*/
public UpdateParallelDataResult updateParallelData(
UpdateParallelDataRequest updateParallelDataRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(updateParallelDataRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new UpdateParallelDataRequestMarshaller()
.marshall(updateParallelDataRequest);
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
Unmarshaller unmarshaller = new UpdateParallelDataResultJsonUnmarshaller();
JsonResponseHandler responseHandler = new JsonResponseHandler(
unmarshaller);
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
awsRequestMetrics.endEvent(Field.ClientExecuteTime);
endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
}
}
/**
* 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.
* @deprecated ResponseMetadata cache can hold up to 50 requests and
* responses in memory and will cause memory issue. This method
* now always returns null.
*/
@Deprecated
public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
return client.getResponseMetadataForRequest(request);
}
private Response invoke(Request request,
HttpResponseHandler> responseHandler,
ExecutionContext executionContext) {
request.setEndpoint(endpoint);
request.setTimeOffset(timeOffset);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
AWSCredentials credentials;
awsRequestMetrics.startEvent(Field.CredentialsRequestTime);
try {
credentials = awsCredentialsProvider.getCredentials();
} finally {
awsRequestMetrics.endEvent(Field.CredentialsRequestTime);
}
AmazonWebServiceRequest originalRequest = request.getOriginalRequest();
if (originalRequest != null && originalRequest.getRequestCredentials() != null) {
credentials = originalRequest.getRequestCredentials();
}
executionContext.setCredentials(credentials);
JsonErrorResponseHandler errorResponseHandler = new JsonErrorResponseHandler(
jsonErrorUnmarshallers);
Response result = client.execute(request, responseHandler,
errorResponseHandler, executionContext);
return result;
}
}