Class DocumentProcessorServiceClient (2.4.3)

public class DocumentProcessorServiceClient implements BackgroundResource

Service Description: Service to call Cloud DocumentAI to process documents according to the processor's definition. Processors are built using state-of-the-art Google AI such as natural language, computer vision, and translation to extract structured information from unstructured or semi-structured documents.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
   ProcessResponse response = documentProcessorServiceClient.processDocument(name);
 }
 

Note: close() needs to be called on the DocumentProcessorServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of DocumentProcessorServiceSettings to create(). For example:

To customize credentials:


 DocumentProcessorServiceSettings documentProcessorServiceSettings =
     DocumentProcessorServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create(documentProcessorServiceSettings);
 

To customize the endpoint:


 DocumentProcessorServiceSettings documentProcessorServiceSettings =
     DocumentProcessorServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create(documentProcessorServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > DocumentProcessorServiceClient

Implements

BackgroundResource

Static Methods

create()

public static final DocumentProcessorServiceClient create()

Constructs an instance of DocumentProcessorServiceClient with default settings.

Returns
Type Description
DocumentProcessorServiceClient
Exceptions
Type Description
IOException

create(DocumentProcessorServiceSettings settings)

public static final DocumentProcessorServiceClient create(DocumentProcessorServiceSettings settings)

Constructs an instance of DocumentProcessorServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings DocumentProcessorServiceSettings
Returns
Type Description
DocumentProcessorServiceClient
Exceptions
Type Description
IOException

create(DocumentProcessorServiceStub stub)

public static final DocumentProcessorServiceClient create(DocumentProcessorServiceStub stub)

Constructs an instance of DocumentProcessorServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(DocumentProcessorServiceSettings).

Parameter
Name Description
stub DocumentProcessorServiceStub
Returns
Type Description
DocumentProcessorServiceClient

Constructors

DocumentProcessorServiceClient(DocumentProcessorServiceSettings settings)

protected DocumentProcessorServiceClient(DocumentProcessorServiceSettings settings)

Constructs an instance of DocumentProcessorServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description
settings DocumentProcessorServiceSettings

DocumentProcessorServiceClient(DocumentProcessorServiceStub stub)

protected DocumentProcessorServiceClient(DocumentProcessorServiceStub stub)
Parameter
Name Description
stub DocumentProcessorServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

batchProcessDocumentsAsync(BatchProcessRequest request)

public final OperationFuture<BatchProcessResponse,BatchProcessMetadata> batchProcessDocumentsAsync(BatchProcessRequest request)

LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   BatchProcessRequest request =
       BatchProcessRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .addAllInputConfigs(new ArrayList<BatchProcessRequest.BatchInputConfig>())
           .setOutputConfig(BatchProcessRequest.BatchOutputConfig.newBuilder().build())
           .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build())
           .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
           .setSkipHumanReview(true)
           .build();
   BatchProcessResponse response =
       documentProcessorServiceClient.batchProcessDocumentsAsync(request).get();
 }
 
Parameter
Name Description
request BatchProcessRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<BatchProcessResponse,BatchProcessMetadata>

batchProcessDocumentsAsync(ProcessorName name)

public final OperationFuture<BatchProcessResponse,BatchProcessMetadata> batchProcessDocumentsAsync(ProcessorName name)

LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
   BatchProcessResponse response =
       documentProcessorServiceClient.batchProcessDocumentsAsync(name).get();
 }
 
Parameter
Name Description
name ProcessorName

Required. The processor resource name.

Returns
Type Description
OperationFuture<BatchProcessResponse,BatchProcessMetadata>

batchProcessDocumentsAsync(String name)

public final OperationFuture<BatchProcessResponse,BatchProcessMetadata> batchProcessDocumentsAsync(String name)

LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   String name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString();
   BatchProcessResponse response =
       documentProcessorServiceClient.batchProcessDocumentsAsync(name).get();
 }
 
Parameter
Name Description
name String

Required. The processor resource name.

Returns
Type Description
OperationFuture<BatchProcessResponse,BatchProcessMetadata>

batchProcessDocumentsCallable()

public final UnaryCallable<BatchProcessRequest,Operation> batchProcessDocumentsCallable()

LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   BatchProcessRequest request =
       BatchProcessRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .addAllInputConfigs(new ArrayList<BatchProcessRequest.BatchInputConfig>())
           .setOutputConfig(BatchProcessRequest.BatchOutputConfig.newBuilder().build())
           .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build())
           .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
           .setSkipHumanReview(true)
           .build();
   ApiFuture<Operation> future =
       documentProcessorServiceClient.batchProcessDocumentsCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<BatchProcessRequest,Operation>

