Class DocumentServiceClient (0.39.0)

GitHub RepositoryProduct Reference

Service Description: Service for ingesting Document information of the customer's website.

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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   DocumentName name =
       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]");
   Document response = documentServiceClient.getDocument(name);
 }
 

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

Methods
Method Description Method Variants

GetDocument

Gets a Document.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getDocument(GetDocumentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getDocument(DocumentName name)

  • getDocument(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getDocumentCallable()

ListDocuments

Gets a list of Documents.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listDocuments(ListDocumentsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listDocuments(BranchName parent)

  • listDocuments(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listDocumentsPagedCallable()

  • listDocumentsCallable()

CreateDocument

Creates a Document.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createDocument(CreateDocumentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createDocument(BranchName parent, Document document, String documentId)

  • createDocument(String parent, Document document, String documentId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createDocumentCallable()

UpdateDocument

Updates a Document.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateDocument(UpdateDocumentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateDocument(Document document, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateDocumentCallable()

DeleteDocument

Deletes a Document.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteDocument(DeleteDocumentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteDocument(DocumentName name)

  • deleteDocument(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteDocumentCallable()

ImportDocuments

Bulk import of multiple Documents. Request processing may be synchronous. Non-existing items will be created.

Note: It is possible for a subset of the Documents to be successfully updated.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • importDocumentsAsync(ImportDocumentsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • importDocumentsOperationCallable()

  • importDocumentsCallable()

PurgeDocuments

Permanently deletes all selected Documents in a branch.

This process is asynchronous. Depending on the number of Documents to be deleted, this operation can take hours to complete. Before the delete operation completes, some Documents might still be returned by DocumentService.GetDocument or DocumentService.ListDocuments.

To get a list of the Documents to be deleted, set PurgeDocumentsRequest.force to false.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • purgeDocumentsAsync(PurgeDocumentsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • purgeDocumentsOperationCallable()

  • purgeDocumentsCallable()

GetProcessedDocument

Gets the parsed layout information for a Document.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getProcessedDocument(GetProcessedDocumentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getProcessedDocument(DocumentName name)

  • getProcessedDocument(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getProcessedDocumentCallable()

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 DocumentServiceSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 DocumentServiceSettings documentServiceSettings =
     DocumentServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 DocumentServiceClient documentServiceClient =
     DocumentServiceClient.create(documentServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 DocumentServiceSettings documentServiceSettings =
     DocumentServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 DocumentServiceClient documentServiceClient =
     DocumentServiceClient.create(documentServiceSettings);
 

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 DocumentServiceSettings documentServiceSettings =
     DocumentServiceSettings.newHttpJsonBuilder().build();
 DocumentServiceClient documentServiceClient =
     DocumentServiceClient.create(documentServiceSettings);
 

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

Inheritance

java.lang.Object > DocumentServiceClient

Static Methods

create()

public static final DocumentServiceClient create()

Constructs an instance of DocumentServiceClient with default settings.

Returns
Type Description
DocumentServiceClient
Exceptions
Type Description
IOException

create(DocumentServiceSettings settings)

public static final DocumentServiceClient create(DocumentServiceSettings settings)

Constructs an instance of DocumentServiceClient, 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 DocumentServiceSettings
Returns
Type Description
DocumentServiceClient
Exceptions
Type Description
IOException

create(DocumentServiceStub stub)

public static final DocumentServiceClient create(DocumentServiceStub stub)

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

Parameter
Name Description
stub DocumentServiceStub
Returns
Type Description
DocumentServiceClient

Constructors

DocumentServiceClient(DocumentServiceSettings settings)

protected DocumentServiceClient(DocumentServiceSettings settings)

Constructs an instance of DocumentServiceClient, 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 DocumentServiceSettings

DocumentServiceClient(DocumentServiceStub stub)

protected DocumentServiceClient(DocumentServiceStub stub)
Parameter
Name Description
stub DocumentServiceStub

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

close()

public final void close()

createDocument(BranchName parent, Document document, String documentId)

public final Document createDocument(BranchName parent, Document document, String documentId)

Creates a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   BranchName parent =
       BranchName.ofProjectLocationDataStoreBranchName(
           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]");
   Document document = Document.newBuilder().build();
   String documentId = "documentId-814940266";
   Document response = documentServiceClient.createDocument(parent, document, documentId);
 }
 
Parameters
Name Description
parent BranchName

Required. The parent resource name, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}.

document Document

Required. The Document to create.

documentId String

Required. The ID to use for the Document, which will become the final component of the Document.name.

If the caller does not have permission to create the Document, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.

This field must be unique among all Documents with the same parent. Otherwise, an ALREADY_EXISTS error is returned.

This field must conform to RFC-1034 standard with a length limit of 63 characters. Otherwise, an INVALID_ARGUMENT error is returned.

Returns
Type Description
Document

createDocument(CreateDocumentRequest request)

public final Document createDocument(CreateDocumentRequest request)

Creates a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   CreateDocumentRequest request =
       CreateDocumentRequest.newBuilder()
           .setParent(
               BranchName.ofProjectLocationDataStoreBranchName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
                   .toString())
           .setDocument(Document.newBuilder().build())
           .setDocumentId("documentId-814940266")
           .build();
   Document response = documentServiceClient.createDocument(request);
 }
 
Parameter
Name Description
request CreateDocumentRequest

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

Returns
Type Description
Document

createDocument(String parent, Document document, String documentId)

public final Document createDocument(String parent, Document document, String documentId)

Creates a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   String parent =
       BranchName.ofProjectLocationDataStoreBranchName(
               "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
           .toString();
   Document document = Document.newBuilder().build();
   String documentId = "documentId-814940266";
   Document response = documentServiceClient.createDocument(parent, document, documentId);
 }
 
Parameters
Name Description
parent String

Required. The parent resource name, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}.

document Document

Required. The Document to create.

documentId String

Required. The ID to use for the Document, which will become the final component of the Document.name.

If the caller does not have permission to create the Document, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.

This field must be unique among all Documents with the same parent. Otherwise, an ALREADY_EXISTS error is returned.

This field must conform to RFC-1034 standard with a length limit of 63 characters. Otherwise, an INVALID_ARGUMENT error is returned.

Returns
Type Description
Document

createDocumentCallable()

public final UnaryCallable<CreateDocumentRequest,Document> createDocumentCallable()

Creates a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   CreateDocumentRequest request =
       CreateDocumentRequest.newBuilder()
           .setParent(
               BranchName.ofProjectLocationDataStoreBranchName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
                   .toString())
           .setDocument(Document.newBuilder().build())
           .setDocumentId("documentId-814940266")
           .build();
   ApiFuture<Document> future =
       documentServiceClient.createDocumentCallable().futureCall(request);
   // Do something.
   Document response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateDocumentRequest,Document>

deleteDocument(DeleteDocumentRequest request)

public final void deleteDocument(DeleteDocumentRequest request)

Deletes a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   DeleteDocumentRequest request =
       DeleteDocumentRequest.newBuilder()
           .setName(
               DocumentName.ofProjectLocationDataStoreBranchDocumentName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
                   .toString())
           .build();
   documentServiceClient.deleteDocument(request);
 }
 
Parameter
Name Description
request DeleteDocumentRequest

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

deleteDocument(DocumentName name)

public final void deleteDocument(DocumentName name)

Deletes a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   DocumentName name =
       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]");
   documentServiceClient.deleteDocument(name);
 }
 
Parameter
Name Description
name DocumentName

Required. Full resource name of Document, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}.

If the caller does not have permission to delete the Document, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.

If the Document to delete does not exist, a NOT_FOUND error is returned.

deleteDocument(String name)

public final void deleteDocument(String name)

Deletes a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   String name =
       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
               "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
           .toString();
   documentServiceClient.deleteDocument(name);
 }
 
Parameter
Name Description
name String

Required. Full resource name of Document, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}.

If the caller does not have permission to delete the Document, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.

If the Document to delete does not exist, a NOT_FOUND error is returned.

deleteDocumentCallable()

public final UnaryCallable<DeleteDocumentRequest,Empty> deleteDocumentCallable()

Deletes a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   DeleteDocumentRequest request =
       DeleteDocumentRequest.newBuilder()
           .setName(
               DocumentName.ofProjectLocationDataStoreBranchDocumentName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
                   .toString())
           .build();
   ApiFuture<Empty> future = documentServiceClient.deleteDocumentCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteDocumentRequest,Empty>

getDocument(DocumentName name)

public final Document getDocument(DocumentName name)

Gets a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   DocumentName name =
       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]");
   Document response = documentServiceClient.getDocument(name);
 }
 
Parameter
Name Description
name DocumentName

Required. Full resource name of Document, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}.

If the caller does not have permission to access the Document, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.

If the requested Document does not exist, a NOT_FOUND error is returned.

Returns
Type Description
Document

getDocument(GetDocumentRequest request)

public final Document getDocument(GetDocumentRequest request)

Gets a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   GetDocumentRequest request =
       GetDocumentRequest.newBuilder()
           .setName(
               DocumentName.ofProjectLocationDataStoreBranchDocumentName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
                   .toString())
           .build();
   Document response = documentServiceClient.getDocument(request);
 }
 
Parameter
Name Description
request GetDocumentRequest

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

Returns
Type Description
Document

getDocument(String name)

public final Document getDocument(String name)

Gets a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   String name =
       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
               "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
           .toString();
   Document response = documentServiceClient.getDocument(name);
 }
 
Parameter
Name Description
name String

Required. Full resource name of Document, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}.

If the caller does not have permission to access the Document, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.

If the requested Document does not exist, a NOT_FOUND error is returned.

Returns
Type Description
Document

getDocumentCallable()

public final UnaryCallable<GetDocumentRequest,Document> getDocumentCallable()

Gets a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   GetDocumentRequest request =
       GetDocumentRequest.newBuilder()
           .setName(
               DocumentName.ofProjectLocationDataStoreBranchDocumentName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
                   .toString())
           .build();
   ApiFuture<Document> future = documentServiceClient.getDocumentCallable().futureCall(request);
   // Do something.
   Document response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetDocumentRequest,Document>

getHttpJsonOperationsClient()

public final OperationsClient getHttpJsonOperationsClient()

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

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

getProcessedDocument(DocumentName name)

public final ProcessedDocument getProcessedDocument(DocumentName name)

Gets the parsed layout information for a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   DocumentName name =
       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]");
   ProcessedDocument response = documentServiceClient.getProcessedDocument(name);
 }
 
Parameter
Name Description
name DocumentName

Required. Full resource name of Document, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}.

If the caller does not have permission to access the Document, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.

If the requested Document does not exist, a NOT_FOUND error is returned.

Returns
Type Description
ProcessedDocument

