Class DocumentServiceClient

  • All Implemented Interfaces:
    com.google.api.gax.core.BackgroundResource, AutoCloseable

    @Generated("by gapic-generator-java")
    public class DocumentServiceClient
    extends Object
    implements com.google.api.gax.core.BackgroundResource
    Service Description: This service lets you manage document.

    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()) {
       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
       Document document = Document.newBuilder().build();
       CreateDocumentResponse response = documentServiceClient.createDocument(parent, document);
     }
     

    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().

    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 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.

    • Constructor Detail

      • DocumentServiceClient

        protected DocumentServiceClient​(DocumentServiceSettings settings)
                                 throws IOException
        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.
        Throws:
        IOException
    • Method Detail

      • create

        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).
      • createDocument

        public final CreateDocumentResponse createDocument​(LocationName parent,
                                                           Document document)
        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()) {
           LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
           Document document = Document.newBuilder().build();
           CreateDocumentResponse response = documentServiceClient.createDocument(parent, document);
         }
         
        Parameters:
        parent - Required. The parent name. Format: projects/{project_number}/locations/{location}.
        document - Required. The document to create.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • createDocument

        public final CreateDocumentResponse createDocument​(String parent,
                                                           Document document)
        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 = LocationName.of("[PROJECT]", "[LOCATION]").toString();
           Document document = Document.newBuilder().build();
           CreateDocumentResponse response = documentServiceClient.createDocument(parent, document);
         }
         
        Parameters:
        parent - Required. The parent name. Format: projects/{project_number}/locations/{location}.
        document - Required. The document to create.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • createDocument

        public final CreateDocumentResponse 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(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                   .setDocument(Document.newBuilder().build())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .setPolicy(Policy.newBuilder().build())
                   .setCloudAiDocumentOption(CloudAIDocumentOption.newBuilder().build())
                   .setCreateMask(FieldMask.newBuilder().build())
                   .build();
           CreateDocumentResponse response = documentServiceClient.createDocument(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • createDocumentCallable

        public final com.google.api.gax.rpc.UnaryCallable<CreateDocumentRequest,​CreateDocumentResponse> 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(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                   .setDocument(Document.newBuilder().build())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .setPolicy(Policy.newBuilder().build())
                   .setCloudAiDocumentOption(CloudAIDocumentOption.newBuilder().build())
                   .setCreateMask(FieldMask.newBuilder().build())
                   .build();
           ApiFuture<CreateDocumentResponse> future =
               documentServiceClient.createDocumentCallable().futureCall(request);
           // Do something.
           CreateDocumentResponse response = future.get();
         }
         
      • getDocument

        public final Document getDocument​(DocumentName name)
        Gets a document. Returns NOT_FOUND if the document does not exist.

        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.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]");
           Document response = documentServiceClient.getDocument(name);
         }
         
        Parameters:
        name - Required. The name of the document to retrieve. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getDocument

        public final Document getDocument​(String name)
        Gets a document. Returns NOT_FOUND if the document does not exist.

        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.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                   .toString();
           Document response = documentServiceClient.getDocument(name);
         }
         
        Parameters:
        name - Required. The name of the document to retrieve. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getDocument

        public final Document getDocument​(GetDocumentRequest request)
        Gets a document. Returns NOT_FOUND if the document does not exist.

        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.ofProjectLocationDocumentName(
                               "[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                           .toString())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .build();
           Document response = documentServiceClient.getDocument(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getDocumentCallable

        public final com.google.api.gax.rpc.UnaryCallable<GetDocumentRequest,​Document> getDocumentCallable()
        Gets a document. Returns NOT_FOUND if the document does not exist.

        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.ofProjectLocationDocumentName(
                               "[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                           .toString())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .build();
           ApiFuture<Document> future = documentServiceClient.getDocumentCallable().futureCall(request);
           // Do something.
           Document response = future.get();
         }
         
      • updateDocument

        public final UpdateDocumentResponse updateDocument​(DocumentName name,
                                                           Document document)
        Updates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing name.

        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.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]");
           Document document = Document.newBuilder().build();
           UpdateDocumentResponse response = documentServiceClient.updateDocument(name, document);
         }
         
        Parameters:
        name - Required. The name of the document to update. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}.
        document - Required. The document to update.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • updateDocument

        public final UpdateDocumentResponse updateDocument​(String name,
                                                           Document document)
        Updates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing name.

        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.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                   .toString();
           Document document = Document.newBuilder().build();
           UpdateDocumentResponse response = documentServiceClient.updateDocument(name, document);
         }
         
        Parameters:
        name - Required. The name of the document to update. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}.
        document - Required. The document to update.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • updateDocument

        public final UpdateDocumentResponse updateDocument​(UpdateDocumentRequest request)
        Updates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing name.

        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()
                   .setName(
                       DocumentName.ofProjectLocationDocumentName(
                               "[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                           .toString())
                   .setDocument(Document.newBuilder().build())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .setCloudAiDocumentOption(CloudAIDocumentOption.newBuilder().build())
                   .setUpdateOptions(UpdateOptions.newBuilder().build())
                   .build();
           UpdateDocumentResponse response = documentServiceClient.updateDocument(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • updateDocumentCallable

        public final com.google.api.gax.rpc.UnaryCallable<UpdateDocumentRequest,​UpdateDocumentResponse> updateDocumentCallable()
        Updates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing name.

        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()
                   .setName(
                       DocumentName.ofProjectLocationDocumentName(
                               "[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                           .toString())
                   .setDocument(Document.newBuilder().build())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .setCloudAiDocumentOption(CloudAIDocumentOption.newBuilder().build())
                   .setUpdateOptions(UpdateOptions.newBuilder().build())
                   .build();
           ApiFuture<UpdateDocumentResponse> future =
               documentServiceClient.updateDocumentCallable().futureCall(request);
           // Do something.
           UpdateDocumentResponse response = future.get();
         }
         
      • deleteDocument

        public final void deleteDocument​(DocumentName name)
        Deletes a document. Returns NOT_FOUND if the document does not exist.

        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.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]");
           documentServiceClient.deleteDocument(name);
         }
         
        Parameters:
        name - Required. The name of the document to delete. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • deleteDocument

        public final void deleteDocument​(String name)
        Deletes a document. Returns NOT_FOUND if the document does not exist.

        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.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                   .toString();
           documentServiceClient.deleteDocument(name);
         }
         
        Parameters:
        name - Required. The name of the document to delete. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • deleteDocument

        public final void deleteDocument​(DeleteDocumentRequest request)
        Deletes a document. Returns NOT_FOUND if the document does not exist.

        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.ofProjectLocationDocumentName(
                               "[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                           .toString())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .build();
           documentServiceClient.deleteDocument(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • deleteDocumentCallable

        public final com.google.api.gax.rpc.UnaryCallable<DeleteDocumentRequest,​com.google.protobuf.Empty> deleteDocumentCallable()
        Deletes a document. Returns NOT_FOUND if the document does not exist.

        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.ofProjectLocationDocumentName(
                               "[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                           .toString())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .build();
           ApiFuture<Empty> future = documentServiceClient.deleteDocumentCallable().futureCall(request);
           // Do something.
           future.get();
         }
         
      • searchDocuments

        public final DocumentServiceClient.SearchDocumentsPagedResponse searchDocuments​(LocationName parent)
        Searches for documents using provided [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. This call only returns documents that the caller has permission to search against.

        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()) {
           LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
           for (SearchDocumentsResponse.MatchingDocument element :
               documentServiceClient.searchDocuments(parent).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        parent - Required. The parent, which owns this collection of documents. Format: projects/{project_number}/locations/{location}.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • searchDocuments

        public final DocumentServiceClient.SearchDocumentsPagedResponse searchDocuments​(String parent)
        Searches for documents using provided [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. This call only returns documents that the caller has permission to search against.

        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 = LocationName.of("[PROJECT]", "[LOCATION]").toString();
           for (SearchDocumentsResponse.MatchingDocument element :
               documentServiceClient.searchDocuments(parent).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        parent - Required. The parent, which owns this collection of documents. Format: projects/{project_number}/locations/{location}.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • searchDocuments

        public final DocumentServiceClient.SearchDocumentsPagedResponse searchDocuments​(SearchDocumentsRequest request)
        Searches for documents using provided [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. This call only returns documents that the caller has permission to search against.

        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()) {
           SearchDocumentsRequest request =
               SearchDocumentsRequest.newBuilder()
                   .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .setDocumentQuery(DocumentQuery.newBuilder().build())
                   .setOffset(-1019779949)
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .setOrderBy("orderBy-1207110587")
                   .addAllHistogramQueries(new ArrayList<HistogramQuery>())
                   .setRequireTotalSize(true)
                   .setQaSizeLimit(142059404)
                   .build();
           for (SearchDocumentsResponse.MatchingDocument element :
               documentServiceClient.searchDocuments(request).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • searchDocumentsPagedCallable

        public final com.google.api.gax.rpc.UnaryCallable<SearchDocumentsRequest,​DocumentServiceClient.SearchDocumentsPagedResponse> searchDocumentsPagedCallable()
        Searches for documents using provided [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. This call only returns documents that the caller has permission to search against.

        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()) {
           SearchDocumentsRequest request =
               SearchDocumentsRequest.newBuilder()
                   .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .setDocumentQuery(DocumentQuery.newBuilder().build())
                   .setOffset(-1019779949)
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .setOrderBy("orderBy-1207110587")
                   .addAllHistogramQueries(new ArrayList<HistogramQuery>())
                   .setRequireTotalSize(true)
                   .setQaSizeLimit(142059404)
                   .build();
           ApiFuture<SearchDocumentsResponse.MatchingDocument> future =
               documentServiceClient.searchDocumentsPagedCallable().futureCall(request);
           // Do something.
           for (SearchDocumentsResponse.MatchingDocument element : future.get().iterateAll()) {
             // doThingsWith(element);
           }
         }
         
      • searchDocumentsCallable

        public final com.google.api.gax.rpc.UnaryCallable<SearchDocumentsRequest,​SearchDocumentsResponse> searchDocumentsCallable()
        Searches for documents using provided [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. This call only returns documents that the caller has permission to search against.

        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()) {
           SearchDocumentsRequest request =
               SearchDocumentsRequest.newBuilder()
                   .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .setDocumentQuery(DocumentQuery.newBuilder().build())
                   .setOffset(-1019779949)
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .setOrderBy("orderBy-1207110587")
                   .addAllHistogramQueries(new ArrayList<HistogramQuery>())
                   .setRequireTotalSize(true)
                   .setQaSizeLimit(142059404)
                   .build();
           while (true) {
             SearchDocumentsResponse response =
                 documentServiceClient.searchDocumentsCallable().call(request);
             for (SearchDocumentsResponse.MatchingDocument element :
                 response.getMatchingDocumentsList()) {
               // doThingsWith(element);
             }
             String nextPageToken = response.getNextPageToken();
             if (!Strings.isNullOrEmpty(nextPageToken)) {
               request = request.toBuilder().setPageToken(nextPageToken).build();
             } else {
               break;
             }
           }
         }
         
      • lockDocument

        public final Document lockDocument​(DocumentName name)
        Lock the document so the document cannot be updated by other users.

        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.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]");
           Document response = documentServiceClient.lockDocument(name);
         }
         
        Parameters:
        name - Required. The name of the document to lock. Format: projects/{project_number}/locations/{location}/documents/{document}.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • lockDocument

        public final Document lockDocument​(String name)
        Lock the document so the document cannot be updated by other users.

        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.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                   .toString();
           Document response = documentServiceClient.lockDocument(name);
         }
         
        Parameters:
        name - Required. The name of the document to lock. Format: projects/{project_number}/locations/{location}/documents/{document}.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • lockDocument

        public final Document lockDocument​(LockDocumentRequest request)
        Lock the document so the document cannot be updated by other users.

        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()) {
           LockDocumentRequest request =
               LockDocumentRequest.newBuilder()
                   .setName(
                       DocumentName.ofProjectLocationDocumentName(
                               "[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                           .toString())
                   .setCollectionId("collectionId1636075609")
                   .setLockingUser(UserInfo.newBuilder().build())
                   .build();
           Document response = documentServiceClient.lockDocument(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • lockDocumentCallable

        public final com.google.api.gax.rpc.UnaryCallable<LockDocumentRequest,​Document> lockDocumentCallable()
        Lock the document so the document cannot be updated by other users.

        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()) {
           LockDocumentRequest request =
               LockDocumentRequest.newBuilder()
                   .setName(
                       DocumentName.ofProjectLocationDocumentName(
                               "[PROJECT]", "[LOCATION]", "[DOCUMENT]")
                           .toString())
                   .setCollectionId("collectionId1636075609")
                   .setLockingUser(UserInfo.newBuilder().build())
                   .build();
           ApiFuture<Document> future = documentServiceClient.lockDocumentCallable().futureCall(request);
           // Do something.
           Document response = future.get();
         }
         
      • fetchAcl

        public final FetchAclResponse fetchAcl​(String resource)
        Gets the access control policy for a resource. Returns NOT_FOUND error if the resource does not exist. Returns an empty policy if the resource exists but does not have a policy set.

        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 resource = "resource-341064690";
           FetchAclResponse response = documentServiceClient.fetchAcl(resource);
         }
         
        Parameters:
        resource - Required. REQUIRED: The resource for which the policy is being requested. Format for document: projects/{project_number}/locations/{location}/documents/{document_id}. Format for collection: projects/{project_number}/locations/{location}/collections/{collection_id}. Format for project: projects/{project_number}.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • fetchAcl

        public final FetchAclResponse fetchAcl​(FetchAclRequest request)
        Gets the access control policy for a resource. Returns NOT_FOUND error if the resource does not exist. Returns an empty policy if the resource exists but does not have a policy set.

        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()) {
           FetchAclRequest request =
               FetchAclRequest.newBuilder()
                   .setResource("resource-341064690")
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .setProjectOwner(true)
                   .build();
           FetchAclResponse response = documentServiceClient.fetchAcl(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • fetchAclCallable

        public final com.google.api.gax.rpc.UnaryCallable<FetchAclRequest,​FetchAclResponse> fetchAclCallable()
        Gets the access control policy for a resource. Returns NOT_FOUND error if the resource does not exist. Returns an empty policy if the resource exists but does not have a policy set.

        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()) {
           FetchAclRequest request =
               FetchAclRequest.newBuilder()
                   .setResource("resource-341064690")
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .setProjectOwner(true)
                   .build();
           ApiFuture<FetchAclResponse> future =
               documentServiceClient.fetchAclCallable().futureCall(request);
           // Do something.
           FetchAclResponse response = future.get();
         }
         
      • setAcl

        public final SetAclResponse setAcl​(String resource,
                                           com.google.iam.v1.Policy policy)
        Sets the access control policy for a resource. Replaces any existing policy.

        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 resource = "resource-341064690";
           Policy policy = Policy.newBuilder().build();
           SetAclResponse response = documentServiceClient.setAcl(resource, policy);
         }
         
        Parameters:
        resource - Required. REQUIRED: The resource for which the policy is being requested. Format for document: projects/{project_number}/locations/{location}/documents/{document_id}. Format for collection: projects/{project_number}/locations/{location}/collections/{collection_id}. Format for project: projects/{project_number}.
        policy - Required. REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. This refers to an Identity and Access (IAM) policy, which specifies access controls for the Document.

        You can set ACL with condition for projects only.

        Supported operators are: `=`, `!=`, `<`, `<=`, `>`, and `>=` where the left of the operator is `DocumentSchemaId` or property name and the right of the operator is a number or a quoted string. You must escape backslash (\\\\) and quote (\\") characters.

        Boolean expressions (AND/OR) are supported up to 3 levels of nesting (for example, "((A AND B AND C) OR D) AND E"), a maximum of 10 comparisons are allowed in the expression. The expression must be < 6000 bytes in length.

        Sample condition: `"DocumentSchemaId = \\"some schema id\\" OR SchemaId.floatPropertyName >= 10"`

        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • setAcl

        public final SetAclResponse setAcl​(SetAclRequest request)
        Sets the access control policy for a resource. Replaces any existing policy.

        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()) {
           SetAclRequest request =
               SetAclRequest.newBuilder()
                   .setResource("resource-341064690")
                   .setPolicy(Policy.newBuilder().build())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .setProjectOwner(true)
                   .build();
           SetAclResponse response = documentServiceClient.setAcl(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • setAclCallable

        public final com.google.api.gax.rpc.UnaryCallable<SetAclRequest,​SetAclResponse> setAclCallable()
        Sets the access control policy for a resource. Replaces any existing policy.

        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()) {
           SetAclRequest request =
               SetAclRequest.newBuilder()
                   .setResource("resource-341064690")
                   .setPolicy(Policy.newBuilder().build())
                   .setRequestMetadata(RequestMetadata.newBuilder().build())
                   .setProjectOwner(true)
                   .build();
           ApiFuture<SetAclResponse> future = documentServiceClient.setAclCallable().futureCall(request);
           // Do something.
           SetAclResponse response = future.get();
         }
         
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in interface com.google.api.gax.core.BackgroundResource
      • isShutdown

        public boolean isShutdown()
        Specified by:
        isShutdown in interface com.google.api.gax.core.BackgroundResource
      • isTerminated

        public boolean isTerminated()
        Specified by:
        isTerminated in interface com.google.api.gax.core.BackgroundResource
      • shutdownNow

        public void shutdownNow()
        Specified by:
        shutdownNow in interface com.google.api.gax.core.BackgroundResource