batchProcessDocumentsOperationCallable()

public final OperationCallable<BatchProcessRequest,BatchProcessResponse,BatchProcessMetadata> batchProcessDocumentsOperationCallable()

LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   BatchProcessRequest request =
       BatchProcessRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .addAllInputConfigs(new ArrayList<BatchProcessRequest.BatchInputConfig>())
           .setOutputConfig(BatchProcessRequest.BatchOutputConfig.newBuilder().build())
           .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build())
           .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
           .setSkipHumanReview(true)
           .build();
   OperationFuture<BatchProcessResponse, BatchProcessMetadata> future =
       documentProcessorServiceClient
           .batchProcessDocumentsOperationCallable()
           .futureCall(request);
   // Do something.
   BatchProcessResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<BatchProcessRequest,BatchProcessResponse,BatchProcessMetadata>

close()

public final void close()

createProcessor(CreateProcessorRequest request)

public final Processor createProcessor(CreateProcessorRequest request)

Creates a processor from the type processor that the user chose. The processor will be at "ENABLED" state by default after its creation.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   CreateProcessorRequest request =
       CreateProcessorRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setProcessor(Processor.newBuilder().build())
           .build();
   Processor response = documentProcessorServiceClient.createProcessor(request);
 }
 
Parameter
Name Description
request CreateProcessorRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Processor

createProcessor(LocationName parent, Processor processor)

public final Processor createProcessor(LocationName parent, Processor processor)

Creates a processor from the type processor that the user chose. The processor will be at "ENABLED" state by default after its creation.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   Processor processor = Processor.newBuilder().build();
   Processor response = documentProcessorServiceClient.createProcessor(parent, processor);
 }
 
Parameters
Name Description
parent LocationName

Required. The parent (project and location) under which to create the processor. Format: projects/{project}/locations/{location}

processor Processor

Required. The processor to be created, requires [processor_type] and [display_name] to be set. Also, the processor is under CMEK if CMEK fields are set.

Returns
Type Description
Processor

createProcessor(String parent, Processor processor)

public final Processor createProcessor(String parent, Processor processor)

Creates a processor from the type processor that the user chose. The processor will be at "ENABLED" state by default after its creation.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   Processor processor = Processor.newBuilder().build();
   Processor response = documentProcessorServiceClient.createProcessor(parent, processor);
 }
 
Parameters
Name Description
parent String

Required. The parent (project and location) under which to create the processor. Format: projects/{project}/locations/{location}

processor Processor

Required. The processor to be created, requires [processor_type] and [display_name] to be set. Also, the processor is under CMEK if CMEK fields are set.

Returns
Type Description
Processor

createProcessorCallable()

public final UnaryCallable<CreateProcessorRequest,Processor> createProcessorCallable()

Creates a processor from the type processor that the user chose. The processor will be at "ENABLED" state by default after its creation.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   CreateProcessorRequest request =
       CreateProcessorRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setProcessor(Processor.newBuilder().build())
           .build();
   ApiFuture<Processor> future =
       documentProcessorServiceClient.createProcessorCallable().futureCall(request);
   // Do something.
   Processor response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateProcessorRequest,Processor>

deleteProcessorAsync(DeleteProcessorRequest request)

public final OperationFuture<Empty,DeleteProcessorMetadata> deleteProcessorAsync(DeleteProcessorRequest request)

Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   DeleteProcessorRequest request =
       DeleteProcessorRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .build();
   documentProcessorServiceClient.deleteProcessorAsync(request).get();
 }
 
Parameter
Name Description
request DeleteProcessorRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<Empty,DeleteProcessorMetadata>

deleteProcessorAsync(ProcessorName name)

public final OperationFuture<Empty,DeleteProcessorMetadata> deleteProcessorAsync(ProcessorName name)

Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
   documentProcessorServiceClient.deleteProcessorAsync(name).get();
 }
 
Parameter
Name Description
name ProcessorName

Required. The processor resource name to be deleted.

Returns
Type Description
OperationFuture<Empty,DeleteProcessorMetadata>

deleteProcessorAsync(String name)

public final OperationFuture<Empty,DeleteProcessorMetadata> deleteProcessorAsync(String name)

Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   String name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString();
   documentProcessorServiceClient.deleteProcessorAsync(name).get();
 }
 
Parameter
Name Description
name String

Required. The processor resource name to be deleted.