getProcessedDocument(GetProcessedDocumentRequest request)

public final ProcessedDocument getProcessedDocument(GetProcessedDocumentRequest request)

Gets the parsed layout information for a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   GetProcessedDocumentRequest request =
       GetProcessedDocumentRequest.newBuilder()
           .setName(
               DocumentName.ofProjectLocationDataStoreBranchDocumentName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
                   .toString())
           .build();
   ProcessedDocument response = documentServiceClient.getProcessedDocument(request);
 }
 
Parameter
Name Description
request GetProcessedDocumentRequest

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

Returns
Type Description
ProcessedDocument

getProcessedDocument(String name)

public final ProcessedDocument getProcessedDocument(String name)

Gets the parsed layout information for a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   String name =
       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
               "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
           .toString();
   ProcessedDocument response = documentServiceClient.getProcessedDocument(name);
 }
 
Parameter
Name Description
name String

Required. Full resource name of Document, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}.

If the caller does not have permission to access the Document, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.

If the requested Document does not exist, a NOT_FOUND error is returned.

Returns
Type Description
ProcessedDocument

getProcessedDocumentCallable()

public final UnaryCallable<GetProcessedDocumentRequest,ProcessedDocument> getProcessedDocumentCallable()

Gets the parsed layout information for a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   GetProcessedDocumentRequest request =
       GetProcessedDocumentRequest.newBuilder()
           .setName(
               DocumentName.ofProjectLocationDataStoreBranchDocumentName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
                   .toString())
           .build();
   ApiFuture<ProcessedDocument> future =
       documentServiceClient.getProcessedDocumentCallable().futureCall(request);
   // Do something.
   ProcessedDocument response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetProcessedDocumentRequest,ProcessedDocument>

