• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.cloud.discoveryengine.v1beta;
18 
19 import com.google.api.core.ApiFuture;
20 import com.google.api.core.ApiFutures;
21 import com.google.api.core.BetaApi;
22 import com.google.api.gax.core.BackgroundResource;
23 import com.google.api.gax.httpjson.longrunning.OperationsClient;
24 import com.google.api.gax.longrunning.OperationFuture;
25 import com.google.api.gax.paging.AbstractFixedSizeCollection;
26 import com.google.api.gax.paging.AbstractPage;
27 import com.google.api.gax.paging.AbstractPagedListResponse;
28 import com.google.api.gax.rpc.OperationCallable;
29 import com.google.api.gax.rpc.PageContext;
30 import com.google.api.gax.rpc.UnaryCallable;
31 import com.google.cloud.discoveryengine.v1beta.stub.DocumentServiceStub;
32 import com.google.cloud.discoveryengine.v1beta.stub.DocumentServiceStubSettings;
33 import com.google.common.util.concurrent.MoreExecutors;
34 import com.google.longrunning.Operation;
35 import com.google.protobuf.Empty;
36 import java.io.IOException;
37 import java.util.List;
38 import java.util.concurrent.TimeUnit;
39 import javax.annotation.Generated;
40 
41 // AUTO-GENERATED DOCUMENTATION AND CLASS.
42 /**
43  * Service Description: Service for ingesting
44  * [Document][google.cloud.discoveryengine.v1beta.Document] information of the customer's website.
45  *
46  * <p>This class provides the ability to make remote calls to the backing service through method
47  * calls that map to API methods. Sample code to get started:
48  *
49  * <pre>{@code
50  * // This snippet has been automatically generated and should be regarded as a code template only.
51  * // It will require modifications to work:
52  * // - It may require correct/in-range values for request initialization.
53  * // - It may require specifying regional endpoints when creating the service client as shown in
54  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
55  * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
56  *   DocumentName name =
57  *       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
58  *           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]");
59  *   Document response = documentServiceClient.getDocument(name);
60  * }
61  * }</pre>
62  *
63  * <p>Note: close() needs to be called on the DocumentServiceClient object to clean up resources
64  * such as threads. In the example above, try-with-resources is used, which automatically calls
65  * close().
66  *
67  * <p>The surface of this class includes several types of Java methods for each of the API's
68  * methods:
69  *
70  * <ol>
71  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
72  *       converted into function parameters. It may be the case that not all fields are available as
73  *       parameters, and not every API method will have a flattened method entry point.
74  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
75  *       which must be constructed before the call. Not every API method will have a request object
76  *       method.
77  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
78  *       callable object, which can be used to initiate calls to the service.
79  * </ol>
80  *
81  * <p>See the individual methods for example code.
82  *
83  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
84  * these names, this class includes a format method for each type of name, and additionally a parse
85  * method to extract the individual identifiers contained within names that are returned.
86  *
87  * <p>This class can be customized by passing in a custom instance of DocumentServiceSettings to
88  * create(). For example:
89  *
90  * <p>To customize credentials:
91  *
92  * <pre>{@code
93  * // This snippet has been automatically generated and should be regarded as a code template only.
94  * // It will require modifications to work:
95  * // - It may require correct/in-range values for request initialization.
96  * // - It may require specifying regional endpoints when creating the service client as shown in
97  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
98  * DocumentServiceSettings documentServiceSettings =
99  *     DocumentServiceSettings.newBuilder()
100  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
101  *         .build();
102  * DocumentServiceClient documentServiceClient =
103  *     DocumentServiceClient.create(documentServiceSettings);
104  * }</pre>
105  *
106  * <p>To customize the endpoint:
107  *
108  * <pre>{@code
109  * // This snippet has been automatically generated and should be regarded as a code template only.
110  * // It will require modifications to work:
111  * // - It may require correct/in-range values for request initialization.
112  * // - It may require specifying regional endpoints when creating the service client as shown in
113  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
114  * DocumentServiceSettings documentServiceSettings =
115  *     DocumentServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
116  * DocumentServiceClient documentServiceClient =
117  *     DocumentServiceClient.create(documentServiceSettings);
118  * }</pre>
119  *
120  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
121  * the wire:
122  *
123  * <pre>{@code
124  * // This snippet has been automatically generated and should be regarded as a code template only.
125  * // It will require modifications to work:
126  * // - It may require correct/in-range values for request initialization.
127  * // - It may require specifying regional endpoints when creating the service client as shown in
128  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
129  * DocumentServiceSettings documentServiceSettings =
130  *     DocumentServiceSettings.newHttpJsonBuilder().build();
131  * DocumentServiceClient documentServiceClient =
132  *     DocumentServiceClient.create(documentServiceSettings);
133  * }</pre>
134  *
135  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
136  */
137 @BetaApi
138 @Generated("by gapic-generator-java")
139 public class DocumentServiceClient implements BackgroundResource {
140   private final DocumentServiceSettings settings;
141   private final DocumentServiceStub stub;
142   private final OperationsClient httpJsonOperationsClient;
143   private final com.google.longrunning.OperationsClient operationsClient;
144 
145   /** Constructs an instance of DocumentServiceClient with default settings. */
create()146   public static final DocumentServiceClient create() throws IOException {
147     return create(DocumentServiceSettings.newBuilder().build());
148   }
149 
150   /**
151    * Constructs an instance of DocumentServiceClient, using the given settings. The channels are
152    * created based on the settings passed in, or defaults for any settings that are not set.
153    */
create(DocumentServiceSettings settings)154   public static final DocumentServiceClient create(DocumentServiceSettings settings)
155       throws IOException {
156     return new DocumentServiceClient(settings);
157   }
158 
159   /**
160    * Constructs an instance of DocumentServiceClient, using the given stub for making calls. This is
161    * for advanced usage - prefer using create(DocumentServiceSettings).
162    */
create(DocumentServiceStub stub)163   public static final DocumentServiceClient create(DocumentServiceStub stub) {
164     return new DocumentServiceClient(stub);
165   }
166 
167   /**
168    * Constructs an instance of DocumentServiceClient, using the given settings. This is protected so
169    * that it is easy to make a subclass, but otherwise, the static factory methods should be
170    * preferred.
171    */
DocumentServiceClient(DocumentServiceSettings settings)172   protected DocumentServiceClient(DocumentServiceSettings settings) throws IOException {
173     this.settings = settings;
174     this.stub = ((DocumentServiceStubSettings) settings.getStubSettings()).createStub();
175     this.operationsClient =
176         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
177     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
178   }
179 
DocumentServiceClient(DocumentServiceStub stub)180   protected DocumentServiceClient(DocumentServiceStub stub) {
181     this.settings = null;
182     this.stub = stub;
183     this.operationsClient =
184         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
185     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
186   }
187 
getSettings()188   public final DocumentServiceSettings getSettings() {
189     return settings;
190   }
191 
getStub()192   public DocumentServiceStub getStub() {
193     return stub;
194   }
195 
196   /**
197    * Returns the OperationsClient that can be used to query the status of a long-running operation
198    * returned by another API method call.
199    */
getOperationsClient()200   public final com.google.longrunning.OperationsClient getOperationsClient() {
201     return operationsClient;
202   }
203 
204   /**
205    * Returns the OperationsClient that can be used to query the status of a long-running operation
206    * returned by another API method call.
207    */
208   @BetaApi
getHttpJsonOperationsClient()209   public final OperationsClient getHttpJsonOperationsClient() {
210     return httpJsonOperationsClient;
211   }
212 
213   // AUTO-GENERATED DOCUMENTATION AND METHOD.
214   /**
215    * Gets a [Document][google.cloud.discoveryengine.v1beta.Document].
216    *
217    * <p>Sample code:
218    *
219    * <pre>{@code
220    * // This snippet has been automatically generated and should be regarded as a code template only.
221    * // It will require modifications to work:
222    * // - It may require correct/in-range values for request initialization.
223    * // - It may require specifying regional endpoints when creating the service client as shown in
224    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
225    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
226    *   DocumentName name =
227    *       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
228    *           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]");
229    *   Document response = documentServiceClient.getDocument(name);
230    * }
231    * }</pre>
232    *
233    * @param name Required. Full resource name of
234    *     [Document][google.cloud.discoveryengine.v1beta.Document], such as
235    *     `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`.
236    *     <p>If the caller does not have permission to access the
237    *     [Document][google.cloud.discoveryengine.v1beta.Document], regardless of whether or not it
238    *     exists, a `PERMISSION_DENIED` error is returned.
239    *     <p>If the requested [Document][google.cloud.discoveryengine.v1beta.Document] does not
240    *     exist, a `NOT_FOUND` error is returned.
241    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
242    */
getDocument(DocumentName name)243   public final Document getDocument(DocumentName name) {
244     GetDocumentRequest request =
245         GetDocumentRequest.newBuilder().setName(name == null ? null : name.toString()).build();
246     return getDocument(request);
247   }
248 
249   // AUTO-GENERATED DOCUMENTATION AND METHOD.
250   /**
251    * Gets a [Document][google.cloud.discoveryengine.v1beta.Document].
252    *
253    * <p>Sample code:
254    *
255    * <pre>{@code
256    * // This snippet has been automatically generated and should be regarded as a code template only.
257    * // It will require modifications to work:
258    * // - It may require correct/in-range values for request initialization.
259    * // - It may require specifying regional endpoints when creating the service client as shown in
260    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
261    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
262    *   String name =
263    *       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
264    *               "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
265    *           .toString();
266    *   Document response = documentServiceClient.getDocument(name);
267    * }
268    * }</pre>
269    *
270    * @param name Required. Full resource name of
271    *     [Document][google.cloud.discoveryengine.v1beta.Document], such as
272    *     `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`.
273    *     <p>If the caller does not have permission to access the
274    *     [Document][google.cloud.discoveryengine.v1beta.Document], regardless of whether or not it
275    *     exists, a `PERMISSION_DENIED` error is returned.
276    *     <p>If the requested [Document][google.cloud.discoveryengine.v1beta.Document] does not
277    *     exist, a `NOT_FOUND` error is returned.
278    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
279    */
getDocument(String name)280   public final Document getDocument(String name) {
281     GetDocumentRequest request = GetDocumentRequest.newBuilder().setName(name).build();
282     return getDocument(request);
283   }
284 
285   // AUTO-GENERATED DOCUMENTATION AND METHOD.
286   /**
287    * Gets a [Document][google.cloud.discoveryengine.v1beta.Document].
288    *
289    * <p>Sample code:
290    *
291    * <pre>{@code
292    * // This snippet has been automatically generated and should be regarded as a code template only.
293    * // It will require modifications to work:
294    * // - It may require correct/in-range values for request initialization.
295    * // - It may require specifying regional endpoints when creating the service client as shown in
296    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
297    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
298    *   GetDocumentRequest request =
299    *       GetDocumentRequest.newBuilder()
300    *           .setName(
301    *               DocumentName.ofProjectLocationDataStoreBranchDocumentName(
302    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
303    *                   .toString())
304    *           .build();
305    *   Document response = documentServiceClient.getDocument(request);
306    * }
307    * }</pre>
308    *
309    * @param request The request object containing all of the parameters for the API call.
310    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
311    */
getDocument(GetDocumentRequest request)312   public final Document getDocument(GetDocumentRequest request) {
313     return getDocumentCallable().call(request);
314   }
315 
316   // AUTO-GENERATED DOCUMENTATION AND METHOD.
317   /**
318    * Gets a [Document][google.cloud.discoveryengine.v1beta.Document].
319    *
320    * <p>Sample code:
321    *
322    * <pre>{@code
323    * // This snippet has been automatically generated and should be regarded as a code template only.
324    * // It will require modifications to work:
325    * // - It may require correct/in-range values for request initialization.
326    * // - It may require specifying regional endpoints when creating the service client as shown in
327    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
328    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
329    *   GetDocumentRequest request =
330    *       GetDocumentRequest.newBuilder()
331    *           .setName(
332    *               DocumentName.ofProjectLocationDataStoreBranchDocumentName(
333    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
334    *                   .toString())
335    *           .build();
336    *   ApiFuture<Document> future = documentServiceClient.getDocumentCallable().futureCall(request);
337    *   // Do something.
338    *   Document response = future.get();
339    * }
340    * }</pre>
341    */
getDocumentCallable()342   public final UnaryCallable<GetDocumentRequest, Document> getDocumentCallable() {
343     return stub.getDocumentCallable();
344   }
345 
346   // AUTO-GENERATED DOCUMENTATION AND METHOD.
347   /**
348    * Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s.
349    *
350    * <p>Sample code:
351    *
352    * <pre>{@code
353    * // This snippet has been automatically generated and should be regarded as a code template only.
354    * // It will require modifications to work:
355    * // - It may require correct/in-range values for request initialization.
356    * // - It may require specifying regional endpoints when creating the service client as shown in
357    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
358    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
359    *   BranchName parent =
360    *       BranchName.ofProjectLocationDataStoreBranchName(
361    *           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]");
362    *   for (Document element : documentServiceClient.listDocuments(parent).iterateAll()) {
363    *     // doThingsWith(element);
364    *   }
365    * }
366    * }</pre>
367    *
368    * @param parent Required. The parent branch resource name, such as
369    *     `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
370    *     Use `default_branch` as the branch ID, to list documents under the default branch.
371    *     <p>If the caller does not have permission to list [Documents][]s under this branch,
372    *     regardless of whether or not this branch exists, a `PERMISSION_DENIED` error is returned.
373    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
374    */
listDocuments(BranchName parent)375   public final ListDocumentsPagedResponse listDocuments(BranchName parent) {
376     ListDocumentsRequest request =
377         ListDocumentsRequest.newBuilder()
378             .setParent(parent == null ? null : parent.toString())
379             .build();
380     return listDocuments(request);
381   }
382 
383   // AUTO-GENERATED DOCUMENTATION AND METHOD.
384   /**
385    * Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s.
386    *
387    * <p>Sample code:
388    *
389    * <pre>{@code
390    * // This snippet has been automatically generated and should be regarded as a code template only.
391    * // It will require modifications to work:
392    * // - It may require correct/in-range values for request initialization.
393    * // - It may require specifying regional endpoints when creating the service client as shown in
394    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
395    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
396    *   String parent =
397    *       BranchName.ofProjectLocationDataStoreBranchName(
398    *               "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
399    *           .toString();
400    *   for (Document element : documentServiceClient.listDocuments(parent).iterateAll()) {
401    *     // doThingsWith(element);
402    *   }
403    * }
404    * }</pre>
405    *
406    * @param parent Required. The parent branch resource name, such as
407    *     `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
408    *     Use `default_branch` as the branch ID, to list documents under the default branch.
409    *     <p>If the caller does not have permission to list [Documents][]s under this branch,
410    *     regardless of whether or not this branch exists, a `PERMISSION_DENIED` error is returned.
411    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
412    */
listDocuments(String parent)413   public final ListDocumentsPagedResponse listDocuments(String parent) {
414     ListDocumentsRequest request = ListDocumentsRequest.newBuilder().setParent(parent).build();
415     return listDocuments(request);
416   }
417 
418   // AUTO-GENERATED DOCUMENTATION AND METHOD.
419   /**
420    * Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s.
421    *
422    * <p>Sample code:
423    *
424    * <pre>{@code
425    * // This snippet has been automatically generated and should be regarded as a code template only.
426    * // It will require modifications to work:
427    * // - It may require correct/in-range values for request initialization.
428    * // - It may require specifying regional endpoints when creating the service client as shown in
429    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
430    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
431    *   ListDocumentsRequest request =
432    *       ListDocumentsRequest.newBuilder()
433    *           .setParent(
434    *               BranchName.ofProjectLocationDataStoreBranchName(
435    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
436    *                   .toString())
437    *           .setPageSize(883849137)
438    *           .setPageToken("pageToken873572522")
439    *           .build();
440    *   for (Document element : documentServiceClient.listDocuments(request).iterateAll()) {
441    *     // doThingsWith(element);
442    *   }
443    * }
444    * }</pre>
445    *
446    * @param request The request object containing all of the parameters for the API call.
447    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
448    */
listDocuments(ListDocumentsRequest request)449   public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest request) {
450     return listDocumentsPagedCallable().call(request);
451   }
452 
453   // AUTO-GENERATED DOCUMENTATION AND METHOD.
454   /**
455    * Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s.
456    *
457    * <p>Sample code:
458    *
459    * <pre>{@code
460    * // This snippet has been automatically generated and should be regarded as a code template only.
461    * // It will require modifications to work:
462    * // - It may require correct/in-range values for request initialization.
463    * // - It may require specifying regional endpoints when creating the service client as shown in
464    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
465    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
466    *   ListDocumentsRequest request =
467    *       ListDocumentsRequest.newBuilder()
468    *           .setParent(
469    *               BranchName.ofProjectLocationDataStoreBranchName(
470    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
471    *                   .toString())
472    *           .setPageSize(883849137)
473    *           .setPageToken("pageToken873572522")
474    *           .build();
475    *   ApiFuture<Document> future =
476    *       documentServiceClient.listDocumentsPagedCallable().futureCall(request);
477    *   // Do something.
478    *   for (Document element : future.get().iterateAll()) {
479    *     // doThingsWith(element);
480    *   }
481    * }
482    * }</pre>
483    */
484   public final UnaryCallable<ListDocumentsRequest, ListDocumentsPagedResponse>
listDocumentsPagedCallable()485       listDocumentsPagedCallable() {
486     return stub.listDocumentsPagedCallable();
487   }
488 
489   // AUTO-GENERATED DOCUMENTATION AND METHOD.
490   /**
491    * Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s.
492    *
493    * <p>Sample code:
494    *
495    * <pre>{@code
496    * // This snippet has been automatically generated and should be regarded as a code template only.
497    * // It will require modifications to work:
498    * // - It may require correct/in-range values for request initialization.
499    * // - It may require specifying regional endpoints when creating the service client as shown in
500    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
501    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
502    *   ListDocumentsRequest request =
503    *       ListDocumentsRequest.newBuilder()
504    *           .setParent(
505    *               BranchName.ofProjectLocationDataStoreBranchName(
506    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
507    *                   .toString())
508    *           .setPageSize(883849137)
509    *           .setPageToken("pageToken873572522")
510    *           .build();
511    *   while (true) {
512    *     ListDocumentsResponse response =
513    *         documentServiceClient.listDocumentsCallable().call(request);
514    *     for (Document element : response.getDocumentsList()) {
515    *       // doThingsWith(element);
516    *     }
517    *     String nextPageToken = response.getNextPageToken();
518    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
519    *       request = request.toBuilder().setPageToken(nextPageToken).build();
520    *     } else {
521    *       break;
522    *     }
523    *   }
524    * }
525    * }</pre>
526    */
listDocumentsCallable()527   public final UnaryCallable<ListDocumentsRequest, ListDocumentsResponse> listDocumentsCallable() {
528     return stub.listDocumentsCallable();
529   }
530 
531   // AUTO-GENERATED DOCUMENTATION AND METHOD.
532   /**
533    * Creates a [Document][google.cloud.discoveryengine.v1beta.Document].
534    *
535    * <p>Sample code:
536    *
537    * <pre>{@code
538    * // This snippet has been automatically generated and should be regarded as a code template only.
539    * // It will require modifications to work:
540    * // - It may require correct/in-range values for request initialization.
541    * // - It may require specifying regional endpoints when creating the service client as shown in
542    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
543    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
544    *   BranchName parent =
545    *       BranchName.ofProjectLocationDataStoreBranchName(
546    *           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]");
547    *   Document document = Document.newBuilder().build();
548    *   String documentId = "documentId-814940266";
549    *   Document response = documentServiceClient.createDocument(parent, document, documentId);
550    * }
551    * }</pre>
552    *
553    * @param parent Required. The parent resource name, such as
554    *     `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
555    * @param document Required. The [Document][google.cloud.discoveryengine.v1beta.Document] to
556    *     create.
557    * @param documentId Required. The ID to use for the
558    *     [Document][google.cloud.discoveryengine.v1beta.Document], which will become the final
559    *     component of the [Document.name][google.cloud.discoveryengine.v1beta.Document.name].
560    *     <p>If the caller does not have permission to create the
561    *     [Document][google.cloud.discoveryengine.v1beta.Document], regardless of whether or not it
562    *     exists, a `PERMISSION_DENIED` error is returned.
563    *     <p>This field must be unique among all
564    *     [Document][google.cloud.discoveryengine.v1beta.Document]s with the same
565    *     [parent][google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent]. Otherwise, an
566    *     `ALREADY_EXISTS` error is returned.
567    *     <p>This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with
568    *     a length limit of 63 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
569    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
570    */
createDocument(BranchName parent, Document document, String documentId)571   public final Document createDocument(BranchName parent, Document document, String documentId) {
572     CreateDocumentRequest request =
573         CreateDocumentRequest.newBuilder()
574             .setParent(parent == null ? null : parent.toString())
575             .setDocument(document)
576             .setDocumentId(documentId)
577             .build();
578     return createDocument(request);
579   }
580 
581   // AUTO-GENERATED DOCUMENTATION AND METHOD.
582   /**
583    * Creates a [Document][google.cloud.discoveryengine.v1beta.Document].
584    *
585    * <p>Sample code:
586    *
587    * <pre>{@code
588    * // This snippet has been automatically generated and should be regarded as a code template only.
589    * // It will require modifications to work:
590    * // - It may require correct/in-range values for request initialization.
591    * // - It may require specifying regional endpoints when creating the service client as shown in
592    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
593    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
594    *   String parent =
595    *       BranchName.ofProjectLocationDataStoreBranchName(
596    *               "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
597    *           .toString();
598    *   Document document = Document.newBuilder().build();
599    *   String documentId = "documentId-814940266";
600    *   Document response = documentServiceClient.createDocument(parent, document, documentId);
601    * }
602    * }</pre>
603    *
604    * @param parent Required. The parent resource name, such as
605    *     `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
606    * @param document Required. The [Document][google.cloud.discoveryengine.v1beta.Document] to
607    *     create.
608    * @param documentId Required. The ID to use for the
609    *     [Document][google.cloud.discoveryengine.v1beta.Document], which will become the final
610    *     component of the [Document.name][google.cloud.discoveryengine.v1beta.Document.name].
611    *     <p>If the caller does not have permission to create the
612    *     [Document][google.cloud.discoveryengine.v1beta.Document], regardless of whether or not it
613    *     exists, a `PERMISSION_DENIED` error is returned.
614    *     <p>This field must be unique among all
615    *     [Document][google.cloud.discoveryengine.v1beta.Document]s with the same
616    *     [parent][google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent]. Otherwise, an
617    *     `ALREADY_EXISTS` error is returned.
618    *     <p>This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with
619    *     a length limit of 63 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
620    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
621    */
createDocument(String parent, Document document, String documentId)622   public final Document createDocument(String parent, Document document, String documentId) {
623     CreateDocumentRequest request =
624         CreateDocumentRequest.newBuilder()
625             .setParent(parent)
626             .setDocument(document)
627             .setDocumentId(documentId)
628             .build();
629     return createDocument(request);
630   }
631 
632   // AUTO-GENERATED DOCUMENTATION AND METHOD.
633   /**
634    * Creates a [Document][google.cloud.discoveryengine.v1beta.Document].
635    *
636    * <p>Sample code:
637    *
638    * <pre>{@code
639    * // This snippet has been automatically generated and should be regarded as a code template only.
640    * // It will require modifications to work:
641    * // - It may require correct/in-range values for request initialization.
642    * // - It may require specifying regional endpoints when creating the service client as shown in
643    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
644    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
645    *   CreateDocumentRequest request =
646    *       CreateDocumentRequest.newBuilder()
647    *           .setParent(
648    *               BranchName.ofProjectLocationDataStoreBranchName(
649    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
650    *                   .toString())
651    *           .setDocument(Document.newBuilder().build())
652    *           .setDocumentId("documentId-814940266")
653    *           .build();
654    *   Document response = documentServiceClient.createDocument(request);
655    * }
656    * }</pre>
657    *
658    * @param request The request object containing all of the parameters for the API call.
659    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
660    */
createDocument(CreateDocumentRequest request)661   public final Document createDocument(CreateDocumentRequest request) {
662     return createDocumentCallable().call(request);
663   }
664 
665   // AUTO-GENERATED DOCUMENTATION AND METHOD.
666   /**
667    * Creates a [Document][google.cloud.discoveryengine.v1beta.Document].
668    *
669    * <p>Sample code:
670    *
671    * <pre>{@code
672    * // This snippet has been automatically generated and should be regarded as a code template only.
673    * // It will require modifications to work:
674    * // - It may require correct/in-range values for request initialization.
675    * // - It may require specifying regional endpoints when creating the service client as shown in
676    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
677    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
678    *   CreateDocumentRequest request =
679    *       CreateDocumentRequest.newBuilder()
680    *           .setParent(
681    *               BranchName.ofProjectLocationDataStoreBranchName(
682    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
683    *                   .toString())
684    *           .setDocument(Document.newBuilder().build())
685    *           .setDocumentId("documentId-814940266")
686    *           .build();
687    *   ApiFuture<Document> future =
688    *       documentServiceClient.createDocumentCallable().futureCall(request);
689    *   // Do something.
690    *   Document response = future.get();
691    * }
692    * }</pre>
693    */
createDocumentCallable()694   public final UnaryCallable<CreateDocumentRequest, Document> createDocumentCallable() {
695     return stub.createDocumentCallable();
696   }
697 
698   // AUTO-GENERATED DOCUMENTATION AND METHOD.
699   /**
700    * Updates a [Document][google.cloud.discoveryengine.v1beta.Document].
701    *
702    * <p>Sample code:
703    *
704    * <pre>{@code
705    * // This snippet has been automatically generated and should be regarded as a code template only.
706    * // It will require modifications to work:
707    * // - It may require correct/in-range values for request initialization.
708    * // - It may require specifying regional endpoints when creating the service client as shown in
709    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
710    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
711    *   UpdateDocumentRequest request =
712    *       UpdateDocumentRequest.newBuilder()
713    *           .setDocument(Document.newBuilder().build())
714    *           .setAllowMissing(true)
715    *           .build();
716    *   Document response = documentServiceClient.updateDocument(request);
717    * }
718    * }</pre>
719    *
720    * @param request The request object containing all of the parameters for the API call.
721    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
722    */
updateDocument(UpdateDocumentRequest request)723   public final Document updateDocument(UpdateDocumentRequest request) {
724     return updateDocumentCallable().call(request);
725   }
726 
727   // AUTO-GENERATED DOCUMENTATION AND METHOD.
728   /**
729    * Updates a [Document][google.cloud.discoveryengine.v1beta.Document].
730    *
731    * <p>Sample code:
732    *
733    * <pre>{@code
734    * // This snippet has been automatically generated and should be regarded as a code template only.
735    * // It will require modifications to work:
736    * // - It may require correct/in-range values for request initialization.
737    * // - It may require specifying regional endpoints when creating the service client as shown in
738    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
739    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
740    *   UpdateDocumentRequest request =
741    *       UpdateDocumentRequest.newBuilder()
742    *           .setDocument(Document.newBuilder().build())
743    *           .setAllowMissing(true)
744    *           .build();
745    *   ApiFuture<Document> future =
746    *       documentServiceClient.updateDocumentCallable().futureCall(request);
747    *   // Do something.
748    *   Document response = future.get();
749    * }
750    * }</pre>
751    */
updateDocumentCallable()752   public final UnaryCallable<UpdateDocumentRequest, Document> updateDocumentCallable() {
753     return stub.updateDocumentCallable();
754   }
755 
756   // AUTO-GENERATED DOCUMENTATION AND METHOD.
757   /**
758    * Deletes a [Document][google.cloud.discoveryengine.v1beta.Document].
759    *
760    * <p>Sample code:
761    *
762    * <pre>{@code
763    * // This snippet has been automatically generated and should be regarded as a code template only.
764    * // It will require modifications to work:
765    * // - It may require correct/in-range values for request initialization.
766    * // - It may require specifying regional endpoints when creating the service client as shown in
767    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
768    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
769    *   DocumentName name =
770    *       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
771    *           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]");
772    *   documentServiceClient.deleteDocument(name);
773    * }
774    * }</pre>
775    *
776    * @param name Required. Full resource name of
777    *     [Document][google.cloud.discoveryengine.v1beta.Document], such as
778    *     `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`.
779    *     <p>If the caller does not have permission to delete the
780    *     [Document][google.cloud.discoveryengine.v1beta.Document], regardless of whether or not it
781    *     exists, a `PERMISSION_DENIED` error is returned.
782    *     <p>If the [Document][google.cloud.discoveryengine.v1beta.Document] to delete does not
783    *     exist, a `NOT_FOUND` error is returned.
784    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
785    */
deleteDocument(DocumentName name)786   public final void deleteDocument(DocumentName name) {
787     DeleteDocumentRequest request =
788         DeleteDocumentRequest.newBuilder().setName(name == null ? null : name.toString()).build();
789     deleteDocument(request);
790   }
791 
792   // AUTO-GENERATED DOCUMENTATION AND METHOD.
793   /**
794    * Deletes a [Document][google.cloud.discoveryengine.v1beta.Document].
795    *
796    * <p>Sample code:
797    *
798    * <pre>{@code
799    * // This snippet has been automatically generated and should be regarded as a code template only.
800    * // It will require modifications to work:
801    * // - It may require correct/in-range values for request initialization.
802    * // - It may require specifying regional endpoints when creating the service client as shown in
803    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
804    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
805    *   String name =
806    *       DocumentName.ofProjectLocationDataStoreBranchDocumentName(
807    *               "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
808    *           .toString();
809    *   documentServiceClient.deleteDocument(name);
810    * }
811    * }</pre>
812    *
813    * @param name Required. Full resource name of
814    *     [Document][google.cloud.discoveryengine.v1beta.Document], such as
815    *     `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`.
816    *     <p>If the caller does not have permission to delete the
817    *     [Document][google.cloud.discoveryengine.v1beta.Document], regardless of whether or not it
818    *     exists, a `PERMISSION_DENIED` error is returned.
819    *     <p>If the [Document][google.cloud.discoveryengine.v1beta.Document] to delete does not
820    *     exist, a `NOT_FOUND` error is returned.
821    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
822    */
deleteDocument(String name)823   public final void deleteDocument(String name) {
824     DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder().setName(name).build();
825     deleteDocument(request);
826   }
827 
828   // AUTO-GENERATED DOCUMENTATION AND METHOD.
829   /**
830    * Deletes a [Document][google.cloud.discoveryengine.v1beta.Document].
831    *
832    * <p>Sample code:
833    *
834    * <pre>{@code
835    * // This snippet has been automatically generated and should be regarded as a code template only.
836    * // It will require modifications to work:
837    * // - It may require correct/in-range values for request initialization.
838    * // - It may require specifying regional endpoints when creating the service client as shown in
839    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
840    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
841    *   DeleteDocumentRequest request =
842    *       DeleteDocumentRequest.newBuilder()
843    *           .setName(
844    *               DocumentName.ofProjectLocationDataStoreBranchDocumentName(
845    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
846    *                   .toString())
847    *           .build();
848    *   documentServiceClient.deleteDocument(request);
849    * }
850    * }</pre>
851    *
852    * @param request The request object containing all of the parameters for the API call.
853    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
854    */
deleteDocument(DeleteDocumentRequest request)855   public final void deleteDocument(DeleteDocumentRequest request) {
856     deleteDocumentCallable().call(request);
857   }
858 
859   // AUTO-GENERATED DOCUMENTATION AND METHOD.
860   /**
861    * Deletes a [Document][google.cloud.discoveryengine.v1beta.Document].
862    *
863    * <p>Sample code:
864    *
865    * <pre>{@code
866    * // This snippet has been automatically generated and should be regarded as a code template only.
867    * // It will require modifications to work:
868    * // - It may require correct/in-range values for request initialization.
869    * // - It may require specifying regional endpoints when creating the service client as shown in
870    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
871    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
872    *   DeleteDocumentRequest request =
873    *       DeleteDocumentRequest.newBuilder()
874    *           .setName(
875    *               DocumentName.ofProjectLocationDataStoreBranchDocumentName(
876    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]", "[DOCUMENT]")
877    *                   .toString())
878    *           .build();
879    *   ApiFuture<Empty> future = documentServiceClient.deleteDocumentCallable().futureCall(request);
880    *   // Do something.
881    *   future.get();
882    * }
883    * }</pre>
884    */
deleteDocumentCallable()885   public final UnaryCallable<DeleteDocumentRequest, Empty> deleteDocumentCallable() {
886     return stub.deleteDocumentCallable();
887   }
888 
889   // AUTO-GENERATED DOCUMENTATION AND METHOD.
890   /**
891    * Bulk import of multiple [Document][google.cloud.discoveryengine.v1beta.Document]s. Request
892    * processing may be synchronous. Non-existing items will be created.
893    *
894    * <p>Note: It is possible for a subset of the
895    * [Document][google.cloud.discoveryengine.v1beta.Document]s to be successfully updated.
896    *
897    * <p>Sample code:
898    *
899    * <pre>{@code
900    * // This snippet has been automatically generated and should be regarded as a code template only.
901    * // It will require modifications to work:
902    * // - It may require correct/in-range values for request initialization.
903    * // - It may require specifying regional endpoints when creating the service client as shown in
904    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
905    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
906    *   ImportDocumentsRequest request =
907    *       ImportDocumentsRequest.newBuilder()
908    *           .setParent(
909    *               BranchName.ofProjectLocationDataStoreBranchName(
910    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
911    *                   .toString())
912    *           .setErrorConfig(ImportErrorConfig.newBuilder().build())
913    *           .build();
914    *   ImportDocumentsResponse response = documentServiceClient.importDocumentsAsync(request).get();
915    * }
916    * }</pre>
917    *
918    * @param request The request object containing all of the parameters for the API call.
919    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
920    */
921   public final OperationFuture<ImportDocumentsResponse, ImportDocumentsMetadata>
importDocumentsAsync(ImportDocumentsRequest request)922       importDocumentsAsync(ImportDocumentsRequest request) {
923     return importDocumentsOperationCallable().futureCall(request);
924   }
925 
926   // AUTO-GENERATED DOCUMENTATION AND METHOD.
927   /**
928    * Bulk import of multiple [Document][google.cloud.discoveryengine.v1beta.Document]s. Request
929    * processing may be synchronous. Non-existing items will be created.
930    *
931    * <p>Note: It is possible for a subset of the
932    * [Document][google.cloud.discoveryengine.v1beta.Document]s to be successfully updated.
933    *
934    * <p>Sample code:
935    *
936    * <pre>{@code
937    * // This snippet has been automatically generated and should be regarded as a code template only.
938    * // It will require modifications to work:
939    * // - It may require correct/in-range values for request initialization.
940    * // - It may require specifying regional endpoints when creating the service client as shown in
941    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
942    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
943    *   ImportDocumentsRequest request =
944    *       ImportDocumentsRequest.newBuilder()
945    *           .setParent(
946    *               BranchName.ofProjectLocationDataStoreBranchName(
947    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
948    *                   .toString())
949    *           .setErrorConfig(ImportErrorConfig.newBuilder().build())
950    *           .build();
951    *   OperationFuture<ImportDocumentsResponse, ImportDocumentsMetadata> future =
952    *       documentServiceClient.importDocumentsOperationCallable().futureCall(request);
953    *   // Do something.
954    *   ImportDocumentsResponse response = future.get();
955    * }
956    * }</pre>
957    */
958   public final OperationCallable<
959           ImportDocumentsRequest, ImportDocumentsResponse, ImportDocumentsMetadata>
importDocumentsOperationCallable()960       importDocumentsOperationCallable() {
961     return stub.importDocumentsOperationCallable();
962   }
963 
964   // AUTO-GENERATED DOCUMENTATION AND METHOD.
965   /**
966    * Bulk import of multiple [Document][google.cloud.discoveryengine.v1beta.Document]s. Request
967    * processing may be synchronous. Non-existing items will be created.
968    *
969    * <p>Note: It is possible for a subset of the
970    * [Document][google.cloud.discoveryengine.v1beta.Document]s to be successfully updated.
971    *
972    * <p>Sample code:
973    *
974    * <pre>{@code
975    * // This snippet has been automatically generated and should be regarded as a code template only.
976    * // It will require modifications to work:
977    * // - It may require correct/in-range values for request initialization.
978    * // - It may require specifying regional endpoints when creating the service client as shown in
979    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
980    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
981    *   ImportDocumentsRequest request =
982    *       ImportDocumentsRequest.newBuilder()
983    *           .setParent(
984    *               BranchName.ofProjectLocationDataStoreBranchName(
985    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
986    *                   .toString())
987    *           .setErrorConfig(ImportErrorConfig.newBuilder().build())
988    *           .build();
989    *   ApiFuture<Operation> future =
990    *       documentServiceClient.importDocumentsCallable().futureCall(request);
991    *   // Do something.
992    *   Operation response = future.get();
993    * }
994    * }</pre>
995    */
importDocumentsCallable()996   public final UnaryCallable<ImportDocumentsRequest, Operation> importDocumentsCallable() {
997     return stub.importDocumentsCallable();
998   }
999 
1000   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1001   /**
1002    * Permanently deletes all selected [Document][google.cloud.discoveryengine.v1beta.Document]s in a
1003    * branch.
1004    *
1005    * <p>This process is asynchronous. Depending on the number of
1006    * [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, this operation can
1007    * take hours to complete. Before the delete operation completes, some
1008    * [Document][google.cloud.discoveryengine.v1beta.Document]s might still be returned by
1009    * [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument]
1010    * or
1011    * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments].
1012    *
1013    * <p>To get a list of the [Document][google.cloud.discoveryengine.v1beta.Document]s to be
1014    * deleted, set
1015    * [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force]
1016    * to false.
1017    *
1018    * <p>Sample code:
1019    *
1020    * <pre>{@code
1021    * // This snippet has been automatically generated and should be regarded as a code template only.
1022    * // It will require modifications to work:
1023    * // - It may require correct/in-range values for request initialization.
1024    * // - It may require specifying regional endpoints when creating the service client as shown in
1025    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1026    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
1027    *   PurgeDocumentsRequest request =
1028    *       PurgeDocumentsRequest.newBuilder()
1029    *           .setParent(
1030    *               BranchName.ofProjectLocationDataStoreBranchName(
1031    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
1032    *                   .toString())
1033    *           .setFilter("filter-1274492040")
1034    *           .setForce(true)
1035    *           .build();
1036    *   PurgeDocumentsResponse response = documentServiceClient.purgeDocumentsAsync(request).get();
1037    * }
1038    * }</pre>
1039    *
1040    * @param request The request object containing all of the parameters for the API call.
1041    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1042    */
purgeDocumentsAsync( PurgeDocumentsRequest request)1043   public final OperationFuture<PurgeDocumentsResponse, PurgeDocumentsMetadata> purgeDocumentsAsync(
1044       PurgeDocumentsRequest request) {
1045     return purgeDocumentsOperationCallable().futureCall(request);
1046   }
1047 
1048   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1049   /**
1050    * Permanently deletes all selected [Document][google.cloud.discoveryengine.v1beta.Document]s in a
1051    * branch.
1052    *
1053    * <p>This process is asynchronous. Depending on the number of
1054    * [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, this operation can
1055    * take hours to complete. Before the delete operation completes, some
1056    * [Document][google.cloud.discoveryengine.v1beta.Document]s might still be returned by
1057    * [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument]
1058    * or
1059    * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments].
1060    *
1061    * <p>To get a list of the [Document][google.cloud.discoveryengine.v1beta.Document]s to be
1062    * deleted, set
1063    * [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force]
1064    * to false.
1065    *
1066    * <p>Sample code:
1067    *
1068    * <pre>{@code
1069    * // This snippet has been automatically generated and should be regarded as a code template only.
1070    * // It will require modifications to work:
1071    * // - It may require correct/in-range values for request initialization.
1072    * // - It may require specifying regional endpoints when creating the service client as shown in
1073    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1074    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
1075    *   PurgeDocumentsRequest request =
1076    *       PurgeDocumentsRequest.newBuilder()
1077    *           .setParent(
1078    *               BranchName.ofProjectLocationDataStoreBranchName(
1079    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
1080    *                   .toString())
1081    *           .setFilter("filter-1274492040")
1082    *           .setForce(true)
1083    *           .build();
1084    *   OperationFuture<PurgeDocumentsResponse, PurgeDocumentsMetadata> future =
1085    *       documentServiceClient.purgeDocumentsOperationCallable().futureCall(request);
1086    *   // Do something.
1087    *   PurgeDocumentsResponse response = future.get();
1088    * }
1089    * }</pre>
1090    */
1091   public final OperationCallable<
1092           PurgeDocumentsRequest, PurgeDocumentsResponse, PurgeDocumentsMetadata>
purgeDocumentsOperationCallable()1093       purgeDocumentsOperationCallable() {
1094     return stub.purgeDocumentsOperationCallable();
1095   }
1096 
1097   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1098   /**
1099    * Permanently deletes all selected [Document][google.cloud.discoveryengine.v1beta.Document]s in a
1100    * branch.
1101    *
1102    * <p>This process is asynchronous. Depending on the number of
1103    * [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, this operation can
1104    * take hours to complete. Before the delete operation completes, some
1105    * [Document][google.cloud.discoveryengine.v1beta.Document]s might still be returned by
1106    * [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument]
1107    * or
1108    * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments].
1109    *
1110    * <p>To get a list of the [Document][google.cloud.discoveryengine.v1beta.Document]s to be
1111    * deleted, set
1112    * [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force]
1113    * to false.
1114    *
1115    * <p>Sample code:
1116    *
1117    * <pre>{@code
1118    * // This snippet has been automatically generated and should be regarded as a code template only.
1119    * // It will require modifications to work:
1120    * // - It may require correct/in-range values for request initialization.
1121    * // - It may require specifying regional endpoints when creating the service client as shown in
1122    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1123    * try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
1124    *   PurgeDocumentsRequest request =
1125    *       PurgeDocumentsRequest.newBuilder()
1126    *           .setParent(
1127    *               BranchName.ofProjectLocationDataStoreBranchName(
1128    *                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[BRANCH]")
1129    *                   .toString())
1130    *           .setFilter("filter-1274492040")
1131    *           .setForce(true)
1132    *           .build();
1133    *   ApiFuture<Operation> future =
1134    *       documentServiceClient.purgeDocumentsCallable().futureCall(request);
1135    *   // Do something.
1136    *   Operation response = future.get();
1137    * }
1138    * }</pre>
1139    */
purgeDocumentsCallable()1140   public final UnaryCallable<PurgeDocumentsRequest, Operation> purgeDocumentsCallable() {
1141     return stub.purgeDocumentsCallable();
1142   }
1143 
1144   @Override
close()1145   public final void close() {
1146     stub.close();
1147   }
1148 
1149   @Override
shutdown()1150   public void shutdown() {
1151     stub.shutdown();
1152   }
1153 
1154   @Override
isShutdown()1155   public boolean isShutdown() {
1156     return stub.isShutdown();
1157   }
1158 
1159   @Override
isTerminated()1160   public boolean isTerminated() {
1161     return stub.isTerminated();
1162   }
1163 
1164   @Override
shutdownNow()1165   public void shutdownNow() {
1166     stub.shutdownNow();
1167   }
1168 
1169   @Override
awaitTermination(long duration, TimeUnit unit)1170   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
1171     return stub.awaitTermination(duration, unit);
1172   }
1173 
1174   public static class ListDocumentsPagedResponse
1175       extends AbstractPagedListResponse<
1176           ListDocumentsRequest,
1177           ListDocumentsResponse,
1178           Document,
1179           ListDocumentsPage,
1180           ListDocumentsFixedSizeCollection> {
1181 
createAsync( PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context, ApiFuture<ListDocumentsResponse> futureResponse)1182     public static ApiFuture<ListDocumentsPagedResponse> createAsync(
1183         PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context,
1184         ApiFuture<ListDocumentsResponse> futureResponse) {
1185       ApiFuture<ListDocumentsPage> futurePage =
1186           ListDocumentsPage.createEmptyPage().createPageAsync(context, futureResponse);
1187       return ApiFutures.transform(
1188           futurePage,
1189           input -> new ListDocumentsPagedResponse(input),
1190           MoreExecutors.directExecutor());
1191     }
1192 
ListDocumentsPagedResponse(ListDocumentsPage page)1193     private ListDocumentsPagedResponse(ListDocumentsPage page) {
1194       super(page, ListDocumentsFixedSizeCollection.createEmptyCollection());
1195     }
1196   }
1197 
1198   public static class ListDocumentsPage
1199       extends AbstractPage<
1200           ListDocumentsRequest, ListDocumentsResponse, Document, ListDocumentsPage> {
1201 
ListDocumentsPage( PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context, ListDocumentsResponse response)1202     private ListDocumentsPage(
1203         PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context,
1204         ListDocumentsResponse response) {
1205       super(context, response);
1206     }
1207 
createEmptyPage()1208     private static ListDocumentsPage createEmptyPage() {
1209       return new ListDocumentsPage(null, null);
1210     }
1211 
1212     @Override
createPage( PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context, ListDocumentsResponse response)1213     protected ListDocumentsPage createPage(
1214         PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context,
1215         ListDocumentsResponse response) {
1216       return new ListDocumentsPage(context, response);
1217     }
1218 
1219     @Override
createPageAsync( PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context, ApiFuture<ListDocumentsResponse> futureResponse)1220     public ApiFuture<ListDocumentsPage> createPageAsync(
1221         PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context,
1222         ApiFuture<ListDocumentsResponse> futureResponse) {
1223       return super.createPageAsync(context, futureResponse);
1224     }
1225   }
1226 
1227   public static class ListDocumentsFixedSizeCollection
1228       extends AbstractFixedSizeCollection<
1229           ListDocumentsRequest,
1230           ListDocumentsResponse,
1231           Document,
1232           ListDocumentsPage,
1233           ListDocumentsFixedSizeCollection> {
1234 
ListDocumentsFixedSizeCollection(List<ListDocumentsPage> pages, int collectionSize)1235     private ListDocumentsFixedSizeCollection(List<ListDocumentsPage> pages, int collectionSize) {
1236       super(pages, collectionSize);
1237     }
1238 
createEmptyCollection()1239     private static ListDocumentsFixedSizeCollection createEmptyCollection() {
1240       return new ListDocumentsFixedSizeCollection(null, 0);
1241     }
1242 
1243     @Override
createCollection( List<ListDocumentsPage> pages, int collectionSize)1244     protected ListDocumentsFixedSizeCollection createCollection(
1245         List<ListDocumentsPage> pages, int collectionSize) {
1246       return new ListDocumentsFixedSizeCollection(pages, collectionSize);
1247     }
1248   }
1249 }
1250