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

software.amazon.awssdk.services.translate.DefaultTranslateAsyncClient Maven / Gradle / Ivy

Go to download

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

There is a newer version: 2.30.1
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.translate;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.client.handler.AsyncClientHandler;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.translate.internal.TranslateServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.translate.model.ConcurrentModificationException;
import software.amazon.awssdk.services.translate.model.ConflictException;
import software.amazon.awssdk.services.translate.model.CreateParallelDataRequest;
import software.amazon.awssdk.services.translate.model.CreateParallelDataResponse;
import software.amazon.awssdk.services.translate.model.DeleteParallelDataRequest;
import software.amazon.awssdk.services.translate.model.DeleteParallelDataResponse;
import software.amazon.awssdk.services.translate.model.DeleteTerminologyRequest;
import software.amazon.awssdk.services.translate.model.DeleteTerminologyResponse;
import software.amazon.awssdk.services.translate.model.DescribeTextTranslationJobRequest;
import software.amazon.awssdk.services.translate.model.DescribeTextTranslationJobResponse;
import software.amazon.awssdk.services.translate.model.DetectedLanguageLowConfidenceException;
import software.amazon.awssdk.services.translate.model.GetParallelDataRequest;
import software.amazon.awssdk.services.translate.model.GetParallelDataResponse;
import software.amazon.awssdk.services.translate.model.GetTerminologyRequest;
import software.amazon.awssdk.services.translate.model.GetTerminologyResponse;
import software.amazon.awssdk.services.translate.model.ImportTerminologyRequest;
import software.amazon.awssdk.services.translate.model.ImportTerminologyResponse;
import software.amazon.awssdk.services.translate.model.InternalServerException;
import software.amazon.awssdk.services.translate.model.InvalidFilterException;
import software.amazon.awssdk.services.translate.model.InvalidParameterValueException;
import software.amazon.awssdk.services.translate.model.InvalidRequestException;
import software.amazon.awssdk.services.translate.model.LimitExceededException;
import software.amazon.awssdk.services.translate.model.ListLanguagesRequest;
import software.amazon.awssdk.services.translate.model.ListLanguagesResponse;
import software.amazon.awssdk.services.translate.model.ListParallelDataRequest;
import software.amazon.awssdk.services.translate.model.ListParallelDataResponse;
import software.amazon.awssdk.services.translate.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.translate.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.translate.model.ListTerminologiesRequest;
import software.amazon.awssdk.services.translate.model.ListTerminologiesResponse;
import software.amazon.awssdk.services.translate.model.ListTextTranslationJobsRequest;
import software.amazon.awssdk.services.translate.model.ListTextTranslationJobsResponse;
import software.amazon.awssdk.services.translate.model.ResourceNotFoundException;
import software.amazon.awssdk.services.translate.model.ServiceUnavailableException;
import software.amazon.awssdk.services.translate.model.StartTextTranslationJobRequest;
import software.amazon.awssdk.services.translate.model.StartTextTranslationJobResponse;
import software.amazon.awssdk.services.translate.model.StopTextTranslationJobRequest;
import software.amazon.awssdk.services.translate.model.StopTextTranslationJobResponse;
import software.amazon.awssdk.services.translate.model.TagResourceRequest;
import software.amazon.awssdk.services.translate.model.TagResourceResponse;
import software.amazon.awssdk.services.translate.model.TextSizeLimitExceededException;
import software.amazon.awssdk.services.translate.model.TooManyRequestsException;
import software.amazon.awssdk.services.translate.model.TooManyTagsException;
import software.amazon.awssdk.services.translate.model.TranslateDocumentRequest;
import software.amazon.awssdk.services.translate.model.TranslateDocumentResponse;
import software.amazon.awssdk.services.translate.model.TranslateException;
import software.amazon.awssdk.services.translate.model.TranslateTextRequest;
import software.amazon.awssdk.services.translate.model.TranslateTextResponse;
import software.amazon.awssdk.services.translate.model.UnsupportedDisplayLanguageCodeException;
import software.amazon.awssdk.services.translate.model.UnsupportedLanguagePairException;
import software.amazon.awssdk.services.translate.model.UntagResourceRequest;
import software.amazon.awssdk.services.translate.model.UntagResourceResponse;
import software.amazon.awssdk.services.translate.model.UpdateParallelDataRequest;
import software.amazon.awssdk.services.translate.model.UpdateParallelDataResponse;
import software.amazon.awssdk.services.translate.transform.CreateParallelDataRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.DeleteParallelDataRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.DeleteTerminologyRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.DescribeTextTranslationJobRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.GetParallelDataRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.GetTerminologyRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.ImportTerminologyRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.ListLanguagesRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.ListParallelDataRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.ListTerminologiesRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.ListTextTranslationJobsRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.StartTextTranslationJobRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.StopTextTranslationJobRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.TranslateDocumentRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.TranslateTextRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.translate.transform.UpdateParallelDataRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;

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

    private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
            .serviceProtocol(AwsServiceProtocol.AWS_JSON).build();

    private final AsyncClientHandler clientHandler;

    private final AwsJsonProtocolFactory protocolFactory;

    private final SdkClientConfiguration clientConfiguration;

    protected DefaultTranslateAsyncClient(SdkClientConfiguration clientConfiguration) {
        this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
        this.clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.SDK_CLIENT, this).build();
        this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
    }

    /**
     * 

* 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 A Java Future containing the result of the CreateParallelData operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • InvalidRequestException The request that you made is not valid. Check your request to determine why * it's not valid and then retry the request.
  • *
  • LimitExceededException The specified limit has been exceeded. Review your request and retry it with a * quantity below the stated limit.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • TooManyTagsException You have added too many tags to this resource. The maximum is 50 tags.
  • *
  • ConflictException There was a conflict processing the request. Try your request again.
  • *
  • ConcurrentModificationException Another modification is being made. That modification must complete * before you can make your change.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.CreateParallelData * @see AWS * API Documentation */ @Override public CompletableFuture createParallelData(CreateParallelDataRequest createParallelDataRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createParallelDataRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, createParallelDataRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateParallelData"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, CreateParallelDataResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("CreateParallelData").withProtocolMetadata(protocolMetadata) .withMarshaller(new CreateParallelDataRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(createParallelDataRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Deletes a parallel data resource in Amazon Translate. *

* * @param deleteParallelDataRequest * @return A Java Future containing the result of the DeleteParallelData operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • ConcurrentModificationException Another modification is being made. That modification must complete * before you can make your change.
  • *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.DeleteParallelData * @see AWS * API Documentation */ @Override public CompletableFuture deleteParallelData(DeleteParallelDataRequest deleteParallelDataRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteParallelDataRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteParallelDataRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteParallelData"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DeleteParallelDataResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DeleteParallelData").withProtocolMetadata(protocolMetadata) .withMarshaller(new DeleteParallelDataRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(deleteParallelDataRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* A synchronous action that deletes a custom terminology. *

* * @param deleteTerminologyRequest * @return A Java Future containing the result of the DeleteTerminology operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.DeleteTerminology * @see AWS * API Documentation */ @Override public CompletableFuture deleteTerminology(DeleteTerminologyRequest deleteTerminologyRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteTerminologyRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteTerminologyRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteTerminology"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DeleteTerminologyResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DeleteTerminology").withProtocolMetadata(protocolMetadata) .withMarshaller(new DeleteTerminologyRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(deleteTerminologyRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* 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 A Java Future containing the result of the DescribeTextTranslationJob operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.DescribeTextTranslationJob * @see AWS API Documentation */ @Override public CompletableFuture describeTextTranslationJob( DescribeTextTranslationJobRequest describeTextTranslationJobRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeTextTranslationJobRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, describeTextTranslationJobRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeTextTranslationJob"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DescribeTextTranslationJobResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DescribeTextTranslationJob").withProtocolMetadata(protocolMetadata) .withMarshaller(new DescribeTextTranslationJobRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(describeTextTranslationJobRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Provides information about a parallel data resource. *

* * @param getParallelDataRequest * @return A Java Future containing the result of the GetParallelData operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.GetParallelData * @see AWS API * Documentation */ @Override public CompletableFuture getParallelData(GetParallelDataRequest getParallelDataRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getParallelDataRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, getParallelDataRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetParallelData"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetParallelDataResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetParallelData").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetParallelDataRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getParallelDataRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Retrieves a custom terminology. *

* * @param getTerminologyRequest * @return A Java Future containing the result of the GetTerminology operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.GetTerminology * @see AWS API * Documentation */ @Override public CompletableFuture getTerminology(GetTerminologyRequest getTerminologyRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getTerminologyRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, getTerminologyRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetTerminology"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetTerminologyResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetTerminology").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetTerminologyRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getTerminologyRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* 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 A Java Future containing the result of the ImportTerminology operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • LimitExceededException The specified limit has been exceeded. Review your request and retry it with a * quantity below the stated limit.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • TooManyTagsException You have added too many tags to this resource. The maximum is 50 tags.
  • *
  • ConcurrentModificationException Another modification is being made. That modification must complete * before you can make your change.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.ImportTerminology * @see AWS * API Documentation */ @Override public CompletableFuture importTerminology(ImportTerminologyRequest importTerminologyRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(importTerminologyRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, importTerminologyRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ImportTerminology"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ImportTerminologyResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ImportTerminology").withProtocolMetadata(protocolMetadata) .withMarshaller(new ImportTerminologyRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(importTerminologyRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Provides a list of languages (RFC-5646 codes and names) that Amazon Translate supports. *

* * @param listLanguagesRequest * @return A Java Future containing the result of the ListLanguages operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • UnsupportedDisplayLanguageCodeException Requested display language code is not supported.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.ListLanguages * @see AWS API * Documentation */ @Override public CompletableFuture listLanguages(ListLanguagesRequest listLanguagesRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listLanguagesRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listLanguagesRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListLanguages"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListLanguagesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListLanguages").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListLanguagesRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listLanguagesRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Provides a list of your parallel data resources in Amazon Translate. *

* * @param listParallelDataRequest * @return A Java Future containing the result of the ListParallelData operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.ListParallelData * @see AWS * API Documentation */ @Override public CompletableFuture listParallelData(ListParallelDataRequest listParallelDataRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listParallelDataRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listParallelDataRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListParallelData"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListParallelDataResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListParallelData").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListParallelDataRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listParallelDataRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Lists all tags associated with a given Amazon Translate resource. For more information, see Tagging your resources. *

* * @param listTagsForResourceRequest * @return A Java Future containing the result of the ListTagsForResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.ListTagsForResource * @see AWS * API Documentation */ @Override public CompletableFuture listTagsForResource( ListTagsForResourceRequest listTagsForResourceRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listTagsForResourceRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagsForResourceRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListTagsForResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListTagsForResource").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listTagsForResourceRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Provides a list of custom terminologies associated with your account. *

* * @param listTerminologiesRequest * @return A Java Future containing the result of the ListTerminologies operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.ListTerminologies * @see AWS * API Documentation */ @Override public CompletableFuture listTerminologies(ListTerminologiesRequest listTerminologiesRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listTerminologiesRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listTerminologiesRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTerminologies"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListTerminologiesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListTerminologies").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListTerminologiesRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listTerminologiesRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Gets a list of the batch translation jobs that you have submitted. *

* * @param listTextTranslationJobsRequest * @return A Java Future containing the result of the ListTextTranslationJobs operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • InvalidRequestException The request that you made is not valid. Check your request to determine why * it's not valid and then retry the request.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • InvalidFilterException The filter specified for the operation is not valid. Specify a different * filter.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.ListTextTranslationJobs * @see AWS API Documentation */ @Override public CompletableFuture listTextTranslationJobs( ListTextTranslationJobsRequest listTextTranslationJobsRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listTextTranslationJobsRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listTextTranslationJobsRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTextTranslationJobs"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListTextTranslationJobsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListTextTranslationJobs").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListTextTranslationJobsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listTextTranslationJobsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* 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 A Java Future containing the result of the StartTextTranslationJob operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • UnsupportedLanguagePairException Amazon Translate does not support translation from the language of * the source text into the requested target language. For more information, see Supported languages.
  • *
  • InvalidRequestException The request that you made is not valid. Check your request to determine why * it's not valid and then retry the request.
  • *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.StartTextTranslationJob * @see AWS API Documentation */ @Override public CompletableFuture startTextTranslationJob( StartTextTranslationJobRequest startTextTranslationJobRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(startTextTranslationJobRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, startTextTranslationJobRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StartTextTranslationJob"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, StartTextTranslationJobResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("StartTextTranslationJob").withProtocolMetadata(protocolMetadata) .withMarshaller(new StartTextTranslationJobRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(startTextTranslationJobRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* 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 A Java Future containing the result of the StopTextTranslationJob operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.StopTextTranslationJob * @see AWS API Documentation */ @Override public CompletableFuture stopTextTranslationJob( StopTextTranslationJobRequest stopTextTranslationJobRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(stopTextTranslationJobRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, stopTextTranslationJobRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StopTextTranslationJob"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, StopTextTranslationJobResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("StopTextTranslationJob").withProtocolMetadata(protocolMetadata) .withMarshaller(new StopTextTranslationJobRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(stopTextTranslationJobRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* 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 A Java Future containing the result of the TagResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • ConcurrentModificationException Another modification is being made. That modification must complete * before you can make your change.
  • *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • TooManyTagsException You have added too many tags to this resource. The maximum is 50 tags.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.TagResource * @see AWS API * Documentation */ @Override public CompletableFuture tagResource(TagResourceRequest tagResourceRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(tagResourceRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, tagResourceRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, TagResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("TagResource").withProtocolMetadata(protocolMetadata) .withMarshaller(new TagResourceRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(tagResourceRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Translates the input document from the source language to the target language. This synchronous operation * supports text, HTML, or Word documents as 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). *

*

* 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 A Java Future containing the result of the TranslateDocument operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • InvalidRequestException The request that you made is not valid. Check your request to determine why * it's not valid and then retry the request.
  • *
  • LimitExceededException The specified limit has been exceeded. Review your request and retry it with a * quantity below the stated limit.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • UnsupportedLanguagePairException Amazon Translate does not support translation from the language of * the source text into the requested target language. For more information, see Supported languages.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ServiceUnavailableException The Amazon Translate service is temporarily unavailable. Wait a bit and * then retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.TranslateDocument * @see AWS * API Documentation */ @Override public CompletableFuture translateDocument(TranslateDocumentRequest translateDocumentRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(translateDocumentRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, translateDocumentRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TranslateDocument"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, TranslateDocumentResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("TranslateDocument").withProtocolMetadata(protocolMetadata) .withMarshaller(new TranslateDocumentRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(translateDocumentRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* 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 A Java Future containing the result of the TranslateText operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • InvalidRequestException The request that you made is not valid. Check your request to determine why * it's not valid and then retry the request.
  • *
  • TextSizeLimitExceededException The size of the text you submitted exceeds the size limit. Reduce the * size of the text or use a smaller document and then retry your request.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • UnsupportedLanguagePairException Amazon Translate does not support translation from the language of * the source text into the requested target language. For more information, see Supported languages.
  • *
  • DetectedLanguageLowConfidenceException The confidence that Amazon Comprehend accurately detected the * source language is low. If a low confidence level is acceptable for your application, you can use the * language in the exception to call Amazon Translate again. For more information, see the DetectDominantLanguage operation in the Amazon Comprehend Developer Guide.
  • *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ServiceUnavailableException The Amazon Translate service is temporarily unavailable. Wait a bit and * then retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.TranslateText * @see AWS API * Documentation */ @Override public CompletableFuture translateText(TranslateTextRequest translateTextRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(translateTextRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, translateTextRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TranslateText"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, TranslateTextResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("TranslateText").withProtocolMetadata(protocolMetadata) .withMarshaller(new TranslateTextRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(translateTextRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Removes a specific tag associated with an Amazon Translate resource. For more information, see Tagging your resources. *

* * @param untagResourceRequest * @return A Java Future containing the result of the UntagResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • ConcurrentModificationException Another modification is being made. That modification must complete * before you can make your change.
  • *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.UntagResource * @see AWS API * Documentation */ @Override public CompletableFuture untagResource(UntagResourceRequest untagResourceRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(untagResourceRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, untagResourceRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, UntagResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("UntagResource").withProtocolMetadata(protocolMetadata) .withMarshaller(new UntagResourceRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(untagResourceRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Updates a previously created parallel data resource by importing a new input file from Amazon S3. *

* * @param updateParallelDataRequest * @return A Java Future containing the result of the UpdateParallelData operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. *
    *
  • ConcurrentModificationException Another modification is being made. That modification must complete * before you can make your change.
  • *
  • InvalidParameterValueException The value of the parameter is not valid. Review the value of the * parameter you are using to correct it, and then retry your operation.
  • *
  • InvalidRequestException The request that you made is not valid. Check your request to determine why * it's not valid and then retry the request.
  • *
  • LimitExceededException The specified limit has been exceeded. Review your request and retry it with a * quantity below the stated limit.
  • *
  • TooManyRequestsException You have made too many requests within a short period of time. Wait for a * short time and then try your request again.
  • *
  • ConflictException There was a conflict processing the request. Try your request again.
  • *
  • ResourceNotFoundException The resource you are looking for has not been found. Review the resource * you're looking for and see if a different resource will accomplish your needs before retrying the revised * request.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • TranslateException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TranslateAsyncClient.UpdateParallelData * @see AWS * API Documentation */ @Override public CompletableFuture updateParallelData(UpdateParallelDataRequest updateParallelDataRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateParallelDataRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, updateParallelDataRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Translate"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateParallelData"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, UpdateParallelDataResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("UpdateParallelData").withProtocolMetadata(protocolMetadata) .withMarshaller(new UpdateParallelDataRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(updateParallelDataRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final TranslateServiceClientConfiguration serviceClientConfiguration() { return new TranslateServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private > T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(TranslateException::builder) .protocol(AwsJsonProtocol.AWS_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("ConcurrentModificationException") .exceptionBuilderSupplier(ConcurrentModificationException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("TooManyTagsException") .exceptionBuilderSupplier(TooManyTagsException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ConflictException") .exceptionBuilderSupplier(ConflictException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("DetectedLanguageLowConfidenceException") .exceptionBuilderSupplier(DetectedLanguageLowConfidenceException::builder).httpStatusCode(400) .build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidParameterValueException") .exceptionBuilderSupplier(InvalidParameterValueException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidRequestException") .exceptionBuilderSupplier(InvalidRequestException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ResourceNotFoundException") .exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("UnsupportedLanguagePairException") .exceptionBuilderSupplier(UnsupportedLanguagePairException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidFilterException") .exceptionBuilderSupplier(InvalidFilterException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ServiceUnavailableException") .exceptionBuilderSupplier(ServiceUnavailableException::builder).httpStatusCode(500).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("TextSizeLimitExceededException") .exceptionBuilderSupplier(TextSizeLimitExceededException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InternalServerException") .exceptionBuilderSupplier(InternalServerException::builder).httpStatusCode(500).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("UnsupportedDisplayLanguageCodeException") .exceptionBuilderSupplier(UnsupportedDisplayLanguageCodeException::builder).httpStatusCode(400) .build()) .registerModeledException( ExceptionMetadata.builder().errorCode("TooManyRequestsException") .exceptionBuilderSupplier(TooManyRequestsException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("LimitExceededException") .exceptionBuilderSupplier(LimitExceededException::builder).httpStatusCode(400).build()); } private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); if (plugins.isEmpty()) { return configuration.build(); } TranslateServiceClientConfigurationBuilder serviceConfigBuilder = new TranslateServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } @Override public void close() { clientHandler.close(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy