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

software.amazon.awssdk.services.textract.DefaultTextractAsyncClient Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Textract module holds the client classes that are used for communicating with Textract.

There is a newer version: 2.29.15
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.textract;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
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.awscore.retry.AwsRetryStrategy;
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.ClientOverrideConfiguration;
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.core.retry.RetryMode;
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.retries.api.RetryStrategy;
import software.amazon.awssdk.services.textract.internal.TextractServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.textract.model.AccessDeniedException;
import software.amazon.awssdk.services.textract.model.AnalyzeDocumentRequest;
import software.amazon.awssdk.services.textract.model.AnalyzeDocumentResponse;
import software.amazon.awssdk.services.textract.model.AnalyzeExpenseRequest;
import software.amazon.awssdk.services.textract.model.AnalyzeExpenseResponse;
import software.amazon.awssdk.services.textract.model.AnalyzeIdRequest;
import software.amazon.awssdk.services.textract.model.AnalyzeIdResponse;
import software.amazon.awssdk.services.textract.model.BadDocumentException;
import software.amazon.awssdk.services.textract.model.ConflictException;
import software.amazon.awssdk.services.textract.model.CreateAdapterRequest;
import software.amazon.awssdk.services.textract.model.CreateAdapterResponse;
import software.amazon.awssdk.services.textract.model.CreateAdapterVersionRequest;
import software.amazon.awssdk.services.textract.model.CreateAdapterVersionResponse;
import software.amazon.awssdk.services.textract.model.DeleteAdapterRequest;
import software.amazon.awssdk.services.textract.model.DeleteAdapterResponse;
import software.amazon.awssdk.services.textract.model.DeleteAdapterVersionRequest;
import software.amazon.awssdk.services.textract.model.DeleteAdapterVersionResponse;
import software.amazon.awssdk.services.textract.model.DetectDocumentTextRequest;
import software.amazon.awssdk.services.textract.model.DetectDocumentTextResponse;
import software.amazon.awssdk.services.textract.model.DocumentTooLargeException;
import software.amazon.awssdk.services.textract.model.GetAdapterRequest;
import software.amazon.awssdk.services.textract.model.GetAdapterResponse;
import software.amazon.awssdk.services.textract.model.GetAdapterVersionRequest;
import software.amazon.awssdk.services.textract.model.GetAdapterVersionResponse;
import software.amazon.awssdk.services.textract.model.GetDocumentAnalysisRequest;
import software.amazon.awssdk.services.textract.model.GetDocumentAnalysisResponse;
import software.amazon.awssdk.services.textract.model.GetDocumentTextDetectionRequest;
import software.amazon.awssdk.services.textract.model.GetDocumentTextDetectionResponse;
import software.amazon.awssdk.services.textract.model.GetExpenseAnalysisRequest;
import software.amazon.awssdk.services.textract.model.GetExpenseAnalysisResponse;
import software.amazon.awssdk.services.textract.model.GetLendingAnalysisRequest;
import software.amazon.awssdk.services.textract.model.GetLendingAnalysisResponse;
import software.amazon.awssdk.services.textract.model.GetLendingAnalysisSummaryRequest;
import software.amazon.awssdk.services.textract.model.GetLendingAnalysisSummaryResponse;
import software.amazon.awssdk.services.textract.model.HumanLoopQuotaExceededException;
import software.amazon.awssdk.services.textract.model.IdempotentParameterMismatchException;
import software.amazon.awssdk.services.textract.model.InternalServerErrorException;
import software.amazon.awssdk.services.textract.model.InvalidJobIdException;
import software.amazon.awssdk.services.textract.model.InvalidKmsKeyException;
import software.amazon.awssdk.services.textract.model.InvalidParameterException;
import software.amazon.awssdk.services.textract.model.InvalidS3ObjectException;
import software.amazon.awssdk.services.textract.model.LimitExceededException;
import software.amazon.awssdk.services.textract.model.ListAdapterVersionsRequest;
import software.amazon.awssdk.services.textract.model.ListAdapterVersionsResponse;
import software.amazon.awssdk.services.textract.model.ListAdaptersRequest;
import software.amazon.awssdk.services.textract.model.ListAdaptersResponse;
import software.amazon.awssdk.services.textract.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.textract.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.textract.model.ProvisionedThroughputExceededException;
import software.amazon.awssdk.services.textract.model.ResourceNotFoundException;
import software.amazon.awssdk.services.textract.model.ServiceQuotaExceededException;
import software.amazon.awssdk.services.textract.model.StartDocumentAnalysisRequest;
import software.amazon.awssdk.services.textract.model.StartDocumentAnalysisResponse;
import software.amazon.awssdk.services.textract.model.StartDocumentTextDetectionRequest;
import software.amazon.awssdk.services.textract.model.StartDocumentTextDetectionResponse;
import software.amazon.awssdk.services.textract.model.StartExpenseAnalysisRequest;
import software.amazon.awssdk.services.textract.model.StartExpenseAnalysisResponse;
import software.amazon.awssdk.services.textract.model.StartLendingAnalysisRequest;
import software.amazon.awssdk.services.textract.model.StartLendingAnalysisResponse;
import software.amazon.awssdk.services.textract.model.TagResourceRequest;
import software.amazon.awssdk.services.textract.model.TagResourceResponse;
import software.amazon.awssdk.services.textract.model.TextractException;
import software.amazon.awssdk.services.textract.model.ThrottlingException;
import software.amazon.awssdk.services.textract.model.UnsupportedDocumentException;
import software.amazon.awssdk.services.textract.model.UntagResourceRequest;
import software.amazon.awssdk.services.textract.model.UntagResourceResponse;
import software.amazon.awssdk.services.textract.model.UpdateAdapterRequest;
import software.amazon.awssdk.services.textract.model.UpdateAdapterResponse;
import software.amazon.awssdk.services.textract.model.ValidationException;
import software.amazon.awssdk.services.textract.transform.AnalyzeDocumentRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.AnalyzeExpenseRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.AnalyzeIdRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.CreateAdapterRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.CreateAdapterVersionRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.DeleteAdapterRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.DeleteAdapterVersionRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.DetectDocumentTextRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.GetAdapterRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.GetAdapterVersionRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.GetDocumentAnalysisRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.GetDocumentTextDetectionRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.GetExpenseAnalysisRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.GetLendingAnalysisRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.GetLendingAnalysisSummaryRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.ListAdapterVersionsRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.ListAdaptersRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.StartDocumentAnalysisRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.StartDocumentTextDetectionRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.StartExpenseAnalysisRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.StartLendingAnalysisRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.textract.transform.UpdateAdapterRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;

/**
 * Internal implementation of {@link TextractAsyncClient}.
 *
 * @see TextractAsyncClient#builder()
 */
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultTextractAsyncClient implements TextractAsyncClient {
    private static final Logger log = LoggerFactory.getLogger(DefaultTextractAsyncClient.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 DefaultTextractAsyncClient(SdkClientConfiguration clientConfiguration) {
        this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
        this.clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.SDK_CLIENT, this).build();
        this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
    }

    /**
     * 

* Analyzes an input document for relationships between detected items. *

*

* The types of information returned are as follows: *

*
    *
  • *

    * Form data (key-value pairs). The related information is returned in two Block objects, each of type * KEY_VALUE_SET: a KEY Block object and a VALUE Block object. For example, * Name: Ana Silva Carolina contains a key and value. Name: is the key. Ana Silva Carolina is * the value. *

    *
  • *
  • *

    * Table and table cell data. A TABLE Block object contains information about a detected table. A CELL * Block object is returned for each cell in a table. *

    *
  • *
  • *

    * Lines and words of text. A LINE Block object contains one or more WORD Block objects. * All lines and words that are detected in the document are returned (including text that doesn't have a * relationship with the value of FeatureTypes). *

    *
  • *
  • *

    * Signatures. A SIGNATURE Block object contains the location information of a signature in a document. * If used in conjunction with forms or tables, a signature can be given a Key-Value pairing or be detected in the * cell of a table. *

    *
  • *
  • *

    * Query. A QUERY Block object contains the query text, alias and link to the associated Query results block object. *

    *
  • *
  • *

    * Query Result. A QUERY_RESULT Block object contains the answer to the query and an ID that connects it to the * query asked. This Block also contains a confidence score. *

    *
  • *
*

* Selection elements such as check boxes and option buttons (radio buttons) can be detected in form data and in * tables. A SELECTION_ELEMENT Block object contains information about a selection element, including * the selection status. *

*

* You can choose which type of analysis to perform by specifying the FeatureTypes list. *

*

* The output is returned in a list of Block objects. *

*

* AnalyzeDocument is a synchronous operation. To analyze documents asynchronously, use * StartDocumentAnalysis. *

*

* For more information, see Document Text Analysis. *

* * @param analyzeDocumentRequest * @return A Java Future containing the result of the AnalyzeDocument operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • UnsupportedDocumentException The format of the input document isn't supported. Documents for * operations can be in PNG, JPEG, PDF, or TIFF format.
  • *
  • DocumentTooLargeException The document can't be processed because it's too large. The maximum * document size for synchronous operations 10 MB. The maximum document size for asynchronous operations is * 500 MB for PDF files.
  • *
  • BadDocumentException Amazon Textract isn't able to read the document. For more information on the * document limits in Amazon Textract, see limits.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • HumanLoopQuotaExceededException Indicates you have exceeded the maximum number of active human in the * loop workflows available
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.AnalyzeDocument * @see AWS API * Documentation */ @Override public CompletableFuture analyzeDocument(AnalyzeDocumentRequest analyzeDocumentRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(analyzeDocumentRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, analyzeDocumentRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "AnalyzeDocument"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, AnalyzeDocumentResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("AnalyzeDocument").withProtocolMetadata(protocolMetadata) .withMarshaller(new AnalyzeDocumentRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(analyzeDocumentRequest)); 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); } } /** *

* AnalyzeExpense synchronously analyzes an input document for financially related relationships * between text. *

*

* Information is returned as ExpenseDocuments and seperated as follows: *

*
    *
  • *

    * LineItemGroups- A data set containing LineItems which store information about the lines * of text, such as an item purchased and its price on a receipt. *

    *
  • *
  • *

    * SummaryFields- Contains all other information a receipt, such as header information or the vendors * name. *

    *
  • *
* * @param analyzeExpenseRequest * @return A Java Future containing the result of the AnalyzeExpense operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • UnsupportedDocumentException The format of the input document isn't supported. Documents for * operations can be in PNG, JPEG, PDF, or TIFF format.
  • *
  • DocumentTooLargeException The document can't be processed because it's too large. The maximum * document size for synchronous operations 10 MB. The maximum document size for asynchronous operations is * 500 MB for PDF files.
  • *
  • BadDocumentException Amazon Textract isn't able to read the document. For more information on the * document limits in Amazon Textract, see limits.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.AnalyzeExpense * @see AWS API * Documentation */ @Override public CompletableFuture analyzeExpense(AnalyzeExpenseRequest analyzeExpenseRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(analyzeExpenseRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, analyzeExpenseRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "AnalyzeExpense"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, AnalyzeExpenseResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("AnalyzeExpense").withProtocolMetadata(protocolMetadata) .withMarshaller(new AnalyzeExpenseRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(analyzeExpenseRequest)); 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); } } /** *

* Analyzes identity documents for relevant information. This information is extracted and returned as * IdentityDocumentFields, which records both the normalized field and value of the extracted text. * Unlike other Amazon Textract operations, AnalyzeID doesn't return any Geometry data. *

* * @param analyzeIdRequest * @return A Java Future containing the result of the AnalyzeID operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • UnsupportedDocumentException The format of the input document isn't supported. Documents for * operations can be in PNG, JPEG, PDF, or TIFF format.
  • *
  • DocumentTooLargeException The document can't be processed because it's too large. The maximum * document size for synchronous operations 10 MB. The maximum document size for asynchronous operations is * 500 MB for PDF files.
  • *
  • BadDocumentException Amazon Textract isn't able to read the document. For more information on the * document limits in Amazon Textract, see limits.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.AnalyzeID * @see AWS API * Documentation */ @Override public CompletableFuture analyzeID(AnalyzeIdRequest analyzeIdRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(analyzeIdRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, analyzeIdRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "AnalyzeID"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, AnalyzeIdResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams().withOperationName("AnalyzeID") .withProtocolMetadata(protocolMetadata) .withMarshaller(new AnalyzeIdRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withInput(analyzeIdRequest)); 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 an adapter, which can be fine-tuned for enhanced performance on user provided documents. Takes an * AdapterName and FeatureType. Currently the only supported feature type is QUERIES. You can also * provide a Description, Tags, and a ClientRequestToken. You can choose whether or not the adapter should be * AutoUpdated with the AutoUpdate argument. By default, AutoUpdate is set to DISABLED. *

* * @param createAdapterRequest * @return A Java Future containing the result of the CreateAdapter operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ConflictException Updating or deleting a resource can cause an inconsistent state.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • IdempotentParameterMismatchException A ClientRequestToken input parameter was reused * with an operation, but at least one of the other input parameters is different from the previous call to * the operation.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • LimitExceededException An Amazon Textract service limit was exceeded. For example, if you start too * many asynchronous jobs concurrently, calls to start operations (StartDocumentTextDetection, * for example) raise a LimitExceededException exception (HTTP status code: 400) until the number of * concurrently running jobs is below the Amazon Textract service limit.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • ServiceQuotaExceededException Returned when a request cannot be completed as it would exceed a * maximum service quota.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.CreateAdapter * @see AWS API * Documentation */ @Override public CompletableFuture createAdapter(CreateAdapterRequest createAdapterRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createAdapterRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, createAdapterRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateAdapter"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, CreateAdapterResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("CreateAdapter").withProtocolMetadata(protocolMetadata) .withMarshaller(new CreateAdapterRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(createAdapterRequest)); 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 a new version of an adapter. Operates on a provided AdapterId and a specified dataset provided via the * DatasetConfig argument. Requires that you specify an Amazon S3 bucket with the OutputConfig argument. You can * provide an optional KMSKeyId, an optional ClientRequestToken, and optional tags. *

* * @param createAdapterVersionRequest * @return A Java Future containing the result of the CreateAdapterVersion operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • InvalidKmsKeyException Indicates you do not have decrypt permissions with the KMS key entered, or the * KMS key was entered incorrectly.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • IdempotentParameterMismatchException A ClientRequestToken input parameter was reused * with an operation, but at least one of the other input parameters is different from the previous call to * the operation.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • LimitExceededException An Amazon Textract service limit was exceeded. For example, if you start too * many asynchronous jobs concurrently, calls to start operations (StartDocumentTextDetection, * for example) raise a LimitExceededException exception (HTTP status code: 400) until the number of * concurrently running jobs is below the Amazon Textract service limit.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • ServiceQuotaExceededException Returned when a request cannot be completed as it would exceed a * maximum service quota.
  • *
  • ResourceNotFoundException Returned when an operation tried to access a nonexistent resource.
  • *
  • ConflictException Updating or deleting a resource can cause an inconsistent state.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.CreateAdapterVersion * @see AWS * API Documentation */ @Override public CompletableFuture createAdapterVersion( CreateAdapterVersionRequest createAdapterVersionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createAdapterVersionRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, createAdapterVersionRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateAdapterVersion"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, CreateAdapterVersionResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("CreateAdapterVersion").withProtocolMetadata(protocolMetadata) .withMarshaller(new CreateAdapterVersionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(createAdapterVersionRequest)); 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 an Amazon Textract adapter. Takes an AdapterId and deletes the adapter specified by the ID. *

* * @param deleteAdapterRequest * @return A Java Future containing the result of the DeleteAdapter operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ConflictException Updating or deleting a resource can cause an inconsistent state.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • ResourceNotFoundException Returned when an operation tried to access a nonexistent resource.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.DeleteAdapter * @see AWS API * Documentation */ @Override public CompletableFuture deleteAdapter(DeleteAdapterRequest deleteAdapterRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteAdapterRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteAdapterRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteAdapter"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DeleteAdapterResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DeleteAdapter").withProtocolMetadata(protocolMetadata) .withMarshaller(new DeleteAdapterRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(deleteAdapterRequest)); 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 an Amazon Textract adapter version. Requires that you specify both an AdapterId and a AdapterVersion. * Deletes the adapter version specified by the AdapterId and the AdapterVersion. *

* * @param deleteAdapterVersionRequest * @return A Java Future containing the result of the DeleteAdapterVersion operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ConflictException Updating or deleting a resource can cause an inconsistent state.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • ResourceNotFoundException Returned when an operation tried to access a nonexistent resource.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.DeleteAdapterVersion * @see AWS * API Documentation */ @Override public CompletableFuture deleteAdapterVersion( DeleteAdapterVersionRequest deleteAdapterVersionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteAdapterVersionRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteAdapterVersionRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteAdapterVersion"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DeleteAdapterVersionResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DeleteAdapterVersion").withProtocolMetadata(protocolMetadata) .withMarshaller(new DeleteAdapterVersionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(deleteAdapterVersionRequest)); 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); } } /** *

* Detects text in the input document. Amazon Textract can detect lines of text and the words that make up a line of * text. The input document must be in one of the following image formats: JPEG, PNG, PDF, or TIFF. * DetectDocumentText returns the detected text in an array of Block objects. *

*

* Each document page has as an associated Block of type PAGE. Each PAGE Block object is * the parent of LINE Block objects that represent the lines of detected text on a page. A LINE * Block object is a parent for each word that makes up the line. Words are represented by * Block objects of type WORD. *

*

* DetectDocumentText is a synchronous operation. To analyze documents asynchronously, use * StartDocumentTextDetection. *

*

* For more information, see Document Text Detection. *

* * @param detectDocumentTextRequest * @return A Java Future containing the result of the DetectDocumentText operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • UnsupportedDocumentException The format of the input document isn't supported. Documents for * operations can be in PNG, JPEG, PDF, or TIFF format.
  • *
  • DocumentTooLargeException The document can't be processed because it's too large. The maximum * document size for synchronous operations 10 MB. The maximum document size for asynchronous operations is * 500 MB for PDF files.
  • *
  • BadDocumentException Amazon Textract isn't able to read the document. For more information on the * document limits in Amazon Textract, see limits.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.DetectDocumentText * @see AWS * API Documentation */ @Override public CompletableFuture detectDocumentText(DetectDocumentTextRequest detectDocumentTextRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(detectDocumentTextRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, detectDocumentTextRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DetectDocumentText"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DetectDocumentTextResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DetectDocumentText").withProtocolMetadata(protocolMetadata) .withMarshaller(new DetectDocumentTextRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(detectDocumentTextRequest)); 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 configuration information for an adapter specified by an AdapterId, returning information on AdapterName, * Description, CreationTime, AutoUpdate status, and FeatureTypes. *

* * @param getAdapterRequest * @return A Java Future containing the result of the GetAdapter operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • ResourceNotFoundException Returned when an operation tried to access a nonexistent resource.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.GetAdapter * @see AWS API * Documentation */ @Override public CompletableFuture getAdapter(GetAdapterRequest getAdapterRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getAdapterRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, getAdapterRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetAdapter"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, GetAdapterResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams().withOperationName("GetAdapter") .withProtocolMetadata(protocolMetadata) .withMarshaller(new GetAdapterRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getAdapterRequest)); 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 configuration information for the specified adapter version, including: AdapterId, AdapterVersion, * FeatureTypes, Status, StatusMessage, DatasetConfig, KMSKeyId, OutputConfig, Tags and EvaluationMetrics. *

* * @param getAdapterVersionRequest * @return A Java Future containing the result of the GetAdapterVersion operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • ResourceNotFoundException Returned when an operation tried to access a nonexistent resource.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.GetAdapterVersion * @see AWS * API Documentation */ @Override public CompletableFuture getAdapterVersion(GetAdapterVersionRequest getAdapterVersionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getAdapterVersionRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, getAdapterVersionRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetAdapterVersion"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetAdapterVersionResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetAdapterVersion").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetAdapterVersionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getAdapterVersionRequest)); 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 results for an Amazon Textract asynchronous operation that analyzes text in a document. *

*

* You start asynchronous text analysis by calling StartDocumentAnalysis, which returns a job identifier ( * JobId). When the text analysis operation finishes, Amazon Textract publishes a completion status to * the Amazon Simple Notification Service (Amazon SNS) topic that's registered in the initial call to * StartDocumentAnalysis. To get the results of the text-detection operation, first check that the * status value published to the Amazon SNS topic is SUCCEEDED. If so, call * GetDocumentAnalysis, and pass the job identifier (JobId) from the initial call to * StartDocumentAnalysis. *

*

* GetDocumentAnalysis returns an array of Block objects. The following types of information are * returned: *

*
    *
  • *

    * Form data (key-value pairs). The related information is returned in two Block objects, each of type * KEY_VALUE_SET: a KEY Block object and a VALUE Block object. For example, * Name: Ana Silva Carolina contains a key and value. Name: is the key. Ana Silva Carolina is * the value. *

    *
  • *
  • *

    * Table and table cell data. A TABLE Block object contains information about a detected table. A CELL * Block object is returned for each cell in a table. *

    *
  • *
  • *

    * Lines and words of text. A LINE Block object contains one or more WORD Block objects. * All lines and words that are detected in the document are returned (including text that doesn't have a * relationship with the value of the StartDocumentAnalysis FeatureTypes input parameter). *

    *
  • *
  • *

    * Query. A QUERY Block object contains the query text, alias and link to the associated Query results block object. *

    *
  • *
  • *

    * Query Results. A QUERY_RESULT Block object contains the answer to the query and an ID that connects it to the * query asked. This Block also contains a confidence score. *

    *
  • *
* *

* While processing a document with queries, look out for INVALID_REQUEST_PARAMETERS output. This * indicates that either the per page query limit has been exceeded or that the operation is trying to query a page * in the document which doesn’t exist. *

*
*

* Selection elements such as check boxes and option buttons (radio buttons) can be detected in form data and in * tables. A SELECTION_ELEMENT Block object contains information about a selection element, including * the selection status. *

*

* Use the MaxResults parameter to limit the number of blocks that are returned. If there are more * results than specified in MaxResults, the value of NextToken in the operation response * contains a pagination token for getting the next set of results. To get the next page of results, call * GetDocumentAnalysis, and populate the NextToken request parameter with the token value * that's returned from the previous call to GetDocumentAnalysis. *

*

* For more information, see Document Text Analysis. *

* * @param getDocumentAnalysisRequest * @return A Java Future containing the result of the GetDocumentAnalysis operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InvalidJobIdException An invalid job identifier was passed to an asynchronous analysis operation.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • InvalidKmsKeyException Indicates you do not have decrypt permissions with the KMS key entered, or the * KMS key was entered incorrectly.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.GetDocumentAnalysis * @see AWS * API Documentation */ @Override public CompletableFuture getDocumentAnalysis( GetDocumentAnalysisRequest getDocumentAnalysisRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getDocumentAnalysisRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, getDocumentAnalysisRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetDocumentAnalysis"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetDocumentAnalysisResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetDocumentAnalysis").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetDocumentAnalysisRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getDocumentAnalysisRequest)); 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 results for an Amazon Textract asynchronous operation that detects text in a document. Amazon Textract * can detect lines of text and the words that make up a line of text. *

*

* You start asynchronous text detection by calling StartDocumentTextDetection, which returns a job * identifier (JobId). When the text detection operation finishes, Amazon Textract publishes a * completion status to the Amazon Simple Notification Service (Amazon SNS) topic that's registered in the initial * call to StartDocumentTextDetection. To get the results of the text-detection operation, first check * that the status value published to the Amazon SNS topic is SUCCEEDED. If so, call * GetDocumentTextDetection, and pass the job identifier (JobId) from the initial call to * StartDocumentTextDetection. *

*

* GetDocumentTextDetection returns an array of Block objects. *

*

* Each document page has as an associated Block of type PAGE. Each PAGE Block object is * the parent of LINE Block objects that represent the lines of detected text on a page. A LINE * Block object is a parent for each word that makes up the line. Words are represented by * Block objects of type WORD. *

*

* Use the MaxResults parameter to limit the number of blocks that are returned. If there are more results than * specified in MaxResults, the value of NextToken in the operation response contains a * pagination token for getting the next set of results. To get the next page of results, call * GetDocumentTextDetection, and populate the NextToken request parameter with the token * value that's returned from the previous call to GetDocumentTextDetection. *

*

* For more information, see Document Text Detection. *

* * @param getDocumentTextDetectionRequest * @return A Java Future containing the result of the GetDocumentTextDetection operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InvalidJobIdException An invalid job identifier was passed to an asynchronous analysis operation.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • InvalidKmsKeyException Indicates you do not have decrypt permissions with the KMS key entered, or the * KMS key was entered incorrectly.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.GetDocumentTextDetection * @see AWS API Documentation */ @Override public CompletableFuture getDocumentTextDetection( GetDocumentTextDetectionRequest getDocumentTextDetectionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getDocumentTextDetectionRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, getDocumentTextDetectionRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetDocumentTextDetection"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetDocumentTextDetectionResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetDocumentTextDetection").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetDocumentTextDetectionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getDocumentTextDetectionRequest)); 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 results for an Amazon Textract asynchronous operation that analyzes invoices and receipts. Amazon * Textract finds contact information, items purchased, and vendor name, from input invoices and receipts. *

*

* You start asynchronous invoice/receipt analysis by calling StartExpenseAnalysis, which returns a job * identifier (JobId). Upon completion of the invoice/receipt analysis, Amazon Textract publishes the * completion status to the Amazon Simple Notification Service (Amazon SNS) topic. This topic must be registered in * the initial call to StartExpenseAnalysis. To get the results of the invoice/receipt analysis * operation, first ensure that the status value published to the Amazon SNS topic is SUCCEEDED. If so, * call GetExpenseAnalysis, and pass the job identifier (JobId) from the initial call to * StartExpenseAnalysis. *

*

* Use the MaxResults parameter to limit the number of blocks that are returned. If there are more results than * specified in MaxResults, the value of NextToken in the operation response contains a * pagination token for getting the next set of results. To get the next page of results, call * GetExpenseAnalysis, and populate the NextToken request parameter with the token value * that's returned from the previous call to GetExpenseAnalysis. *

*

* For more information, see Analyzing Invoices and Receipts. *

* * @param getExpenseAnalysisRequest * @return A Java Future containing the result of the GetExpenseAnalysis operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InvalidJobIdException An invalid job identifier was passed to an asynchronous analysis operation.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • InvalidKmsKeyException Indicates you do not have decrypt permissions with the KMS key entered, or the * KMS key was entered incorrectly.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.GetExpenseAnalysis * @see AWS * API Documentation */ @Override public CompletableFuture getExpenseAnalysis(GetExpenseAnalysisRequest getExpenseAnalysisRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getExpenseAnalysisRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, getExpenseAnalysisRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetExpenseAnalysis"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetExpenseAnalysisResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetExpenseAnalysis").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetExpenseAnalysisRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getExpenseAnalysisRequest)); 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 results for an Amazon Textract asynchronous operation that analyzes text in a lending document. *

*

* You start asynchronous text analysis by calling StartLendingAnalysis, which returns a job identifier * (JobId). When the text analysis operation finishes, Amazon Textract publishes a completion status to * the Amazon Simple Notification Service (Amazon SNS) topic that's registered in the initial call to * StartLendingAnalysis. *

*

* To get the results of the text analysis operation, first check that the status value published to the Amazon SNS * topic is SUCCEEDED. If so, call GetLendingAnalysis, and pass the job identifier (JobId) from the * initial call to StartLendingAnalysis. *

* * @param getLendingAnalysisRequest * @return A Java Future containing the result of the GetLendingAnalysis operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InvalidJobIdException An invalid job identifier was passed to an asynchronous analysis operation.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • InvalidKmsKeyException Indicates you do not have decrypt permissions with the KMS key entered, or the * KMS key was entered incorrectly.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.GetLendingAnalysis * @see AWS * API Documentation */ @Override public CompletableFuture getLendingAnalysis(GetLendingAnalysisRequest getLendingAnalysisRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getLendingAnalysisRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, getLendingAnalysisRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetLendingAnalysis"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetLendingAnalysisResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetLendingAnalysis").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetLendingAnalysisRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getLendingAnalysisRequest)); 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 summarized results for the StartLendingAnalysis operation, which analyzes text in a lending * document. The returned summary consists of information about documents grouped together by a common document * type. Information like detected signatures, page numbers, and split documents is returned with respect to the * type of grouped document. *

*

* You start asynchronous text analysis by calling StartLendingAnalysis, which returns a job identifier * (JobId). When the text analysis operation finishes, Amazon Textract publishes a completion status to * the Amazon Simple Notification Service (Amazon SNS) topic that's registered in the initial call to * StartLendingAnalysis. *

*

* To get the results of the text analysis operation, first check that the status value published to the Amazon SNS * topic is SUCCEEDED. If so, call GetLendingAnalysisSummary, and pass the job identifier ( * JobId) from the initial call to StartLendingAnalysis. *

