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: Service for ingesting [Document][google.cloud.discoveryengine.v1.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().

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

        public final com.google.longrunning.OperationsClient getOperationsClient()
        Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
      • getHttpJsonOperationsClient

        @BetaApi
        public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
        Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
      • getDocument

        public final Document getDocument​(DocumentName name)
        Gets a [Document][google.cloud.discoveryengine.v1.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);
         }
         
        Parameters:
        name - Required. Full resource name of [Document][google.cloud.discoveryengine.v1.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][google.cloud.discoveryengine.v1.Document], regardless of whether or not it exists, a `PERMISSION_DENIED` error is returned.

        If the requested [Document][google.cloud.discoveryengine.v1.Document] does not exist, a `NOT_FOUND` error is returned.

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

        public final Document getDocument​(String name)
        Gets a [Document][google.cloud.discoveryengine.v1.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);
         }
         
        Parameters:
        name - Required. Full resource name of [Document][google.cloud.discoveryengine.v1.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][google.cloud.discoveryengine.v1.Document], regardless of whether or not it exists, a `PERMISSION_DENIED` error is returned.

        If the requested [Document][google.cloud.discoveryengine.v1.Document] does not exist, a `NOT_FOUND` error is returned.

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

        public final Document getDocument​(GetDocumentRequest request)
        Gets a [Document][google.cloud.discoveryengine.v1.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);
         }
         
        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][google.cloud.discoveryengine.v1.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();
         }
         
      • listDocuments

        public final DocumentServiceClient.ListDocumentsPagedResponse listDocuments​(BranchName parent)
        Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s.

        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);
           }
         }
         
        Parameters:
        parent - 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 [Document][google.cloud.discoveryengine.v1.Document]s under this branch, regardless of whether or not this branch exists, a `PERMISSION_DENIED` error is returned.

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

        public final DocumentServiceClient.ListDocumentsPagedResponse listDocuments​(String parent)
        Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s.

        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);
           }
         }
         
        Parameters:
        parent - 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 [Document][google.cloud.discoveryengine.v1.Document]s under this branch, regardless of whether or not this branch exists, a `PERMISSION_DENIED` error is returned.

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

        public final DocumentServiceClient.ListDocumentsPagedResponse listDocuments​(ListDocumentsRequest request)
        Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s.

        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);
           }
         }
         
        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
      • listDocumentsPagedCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListDocumentsRequest,​DocumentServiceClient.ListDocumentsPagedResponse> listDocumentsPagedCallable()
        Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s.

        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);
           }
         }
         
      • listDocumentsCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListDocumentsRequest,​ListDocumentsResponse> listDocumentsCallable()
        Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s.

        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;
             }
           }
         }
         
      • createDocument

        public final Document createDocument​(BranchName parent,
                                             Document document,
                                             String documentId)
        Creates a [Document][google.cloud.discoveryengine.v1.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:
        parent - Required. The parent resource name, such as `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
        document - Required. The [Document][google.cloud.discoveryengine.v1.Document] to create.
        documentId - Required. The ID to use for the [Document][google.cloud.discoveryengine.v1.Document], which will become the final component of the [Document.name][google.cloud.discoveryengine.v1.Document.name].

        If the caller does not have permission to create the [Document][google.cloud.discoveryengine.v1.Document], regardless of whether or not it exists, a `PERMISSION_DENIED` error is returned.

        This field must be unique among all [Document][google.cloud.discoveryengine.v1.Document]s with the same [parent][google.cloud.discoveryengine.v1.CreateDocumentRequest.parent]. Otherwise, an `ALREADY_EXISTS` error is returned.

        This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length limit of 63 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.

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

        public final Document createDocument​(String parent,
                                             Document document,
                                             String documentId)
        Creates a [Document][google.cloud.discoveryengine.v1.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:
        parent - Required. The parent resource name, such as `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
        document - Required. The [Document][google.cloud.discoveryengine.v1.Document] to create.
        documentId - Required. The ID to use for the [Document][google.cloud.discoveryengine.v1.Document], which will become the final component of the [Document.name][google.cloud.discoveryengine.v1.Document.name].

        If the caller does not have permission to create the [Document][google.cloud.discoveryengine.v1.Document], regardless of whether or not it exists, a `PERMISSION_DENIED` error is returned.

        This field must be unique among all [Document][google.cloud.discoveryengine.v1.Document]s with the same [parent][google.cloud.discoveryengine.v1.CreateDocumentRequest.parent]. Otherwise, an `ALREADY_EXISTS` error is returned.

        This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length limit of 63 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.

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

        public final Document createDocument​(CreateDocumentRequest request)
        Creates a [Document][google.cloud.discoveryengine.v1.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);
         }
         
        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,​Document> createDocumentCallable()
        Creates a [Document][google.cloud.discoveryengine.v1.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();
         }
         
      • updateDocument

        public final Document updateDocument​(UpdateDocumentRequest request)
        Updates a [Document][google.cloud.discoveryengine.v1.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)
                   .build();
           Document 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,​Document> updateDocumentCallable()
        Updates a [Document][google.cloud.discoveryengine.v1.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)
                   .build();
           ApiFuture<Document> future =
               documentServiceClient.updateDocumentCallable().futureCall(request);
           // Do something.
           Document response = future.get();
         }
         
      • deleteDocument

        public final void deleteDocument​(DocumentName name)
        Deletes a [Document][google.cloud.discoveryengine.v1.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);
         }
         
        Parameters:
        name - Required. Full resource name of [Document][google.cloud.discoveryengine.v1.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][google.cloud.discoveryengine.v1.Document], regardless of whether or not it exists, a `PERMISSION_DENIED` error is returned.

        If the [Document][google.cloud.discoveryengine.v1.Document] to delete does not exist, a `NOT_FOUND` error is returned.

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

        public final void deleteDocument​(String name)
        Deletes a [Document][google.cloud.discoveryengine.v1.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);
         }
         
        Parameters:
        name - Required. Full resource name of [Document][google.cloud.discoveryengine.v1.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][google.cloud.discoveryengine.v1.Document], regardless of whether or not it exists, a `PERMISSION_DENIED` error is returned.

        If the [Document][google.cloud.discoveryengine.v1.Document] to delete does not exist, a `NOT_FOUND` error is returned.

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

        public final void deleteDocument​(DeleteDocumentRequest request)
        Deletes a [Document][google.cloud.discoveryengine.v1.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);
         }
         
        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][google.cloud.discoveryengine.v1.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();
         }
         
      • importDocumentsAsync

        public final com.google.api.gax.longrunning.OperationFuture<ImportDocumentsResponse,​ImportDocumentsMetadata> importDocumentsAsync​(ImportDocumentsRequest request)
        Bulk import of multiple [Document][google.cloud.discoveryengine.v1.Document]s. Request processing may be synchronous. Non-existing items will be created.

        Note: It is possible for a subset of the [Document][google.cloud.discoveryengine.v1.Document]s 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())
                   .setAutoGenerateIds(true)
                   .setIdField("idField1629396127")
                   .build();
           ImportDocumentsResponse response = documentServiceClient.importDocumentsAsync(request).get();
         }
         
        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
      • importDocumentsOperationCallable

        public final com.google.api.gax.rpc.OperationCallable<ImportDocumentsRequest,​ImportDocumentsResponse,​ImportDocumentsMetadata> importDocumentsOperationCallable()
        Bulk import of multiple [Document][google.cloud.discoveryengine.v1.Document]s. Request processing may be synchronous. Non-existing items will be created.

        Note: It is possible for a subset of the [Document][google.cloud.discoveryengine.v1.Document]s 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())
                   .setAutoGenerateIds(true)
                   .setIdField("idField1629396127")
                   .build();
           OperationFuture<ImportDocumentsResponse, ImportDocumentsMetadata> future =
               documentServiceClient.importDocumentsOperationCallable().futureCall(request);
           // Do something.
           ImportDocumentsResponse response = future.get();
         }
         
      • importDocumentsCallable

        public final com.google.api.gax.rpc.UnaryCallable<ImportDocumentsRequest,​com.google.longrunning.Operation> importDocumentsCallable()
        Bulk import of multiple [Document][google.cloud.discoveryengine.v1.Document]s. Request processing may be synchronous. Non-existing items will be created.

        Note: It is possible for a subset of the [Document][google.cloud.discoveryengine.v1.Document]s 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())
                   .setAutoGenerateIds(true)
                   .setIdField("idField1629396127")
                   .build();
           ApiFuture<Operation> future =
               documentServiceClient.importDocumentsCallable().futureCall(request);
           // Do something.
           Operation response = future.get();
         }
         
      • purgeDocumentsAsync

        public final com.google.api.gax.longrunning.OperationFuture<PurgeDocumentsResponse,​PurgeDocumentsMetadata> purgeDocumentsAsync​(PurgeDocumentsRequest request)
        Permanently deletes all selected [Document][google.cloud.discoveryengine.v1.Document]s in a branch.

        This process is asynchronous. Depending on the number of [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, this operation can take hours to complete. Before the delete operation completes, some [Document][google.cloud.discoveryengine.v1.Document]s might still be returned by [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument] or [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments].

        To get a list of the [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, set [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1.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")
                   .setForce(true)
                   .build();
           PurgeDocumentsResponse response = documentServiceClient.purgeDocumentsAsync(request).get();
         }
         
        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
      • purgeDocumentsOperationCallable

        public final com.google.api.gax.rpc.OperationCallable<PurgeDocumentsRequest,​PurgeDocumentsResponse,​PurgeDocumentsMetadata> purgeDocumentsOperationCallable()
        Permanently deletes all selected [Document][google.cloud.discoveryengine.v1.Document]s in a branch.

        This process is asynchronous. Depending on the number of [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, this operation can take hours to complete. Before the delete operation completes, some [Document][google.cloud.discoveryengine.v1.Document]s might still be returned by [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument] or [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments].

        To get a list of the [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, set [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1.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")
                   .setForce(true)
                   .build();
           OperationFuture<PurgeDocumentsResponse, PurgeDocumentsMetadata> future =
               documentServiceClient.purgeDocumentsOperationCallable().futureCall(request);
           // Do something.
           PurgeDocumentsResponse response = future.get();
         }
         
      • purgeDocumentsCallable

        public final com.google.api.gax.rpc.UnaryCallable<PurgeDocumentsRequest,​com.google.longrunning.Operation> purgeDocumentsCallable()
        Permanently deletes all selected [Document][google.cloud.discoveryengine.v1.Document]s in a branch.

        This process is asynchronous. Depending on the number of [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, this operation can take hours to complete. Before the delete operation completes, some [Document][google.cloud.discoveryengine.v1.Document]s might still be returned by [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument] or [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments].

        To get a list of the [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, set [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1.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")
                   .setForce(true)
                   .build();
           ApiFuture<Operation> future =
               documentServiceClient.purgeDocumentsCallable().futureCall(request);
           // Do something.
           Operation 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