getSettings()

public final DocumentServiceSettings getSettings()
Returns
Type Description
DocumentServiceSettings

getStub()

public DocumentServiceStub getStub()
Returns
Type Description
DocumentServiceStub

importDocumentsAsync(ImportDocumentsRequest request)

public final OperationFuture<ImportDocumentsResponse,ImportDocumentsMetadata> importDocumentsAsync(ImportDocumentsRequest request)

Bulk import of multiple Documents. Request processing may be synchronous. Non-existing items will be created.

Note: It is possible for a subset of the Documents to be successfully updated.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   ImportDocumentsRequest request =
       ImportDocumentsRequest.newBuilder()
           .setParent(
               BranchName.ofProjectLocationDataStoreBranchName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
                   .toString())
           .setErrorConfig(ImportErrorConfig.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .setAutoGenerateIds(true)
           .setIdField("idField1629396127")
           .build();
   ImportDocumentsResponse response = documentServiceClient.importDocumentsAsync(request).get();
 }
 
Parameter
Name Description
request ImportDocumentsRequest

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

Returns
Type Description
OperationFuture<ImportDocumentsResponse,ImportDocumentsMetadata>

importDocumentsCallable()

public final UnaryCallable<ImportDocumentsRequest,Operation> importDocumentsCallable()

Bulk import of multiple Documents. Request processing may be synchronous. Non-existing items will be created.

Note: It is possible for a subset of the Documents to be successfully updated.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   ImportDocumentsRequest request =
       ImportDocumentsRequest.newBuilder()
           .setParent(
               BranchName.ofProjectLocationDataStoreBranchName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
                   .toString())
           .setErrorConfig(ImportErrorConfig.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .setAutoGenerateIds(true)
           .setIdField("idField1629396127")
           .build();
   ApiFuture<Operation> future =
       documentServiceClient.importDocumentsCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ImportDocumentsRequest,Operation>

importDocumentsOperationCallable()

public final OperationCallable<ImportDocumentsRequest,ImportDocumentsResponse,ImportDocumentsMetadata> importDocumentsOperationCallable()

Bulk import of multiple Documents. Request processing may be synchronous. Non-existing items will be created.

Note: It is possible for a subset of the Documents to be successfully updated.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   ImportDocumentsRequest request =
       ImportDocumentsRequest.newBuilder()
           .setParent(
               BranchName.ofProjectLocationDataStoreBranchName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
                   .toString())
           .setErrorConfig(ImportErrorConfig.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .setAutoGenerateIds(true)
           .setIdField("idField1629396127")
           .build();
   OperationFuture<ImportDocumentsResponse, ImportDocumentsMetadata> future =
       documentServiceClient.importDocumentsOperationCallable().futureCall(request);
   // Do something.
   ImportDocumentsResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<ImportDocumentsRequest,ImportDocumentsResponse,ImportDocumentsMetadata>

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listDocuments(BranchName parent)

public final DocumentServiceClient.ListDocumentsPagedResponse listDocuments(BranchName parent)

Gets a list of Documents.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   BranchName parent =
       BranchName.ofProjectLocationDataStoreBranchName(
           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]");
   for (Document element : documentServiceClient.listDocuments(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent BranchName

Required. The parent branch resource name, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}. Use default_branch as the branch ID, to list documents under the default branch.

If the caller does not have permission to list Documents under this branch, regardless of whether or not this branch exists, a PERMISSION_DENIED error is returned.

Returns
Type Description
DocumentServiceClient.ListDocumentsPagedResponse

listDocuments(ListDocumentsRequest request)

public final DocumentServiceClient.ListDocumentsPagedResponse listDocuments(ListDocumentsRequest request)

Gets a list of Documents.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   ListDocumentsRequest request =
       ListDocumentsRequest.newBuilder()
           .setParent(
               BranchName.ofProjectLocationDataStoreBranchName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
                   .toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Document element : documentServiceClient.listDocuments(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListDocumentsRequest

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

Returns
Type Description
DocumentServiceClient.ListDocumentsPagedResponse

listDocuments(String parent)

public final DocumentServiceClient.ListDocumentsPagedResponse listDocuments(String parent)

Gets a list of Documents.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   String parent =
       BranchName.ofProjectLocationDataStoreBranchName(
               "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
           .toString();
   for (Document element : documentServiceClient.listDocuments(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The parent branch resource name, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}. Use default_branch as the branch ID, to list documents under the default branch.

If the caller does not have permission to list Documents under this branch, regardless of whether or not this branch exists, a PERMISSION_DENIED error is returned.

Returns
Type Description
DocumentServiceClient.ListDocumentsPagedResponse

listDocumentsCallable()

public final UnaryCallable<ListDocumentsRequest,ListDocumentsResponse> listDocumentsCallable()

Gets a list of Documents.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   ListDocumentsRequest request =
       ListDocumentsRequest.newBuilder()
           .setParent(
               BranchName.ofProjectLocationDataStoreBranchName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
                   .toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListDocumentsResponse response =
         documentServiceClient.listDocumentsCallable().call(request);
     for (Document element : response.getDocumentsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListDocumentsRequest,ListDocumentsResponse>

listDocumentsPagedCallable()

public final UnaryCallable<ListDocumentsRequest,DocumentServiceClient.ListDocumentsPagedResponse> listDocumentsPagedCallable()

Gets a list of Documents.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   ListDocumentsRequest request =
       ListDocumentsRequest.newBuilder()
           .setParent(
               BranchName.ofProjectLocationDataStoreBranchName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
                   .toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Document> future =
       documentServiceClient.listDocumentsPagedCallable().futureCall(request);
   // Do something.
   for (Document element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListDocumentsRequest,ListDocumentsPagedResponse>

purgeDocumentsAsync(PurgeDocumentsRequest request)

public final OperationFuture<PurgeDocumentsResponse,PurgeDocumentsMetadata> purgeDocumentsAsync(PurgeDocumentsRequest request)

Permanently deletes all selected Documents in a branch.

This process is asynchronous. Depending on the number of Documents to be deleted, this operation can take hours to complete. Before the delete operation completes, some Documents might still be returned by DocumentService.GetDocument or DocumentService.ListDocuments.

To get a list of the Documents to be deleted, set PurgeDocumentsRequest.force to false.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   PurgeDocumentsRequest request =
       PurgeDocumentsRequest.newBuilder()
           .setParent(
               BranchName.ofProjectLocationDataStoreBranchName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
                   .toString())
           .setFilter("filter-1274492040")
           .setErrorConfig(PurgeErrorConfig.newBuilder().build())
           .setForce(true)
           .build();
   PurgeDocumentsResponse response = documentServiceClient.purgeDocumentsAsync(request).get();
 }
 
Parameter
Name Description
request PurgeDocumentsRequest

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

Returns
Type Description
OperationFuture<PurgeDocumentsResponse,PurgeDocumentsMetadata>

purgeDocumentsCallable()

public final UnaryCallable<PurgeDocumentsRequest,Operation> purgeDocumentsCallable()

Permanently deletes all selected Documents in a branch.

This process is asynchronous. Depending on the number of Documents to be deleted, this operation can take hours to complete. Before the delete operation completes, some Documents might still be returned by DocumentService.GetDocument or DocumentService.ListDocuments.

To get a list of the Documents to be deleted, set PurgeDocumentsRequest.force to false.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   PurgeDocumentsRequest request =
       PurgeDocumentsRequest.newBuilder()
           .setParent(
               BranchName.ofProjectLocationDataStoreBranchName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
                   .toString())
           .setFilter("filter-1274492040")
           .setErrorConfig(PurgeErrorConfig.newBuilder().build())
           .setForce(true)
           .build();
   ApiFuture<Operation> future =
       documentServiceClient.purgeDocumentsCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<PurgeDocumentsRequest,Operation>

purgeDocumentsOperationCallable()

public final OperationCallable<PurgeDocumentsRequest,PurgeDocumentsResponse,PurgeDocumentsMetadata> purgeDocumentsOperationCallable()

Permanently deletes all selected Documents in a branch.

This process is asynchronous. Depending on the number of Documents to be deleted, this operation can take hours to complete. Before the delete operation completes, some Documents might still be returned by DocumentService.GetDocument or DocumentService.ListDocuments.

To get a list of the Documents to be deleted, set PurgeDocumentsRequest.force to false.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   PurgeDocumentsRequest request =
       PurgeDocumentsRequest.newBuilder()
           .setParent(
               BranchName.ofProjectLocationDataStoreBranchName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
                   .toString())
           .setFilter("filter-1274492040")
           .setErrorConfig(PurgeErrorConfig.newBuilder().build())
           .setForce(true)
           .build();
   OperationFuture<PurgeDocumentsResponse, PurgeDocumentsMetadata> future =
       documentServiceClient.purgeDocumentsOperationCallable().futureCall(request);
   // Do something.
   PurgeDocumentsResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<PurgeDocumentsRequest,PurgeDocumentsResponse,PurgeDocumentsMetadata>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateDocument(Document document, FieldMask updateMask)

public final Document updateDocument(Document document, FieldMask updateMask)

Updates a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   Document document = Document.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Document response = documentServiceClient.updateDocument(document, updateMask);
 }
 
Parameters
Name Description
document Document

Required. The document to update/create.

If the caller does not have permission to update the Document, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.

If the Document to update does not exist and allow_missing is not set, a NOT_FOUND error is returned.

updateMask FieldMask

Indicates which fields in the provided imported 'document' to update. If not set, will by default update all fields.

Returns
Type Description
Document

updateDocument(UpdateDocumentRequest request)

public final Document updateDocument(UpdateDocumentRequest request)

Updates a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   UpdateDocumentRequest request =
       UpdateDocumentRequest.newBuilder()
           .setDocument(Document.newBuilder().build())
           .setAllowMissing(true)
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Document response = documentServiceClient.updateDocument(request);
 }
 
Parameter
Name Description
request UpdateDocumentRequest

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

Returns
Type Description
Document

updateDocumentCallable()

public final UnaryCallable<UpdateDocumentRequest,Document> updateDocumentCallable()

Updates a Document.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
   UpdateDocumentRequest request =
       UpdateDocumentRequest.newBuilder()
           .setDocument(Document.newBuilder().build())
           .setAllowMissing(true)
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Document> future =
       documentServiceClient.updateDocumentCallable().futureCall(request);
   // Do something.
   Document response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateDocumentRequest,Document>