* * @param getLendingAnalysisSummaryRequest * @return A Java Future containing the result of the GetLendingAnalysisSummary operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InvalidJobIdException An invalid job identifier was passed to an asynchronous analysis operation.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • InvalidKmsKeyException Indicates you do not have decrypt permissions with the KMS key entered, or the * KMS key was entered incorrectly.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.GetLendingAnalysisSummary * @see AWS API Documentation */ @Override public CompletableFuture getLendingAnalysisSummary( GetLendingAnalysisSummaryRequest getLendingAnalysisSummaryRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getLendingAnalysisSummaryRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, getLendingAnalysisSummaryRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetLendingAnalysisSummary"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetLendingAnalysisSummaryResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetLendingAnalysisSummary").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetLendingAnalysisSummaryRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getLendingAnalysisSummaryRequest)); 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); } } /** *

* List all version of an adapter that meet the specified filtration criteria. *

* * @param listAdapterVersionsRequest * @return A Java Future containing the result of the ListAdapterVersions operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • ResourceNotFoundException Returned when an operation tried to access a nonexistent resource.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.ListAdapterVersions * @see AWS * API Documentation */ @Override public CompletableFuture listAdapterVersions( ListAdapterVersionsRequest listAdapterVersionsRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listAdapterVersionsRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listAdapterVersionsRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListAdapterVersions"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListAdapterVersionsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListAdapterVersions").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListAdapterVersionsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listAdapterVersionsRequest)); 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 adapters that match the specified filtration criteria. *

* * @param listAdaptersRequest * @return A Java Future containing the result of the ListAdapters operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.ListAdapters * @see AWS API * Documentation */ @Override public CompletableFuture listAdapters(ListAdaptersRequest listAdaptersRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listAdaptersRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listAdaptersRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListAdapters"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListAdaptersResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListAdapters").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListAdaptersRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listAdaptersRequest)); 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 for an Amazon Textract resource. *