Returns
Type Description
OperationFuture<Empty,DeleteProcessorMetadata>

deleteProcessorCallable()

public final UnaryCallable<DeleteProcessorRequest,Operation> deleteProcessorCallable()

Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   DeleteProcessorRequest request =
       DeleteProcessorRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .build();
   ApiFuture<Operation> future =
       documentProcessorServiceClient.deleteProcessorCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteProcessorRequest,Operation>

deleteProcessorOperationCallable()

public final OperationCallable<DeleteProcessorRequest,Empty,DeleteProcessorMetadata> deleteProcessorOperationCallable()

Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   DeleteProcessorRequest request =
       DeleteProcessorRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .build();
   OperationFuture<Empty, DeleteProcessorMetadata> future =
       documentProcessorServiceClient.deleteProcessorOperationCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
OperationCallable<DeleteProcessorRequest,Empty,DeleteProcessorMetadata>

disableProcessorAsync(DisableProcessorRequest request)

public final OperationFuture<DisableProcessorResponse,DisableProcessorMetadata> disableProcessorAsync(DisableProcessorRequest request)

Disables a processor

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   DisableProcessorRequest request =
       DisableProcessorRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .build();
   DisableProcessorResponse response =
       documentProcessorServiceClient.disableProcessorAsync(request).get();
 }
 
Parameter
Name Description
request DisableProcessorRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<DisableProcessorResponse,DisableProcessorMetadata>

disableProcessorCallable()

public final UnaryCallable<DisableProcessorRequest,Operation> disableProcessorCallable()

Disables a processor

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   DisableProcessorRequest request =
       DisableProcessorRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .build();
   ApiFuture<Operation> future =
       documentProcessorServiceClient.disableProcessorCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<DisableProcessorRequest,Operation>

disableProcessorOperationCallable()

public final OperationCallable<DisableProcessorRequest,DisableProcessorResponse,DisableProcessorMetadata> disableProcessorOperationCallable()

Disables a processor

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   DisableProcessorRequest request =
       DisableProcessorRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .build();
   OperationFuture<DisableProcessorResponse, DisableProcessorMetadata> future =
       documentProcessorServiceClient.disableProcessorOperationCallable().futureCall(request);
   // Do something.
   DisableProcessorResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<DisableProcessorRequest,DisableProcessorResponse,DisableProcessorMetadata>

enableProcessorAsync(EnableProcessorRequest request)

public final OperationFuture<EnableProcessorResponse,EnableProcessorMetadata> enableProcessorAsync(EnableProcessorRequest request)

Enables a processor

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   EnableProcessorRequest request =
       EnableProcessorRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .build();
   EnableProcessorResponse response =
       documentProcessorServiceClient.enableProcessorAsync(request).get();
 }
 
Parameter
Name Description
request EnableProcessorRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<EnableProcessorResponse,EnableProcessorMetadata>

enableProcessorCallable()

public final UnaryCallable<EnableProcessorRequest,Operation> enableProcessorCallable()

Enables a processor

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   EnableProcessorRequest request =
       EnableProcessorRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .build();
   ApiFuture<Operation> future =
       documentProcessorServiceClient.enableProcessorCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<EnableProcessorRequest,Operation>

enableProcessorOperationCallable()

public final OperationCallable<EnableProcessorRequest,EnableProcessorResponse,EnableProcessorMetadata> enableProcessorOperationCallable()

Enables a processor

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   EnableProcessorRequest request =
       EnableProcessorRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .build();
   OperationFuture<EnableProcessorResponse, EnableProcessorMetadata> future =
       documentProcessorServiceClient.enableProcessorOperationCallable().futureCall(request);
   // Do something.
   EnableProcessorResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<EnableProcessorRequest,EnableProcessorResponse,EnableProcessorMetadata>

fetchProcessorTypes(FetchProcessorTypesRequest request)

public final FetchProcessorTypesResponse fetchProcessorTypes(FetchProcessorTypesRequest request)

Fetches processor types.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   FetchProcessorTypesRequest request =
       FetchProcessorTypesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .build();
   FetchProcessorTypesResponse response =
       documentProcessorServiceClient.fetchProcessorTypes(request);
 }
 
Parameter
Name Description
request FetchProcessorTypesRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
FetchProcessorTypesResponse

fetchProcessorTypes(LocationName parent)

public final FetchProcessorTypesResponse fetchProcessorTypes(LocationName parent)

Fetches processor types.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   FetchProcessorTypesResponse response =
       documentProcessorServiceClient.fetchProcessorTypes(parent);
 }
 
Parameter
Name Description
parent LocationName

Required. The project of processor type to list. Format: projects/{project}/locations/{location}

Returns
Type Description
FetchProcessorTypesResponse

fetchProcessorTypes(String parent)

public final FetchProcessorTypesResponse fetchProcessorTypes(String parent)

Fetches processor types.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   FetchProcessorTypesResponse response =
       documentProcessorServiceClient.fetchProcessorTypes(parent);
 }
 
Parameter
Name Description
parent String

Required. The project of processor type to list. Format: projects/{project}/locations/{location}

Returns
Type Description
FetchProcessorTypesResponse

fetchProcessorTypesCallable()

public final UnaryCallable<FetchProcessorTypesRequest,FetchProcessorTypesResponse> fetchProcessorTypesCallable()

Fetches processor types.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   FetchProcessorTypesRequest request =
       FetchProcessorTypesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .build();
   ApiFuture<FetchProcessorTypesResponse> future =
       documentProcessorServiceClient.fetchProcessorTypesCallable().futureCall(request);
   // Do something.
   FetchProcessorTypesResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<FetchProcessorTypesRequest,FetchProcessorTypesResponse>

getOperationsClient()

public final OperationsClient getOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
Type Description
OperationsClient

getSettings()

public final DocumentProcessorServiceSettings getSettings()
Returns
Type Description
DocumentProcessorServiceSettings

getStub()

public DocumentProcessorServiceStub getStub()
Returns
Type Description
DocumentProcessorServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listProcessors(ListProcessorsRequest request)

public final DocumentProcessorServiceClient.ListProcessorsPagedResponse listProcessors(ListProcessorsRequest request)

Lists all processors which belong to this project.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ListProcessorsRequest request =
       ListProcessorsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Processor element :
       documentProcessorServiceClient.listProcessors(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListProcessorsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
DocumentProcessorServiceClient.ListProcessorsPagedResponse

listProcessors(LocationName parent)

public final DocumentProcessorServiceClient.ListProcessorsPagedResponse listProcessors(LocationName parent)

Lists all processors which belong to this project.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (Processor element : documentProcessorServiceClient.listProcessors(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent LocationName

Required. The parent (project and location) which owns this collection of Processors. Format: projects/{project}/locations/{location}

Returns
Type Description
DocumentProcessorServiceClient.ListProcessorsPagedResponse

listProcessors(String parent)

public final DocumentProcessorServiceClient.ListProcessorsPagedResponse listProcessors(String parent)

Lists all processors which belong to this project.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   for (Processor element : documentProcessorServiceClient.listProcessors(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The parent (project and location) which owns this collection of Processors. Format: projects/{project}/locations/{location}

Returns
Type Description
DocumentProcessorServiceClient.ListProcessorsPagedResponse

listProcessorsCallable()

public final UnaryCallable<ListProcessorsRequest,ListProcessorsResponse> listProcessorsCallable()

Lists all processors which belong to this project.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ListProcessorsRequest request =
       ListProcessorsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListProcessorsResponse response =
         documentProcessorServiceClient.listProcessorsCallable().call(request);
     for (Processor element : response.getResponsesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListProcessorsRequest,ListProcessorsResponse>

listProcessorsPagedCallable()

public final UnaryCallable<ListProcessorsRequest,DocumentProcessorServiceClient.ListProcessorsPagedResponse> listProcessorsPagedCallable()

Lists all processors which belong to this project.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ListProcessorsRequest request =
       ListProcessorsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Processor> future =
       documentProcessorServiceClient.listProcessorsPagedCallable().futureCall(request);
   // Do something.
   for (Processor element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListProcessorsRequest,ListProcessorsPagedResponse>

processDocument(ProcessRequest request)

public final ProcessResponse processDocument(ProcessRequest request)

Processes a single document.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ProcessRequest request =
       ProcessRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .setDocument(Document.newBuilder().build())
           .setSkipHumanReview(true)
           .build();
   ProcessResponse response = documentProcessorServiceClient.processDocument(request);
 }
 
Parameter
Name Description
request ProcessRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ProcessResponse

processDocument(ProcessorName name)

public final ProcessResponse processDocument(ProcessorName name)

Processes a single document.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
   ProcessResponse response = documentProcessorServiceClient.processDocument(name);
 }
 
Parameter
Name Description
name ProcessorName

Required. The processor resource name.

Returns
Type Description
ProcessResponse

processDocument(String name)

public final ProcessResponse processDocument(String name)

Processes a single document.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   String name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString();
   ProcessResponse response = documentProcessorServiceClient.processDocument(name);
 }
 
Parameter
Name Description
name String

Required. The processor resource name.

Returns
Type Description
ProcessResponse

processDocumentCallable()

public final UnaryCallable<ProcessRequest,ProcessResponse> processDocumentCallable()

Processes a single document.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ProcessRequest request =
       ProcessRequest.newBuilder()
           .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .setDocument(Document.newBuilder().build())
           .setSkipHumanReview(true)
           .build();
   ApiFuture<ProcessResponse> future =
       documentProcessorServiceClient.processDocumentCallable().futureCall(request);
   // Do something.
   ProcessResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ProcessRequest,ProcessResponse>

reviewDocumentAsync(HumanReviewConfigName humanReviewConfig)

public final OperationFuture<ReviewDocumentResponse,ReviewDocumentOperationMetadata> reviewDocumentAsync(HumanReviewConfigName humanReviewConfig)

Send a document for Human Review. The input document should be processed by the specified processor.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   HumanReviewConfigName humanReviewConfig =
       HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
   ReviewDocumentResponse response =
       documentProcessorServiceClient.reviewDocumentAsync(humanReviewConfig).get();
 }
 
Parameter
Name Description
humanReviewConfig HumanReviewConfigName

Required. The resource name of the HumanReviewConfig that the document will be reviewed with.

Returns
Type Description
OperationFuture<ReviewDocumentResponse,ReviewDocumentOperationMetadata>

reviewDocumentAsync(ReviewDocumentRequest request)

public final OperationFuture<ReviewDocumentResponse,ReviewDocumentOperationMetadata> reviewDocumentAsync(ReviewDocumentRequest request)

Send a document for Human Review. The input document should be processed by the specified processor.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ReviewDocumentRequest request =
       ReviewDocumentRequest.newBuilder()
           .setHumanReviewConfig(
               HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .setDocument(Document.newBuilder().build())
           .setEnableSchemaValidation(true)
           .build();
   ReviewDocumentResponse response =
       documentProcessorServiceClient.reviewDocumentAsync(request).get();
 }
 
Parameter
Name Description
request ReviewDocumentRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<ReviewDocumentResponse,ReviewDocumentOperationMetadata>

reviewDocumentAsync(String humanReviewConfig)

public final OperationFuture<ReviewDocumentResponse,ReviewDocumentOperationMetadata> reviewDocumentAsync(String humanReviewConfig)

Send a document for Human Review. The input document should be processed by the specified processor.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   String humanReviewConfig =
       HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString();
   ReviewDocumentResponse response =
       documentProcessorServiceClient.reviewDocumentAsync(humanReviewConfig).get();
 }
 
Parameter
Name Description
humanReviewConfig String

Required. The resource name of the HumanReviewConfig that the document will be reviewed with.

Returns
Type Description
OperationFuture<ReviewDocumentResponse,ReviewDocumentOperationMetadata>

reviewDocumentCallable()

public final UnaryCallable<ReviewDocumentRequest,Operation> reviewDocumentCallable()

Send a document for Human Review. The input document should be processed by the specified processor.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ReviewDocumentRequest request =
       ReviewDocumentRequest.newBuilder()
           .setHumanReviewConfig(
               HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .setDocument(Document.newBuilder().build())
           .setEnableSchemaValidation(true)
           .build();
   ApiFuture<Operation> future =
       documentProcessorServiceClient.reviewDocumentCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ReviewDocumentRequest,Operation>

reviewDocumentOperationCallable()

public final OperationCallable<ReviewDocumentRequest,ReviewDocumentResponse,ReviewDocumentOperationMetadata> reviewDocumentOperationCallable()

Send a document for Human Review. The input document should be processed by the specified processor.

Sample code:


 try (DocumentProcessorServiceClient documentProcessorServiceClient =
     DocumentProcessorServiceClient.create()) {
   ReviewDocumentRequest request =
       ReviewDocumentRequest.newBuilder()
           .setHumanReviewConfig(
               HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
           .setDocument(Document.newBuilder().build())
           .setEnableSchemaValidation(true)
           .build();
   OperationFuture<ReviewDocumentResponse, ReviewDocumentOperationMetadata> future =
       documentProcessorServiceClient.reviewDocumentOperationCallable().futureCall(request);
   // Do something.
   ReviewDocumentResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<ReviewDocumentRequest,ReviewDocumentResponse,ReviewDocumentOperationMetadata>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()