* * @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. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException Returned when an operation tried to access a nonexistent resource.
  • *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.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, "Textract"); 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); } } /** *

* Starts the asynchronous analysis of an input document for relationships between detected items such as key-value * pairs, tables, and selection elements. *

*

* StartDocumentAnalysis can analyze text in documents that are in JPEG, PNG, TIFF, and PDF format. The * documents are stored in an Amazon S3 bucket. Use DocumentLocation to specify the bucket name and file name * of the document. *

*

* StartDocumentAnalysis returns a job identifier (JobId) that you use to get the results * of the operation. When text analysis is finished, Amazon Textract publishes a completion status to the Amazon * Simple Notification Service (Amazon SNS) topic that you specify in NotificationChannel. To get the * results of the text analysis operation, first check that the status value published to the Amazon SNS topic is * SUCCEEDED. If so, call GetDocumentAnalysis, and pass the job identifier (JobId) * from the initial call to StartDocumentAnalysis. *

*

* For more information, see Document Text Analysis. *

* * @param startDocumentAnalysisRequest * @return A Java Future containing the result of the StartDocumentAnalysis operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • InvalidKmsKeyException Indicates you do not have decrypt permissions with the KMS key entered, or the * KMS key was entered incorrectly.
  • *
  • UnsupportedDocumentException The format of the input document isn't supported. Documents for * operations can be in PNG, JPEG, PDF, or TIFF format.
  • *
  • DocumentTooLargeException The document can't be processed because it's too large. The maximum * document size for synchronous operations 10 MB. The maximum document size for asynchronous operations is * 500 MB for PDF files.
  • *
  • BadDocumentException Amazon Textract isn't able to read the document. For more information on the * document limits in Amazon Textract, see limits.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • IdempotentParameterMismatchException A ClientRequestToken input parameter was reused * with an operation, but at least one of the other input parameters is different from the previous call to * the operation.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • LimitExceededException An Amazon Textract service limit was exceeded. For example, if you start too * many asynchronous jobs concurrently, calls to start operations (StartDocumentTextDetection, * for example) raise a LimitExceededException exception (HTTP status code: 400) until the number of * concurrently running jobs is below the Amazon Textract service limit.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.StartDocumentAnalysis * @see AWS API Documentation */ @Override public CompletableFuture startDocumentAnalysis( StartDocumentAnalysisRequest startDocumentAnalysisRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(startDocumentAnalysisRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, startDocumentAnalysisRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StartDocumentAnalysis"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, StartDocumentAnalysisResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("StartDocumentAnalysis").withProtocolMetadata(protocolMetadata) .withMarshaller(new StartDocumentAnalysisRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(startDocumentAnalysisRequest)); 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 the asynchronous detection of text in a document. Amazon Textract can detect lines of text and the words * that make up a line of text. *

*

* StartDocumentTextDetection can analyze text in documents that are in JPEG, PNG, TIFF, and PDF * format. The documents are stored in an Amazon S3 bucket. Use DocumentLocation to specify the bucket name * and file name of the document. *

*

* StartTextDetection returns a job identifier (JobId) that you use to get the results of * the operation. When text detection is finished, Amazon Textract publishes a completion status to the Amazon * Simple Notification Service (Amazon SNS) topic that you specify in NotificationChannel. To get the * results of the text detection operation, first check that the status value published to the Amazon SNS topic is * SUCCEEDED. If so, call GetDocumentTextDetection, and pass the job identifier ( * JobId) from the initial call to StartDocumentTextDetection. *

*

* For more information, see Document Text Detection. *

* * @param startDocumentTextDetectionRequest * @return A Java Future containing the result of the StartDocumentTextDetection operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • InvalidKmsKeyException Indicates you do not have decrypt permissions with the KMS key entered, or the * KMS key was entered incorrectly.
  • *
  • UnsupportedDocumentException The format of the input document isn't supported. Documents for * operations can be in PNG, JPEG, PDF, or TIFF format.
  • *
  • DocumentTooLargeException The document can't be processed because it's too large. The maximum * document size for synchronous operations 10 MB. The maximum document size for asynchronous operations is * 500 MB for PDF files.
  • *
  • BadDocumentException Amazon Textract isn't able to read the document. For more information on the * document limits in Amazon Textract, see limits.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • IdempotentParameterMismatchException A ClientRequestToken input parameter was reused * with an operation, but at least one of the other input parameters is different from the previous call to * the operation.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • LimitExceededException An Amazon Textract service limit was exceeded. For example, if you start too * many asynchronous jobs concurrently, calls to start operations (StartDocumentTextDetection, * for example) raise a LimitExceededException exception (HTTP status code: 400) until the number of * concurrently running jobs is below the Amazon Textract service limit.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.StartDocumentTextDetection * @see AWS API Documentation */ @Override public CompletableFuture startDocumentTextDetection( StartDocumentTextDetectionRequest startDocumentTextDetectionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(startDocumentTextDetectionRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, startDocumentTextDetectionRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StartDocumentTextDetection"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, StartDocumentTextDetectionResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("StartDocumentTextDetection").withProtocolMetadata(protocolMetadata) .withMarshaller(new StartDocumentTextDetectionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(startDocumentTextDetectionRequest)); 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 the asynchronous analysis of invoices or receipts for data like contact information, items purchased, and * vendor names. *

*

* StartExpenseAnalysis can analyze text in documents that are in JPEG, PNG, and PDF format. The * documents must be stored in an Amazon S3 bucket. Use the DocumentLocation parameter to specify the name of * your S3 bucket and the name of the document in that bucket. *

*

* StartExpenseAnalysis returns a job identifier (JobId) that you will provide to * GetExpenseAnalysis to retrieve the results of the operation. When the analysis of the input * invoices/receipts is finished, Amazon Textract publishes a completion status to the Amazon Simple Notification * Service (Amazon SNS) topic that you provide to the NotificationChannel. To obtain the results of the * invoice and receipt analysis operation, ensure that the status value published to the Amazon SNS topic is * SUCCEEDED. If so, call GetExpenseAnalysis, and pass the job identifier (JobId) * that was returned by your call to StartExpenseAnalysis. *

*

* For more information, see Analyzing Invoices and Receipts. *

* * @param startExpenseAnalysisRequest * @return A Java Future containing the result of the StartExpenseAnalysis operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • InvalidKmsKeyException Indicates you do not have decrypt permissions with the KMS key entered, or the * KMS key was entered incorrectly.
  • *
  • UnsupportedDocumentException The format of the input document isn't supported. Documents for * operations can be in PNG, JPEG, PDF, or TIFF format.
  • *
  • DocumentTooLargeException The document can't be processed because it's too large. The maximum * document size for synchronous operations 10 MB. The maximum document size for asynchronous operations is * 500 MB for PDF files.
  • *
  • BadDocumentException Amazon Textract isn't able to read the document. For more information on the * document limits in Amazon Textract, see limits.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • IdempotentParameterMismatchException A ClientRequestToken input parameter was reused * with an operation, but at least one of the other input parameters is different from the previous call to * the operation.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • LimitExceededException An Amazon Textract service limit was exceeded. For example, if you start too * many asynchronous jobs concurrently, calls to start operations (StartDocumentTextDetection, * for example) raise a LimitExceededException exception (HTTP status code: 400) until the number of * concurrently running jobs is below the Amazon Textract service limit.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.StartExpenseAnalysis * @see AWS * API Documentation */ @Override public CompletableFuture startExpenseAnalysis( StartExpenseAnalysisRequest startExpenseAnalysisRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(startExpenseAnalysisRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, startExpenseAnalysisRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StartExpenseAnalysis"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, StartExpenseAnalysisResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("StartExpenseAnalysis").withProtocolMetadata(protocolMetadata) .withMarshaller(new StartExpenseAnalysisRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(startExpenseAnalysisRequest)); 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 the classification and analysis of an input document. StartLendingAnalysis initiates the * classification and analysis of a packet of lending documents. StartLendingAnalysis operates on a * document file located in an Amazon S3 bucket. *

*

* StartLendingAnalysis can analyze text in documents that are in one of the following formats: JPEG, * PNG, TIFF, PDF. Use DocumentLocation to specify the bucket name and the file name of the document. *

*

* StartLendingAnalysis returns a job identifier (JobId) that you use to get the results * of the operation. When the text analysis is finished, Amazon Textract publishes a completion status to the Amazon * Simple Notification Service (Amazon SNS) topic that you specify in NotificationChannel. To get the * results of the text analysis operation, first check that the status value published to the Amazon SNS topic is * SUCCEEDED. If the status is SUCCEEDED you can call either GetLendingAnalysis or * GetLendingAnalysisSummary and provide the JobId to obtain the results of the analysis. *

*

* If using OutputConfig to specify an Amazon S3 bucket, the output will be contained within the * specified prefix in a directory labeled with the job-id. In the directory there are 3 sub-directories: *

*
    *
  • *

    * detailedResponse (contains the GetLendingAnalysis response) *

    *
  • *
  • *

    * summaryResponse (for the GetLendingAnalysisSummary response) *

    *
  • *
  • *

    * splitDocuments (documents split across logical boundaries) *

    *
  • *
* * @param startLendingAnalysisRequest * @return A Java Future containing the result of the StartLendingAnalysis operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • InvalidS3ObjectException Amazon Textract is unable to access the S3 object that's specified in the * request. for more information, Configure Access to Amazon * S3 For troubleshooting information, see Troubleshooting Amazon S3 *
  • *
  • InvalidKmsKeyException Indicates you do not have decrypt permissions with the KMS key entered, or the * KMS key was entered incorrectly.
  • *
  • UnsupportedDocumentException The format of the input document isn't supported. Documents for * operations can be in PNG, JPEG, PDF, or TIFF format.
  • *
  • DocumentTooLargeException The document can't be processed because it's too large. The maximum * document size for synchronous operations 10 MB. The maximum document size for asynchronous operations is * 500 MB for PDF files.
  • *
  • BadDocumentException Amazon Textract isn't able to read the document. For more information on the * document limits in Amazon Textract, see limits.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • IdempotentParameterMismatchException A ClientRequestToken input parameter was reused * with an operation, but at least one of the other input parameters is different from the previous call to * the operation.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • LimitExceededException An Amazon Textract service limit was exceeded. For example, if you start too * many asynchronous jobs concurrently, calls to start operations (StartDocumentTextDetection, * for example) raise a LimitExceededException exception (HTTP status code: 400) until the number of * concurrently running jobs is below the Amazon Textract service limit.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.StartLendingAnalysis * @see AWS * API Documentation */ @Override public CompletableFuture startLendingAnalysis( StartLendingAnalysisRequest startLendingAnalysisRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(startLendingAnalysisRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, startLendingAnalysisRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StartLendingAnalysis"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, StartLendingAnalysisResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("StartLendingAnalysis").withProtocolMetadata(protocolMetadata) .withMarshaller(new StartLendingAnalysisRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(startLendingAnalysisRequest)); 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); } } /** *

* Adds one or more tags to the specified resource. *

* * @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. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException Returned when an operation tried to access a nonexistent resource.
  • *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • ServiceQuotaExceededException Returned when a request cannot be completed as it would exceed a * maximum service quota.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.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, "Textract"); 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); } } /** *

* Removes any tags with the specified keys from the specified resource. *

* * @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. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException Returned when an operation tried to access a nonexistent resource.
  • *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.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, "Textract"); 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); } } /** *

* Update the configuration for an adapter. FeatureTypes configurations cannot be updated. At least one new * parameter must be specified as an argument. *

* * @param updateAdapterRequest * @return A Java Future containing the result of the UpdateAdapter operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidParameterException An input parameter violated a constraint. For example, in synchronous * operations, an InvalidParameterException exception occurs when neither of the * S3Object or Bytes values are supplied in the Document request * parameter. Validate your parameter before calling the API operation again.
  • *
  • AccessDeniedException You aren't authorized to perform the action. Use the Amazon Resource Name (ARN) * of an authorized user or IAM role to perform the operation.
  • *
  • ConflictException Updating or deleting a resource can cause an inconsistent state.
  • *
  • ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you * want to increase this limit, contact Amazon Textract.
  • *
  • InternalServerErrorException Amazon Textract experienced a service issue. Try your call again.
  • *
  • ThrottlingException Amazon Textract is temporarily unable to process the request. Try your call * again.
  • *
  • ValidationException Indicates that a request was not valid. Check request for proper formatting.
  • *
  • ResourceNotFoundException Returned when an operation tried to access a nonexistent resource.
  • *
  • 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.
  • *
  • TextractException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample TextractAsyncClient.UpdateAdapter * @see AWS API * Documentation */ @Override public CompletableFuture updateAdapter(UpdateAdapterRequest updateAdapterRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateAdapterRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, updateAdapterRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Textract"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateAdapter"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, UpdateAdapterResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("UpdateAdapter").withProtocolMetadata(protocolMetadata) .withMarshaller(new UpdateAdapterRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(updateAdapterRequest)); 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 TextractServiceClientConfiguration serviceClientConfiguration() { return new TextractServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private > T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(TextractException::builder) .protocol(AwsJsonProtocol.AWS_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("BadDocumentException") .exceptionBuilderSupplier(BadDocumentException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidParameterException") .exceptionBuilderSupplier(InvalidParameterException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ThrottlingException") .exceptionBuilderSupplier(ThrottlingException::builder).httpStatusCode(500).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("HumanLoopQuotaExceededException") .exceptionBuilderSupplier(HumanLoopQuotaExceededException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidKMSKeyException") .exceptionBuilderSupplier(InvalidKmsKeyException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ServiceQuotaExceededException") .exceptionBuilderSupplier(ServiceQuotaExceededException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("DocumentTooLargeException") .exceptionBuilderSupplier(DocumentTooLargeException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("UnsupportedDocumentException") .exceptionBuilderSupplier(UnsupportedDocumentException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidS3ObjectException") .exceptionBuilderSupplier(InvalidS3ObjectException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("LimitExceededException") .exceptionBuilderSupplier(LimitExceededException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("AccessDeniedException") .exceptionBuilderSupplier(AccessDeniedException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ConflictException") .exceptionBuilderSupplier(ConflictException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ResourceNotFoundException") .exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("IdempotentParameterMismatchException") .exceptionBuilderSupplier(IdempotentParameterMismatchException::builder).httpStatusCode(400) .build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ValidationException") .exceptionBuilderSupplier(ValidationException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ProvisionedThroughputExceededException") .exceptionBuilderSupplier(ProvisionedThroughputExceededException::builder).httpStatusCode(400) .build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidJobIdException") .exceptionBuilderSupplier(InvalidJobIdException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InternalServerError") .exceptionBuilderSupplier(InternalServerErrorException::builder).httpStatusCode(500).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 void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) { ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder(); RetryMode retryMode = builder.retryMode(); if (retryMode != null) { configuration.option(SdkClientOption.RETRY_STRATEGY, AwsRetryStrategy.forRetryMode(retryMode)); } else { Consumer> configurator = builder.retryStrategyConfigurator(); if (configurator != null) { RetryStrategy.Builder defaultBuilder = AwsRetryStrategy.defaultRetryStrategy().toBuilder(); configurator.accept(defaultBuilder); configuration.option(SdkClientOption.RETRY_STRATEGY, defaultBuilder.build()); } else { RetryStrategy retryStrategy = builder.retryStrategy(); if (retryStrategy != null) { configuration.option(SdkClientOption.RETRY_STRATEGY, retryStrategy); } } } configuration.option(SdkClientOption.CONFIGURED_RETRY_MODE, null); configuration.option(SdkClientOption.CONFIGURED_RETRY_STRATEGY, null); configuration.option(SdkClientOption.CONFIGURED_RETRY_CONFIGURATOR, null); } 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(); } TextractServiceClientConfigurationBuilder serviceConfigBuilder = new TextractServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } updateRetryStrategyClientConfiguration(configuration); return configuration.build(); } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } @Override public void close() { clientHandler.close(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy