• 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.dialogflow.v2;
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.dialogflow.v2.stub.DocumentsStub;
32 import com.google.cloud.dialogflow.v2.stub.DocumentsStubSettings;
33 import com.google.cloud.location.GetLocationRequest;
34 import com.google.cloud.location.ListLocationsRequest;
35 import com.google.cloud.location.ListLocationsResponse;
36 import com.google.cloud.location.Location;
37 import com.google.common.util.concurrent.MoreExecutors;
38 import com.google.longrunning.Operation;
39 import com.google.protobuf.Empty;
40 import com.google.protobuf.FieldMask;
41 import java.io.IOException;
42 import java.util.List;
43 import java.util.concurrent.TimeUnit;
44 import javax.annotation.Generated;
45 
46 // AUTO-GENERATED DOCUMENTATION AND CLASS.
47 /**
48  * Service Description: Service for managing knowledge
49  * [Documents][google.cloud.dialogflow.v2.Document].
50  *
51  * <p>This class provides the ability to make remote calls to the backing service through method
52  * calls that map to API methods. Sample code to get started:
53  *
54  * <pre>{@code
55  * // This snippet has been automatically generated and should be regarded as a code template only.
56  * // It will require modifications to work:
57  * // - It may require correct/in-range values for request initialization.
58  * // - It may require specifying regional endpoints when creating the service client as shown in
59  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
60  * try (DocumentsClient documentsClient = DocumentsClient.create()) {
61  *   DocumentName name =
62  *       DocumentName.ofProjectKnowledgeBaseDocumentName(
63  *           "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
64  *   Document response = documentsClient.getDocument(name);
65  * }
66  * }</pre>
67  *
68  * <p>Note: close() needs to be called on the DocumentsClient object to clean up resources such as
69  * threads. In the example above, try-with-resources is used, which automatically calls close().
70  *
71  * <p>The surface of this class includes several types of Java methods for each of the API's
72  * methods:
73  *
74  * <ol>
75  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
76  *       converted into function parameters. It may be the case that not all fields are available as
77  *       parameters, and not every API method will have a flattened method entry point.
78  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
79  *       which must be constructed before the call. Not every API method will have a request object
80  *       method.
81  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
82  *       callable object, which can be used to initiate calls to the service.
83  * </ol>
84  *
85  * <p>See the individual methods for example code.
86  *
87  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
88  * these names, this class includes a format method for each type of name, and additionally a parse
89  * method to extract the individual identifiers contained within names that are returned.
90  *
91  * <p>This class can be customized by passing in a custom instance of DocumentsSettings to create().
92  * For example:
93  *
94  * <p>To customize credentials:
95  *
96  * <pre>{@code
97  * // This snippet has been automatically generated and should be regarded as a code template only.
98  * // It will require modifications to work:
99  * // - It may require correct/in-range values for request initialization.
100  * // - It may require specifying regional endpoints when creating the service client as shown in
101  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
102  * DocumentsSettings documentsSettings =
103  *     DocumentsSettings.newBuilder()
104  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
105  *         .build();
106  * DocumentsClient documentsClient = DocumentsClient.create(documentsSettings);
107  * }</pre>
108  *
109  * <p>To customize the endpoint:
110  *
111  * <pre>{@code
112  * // This snippet has been automatically generated and should be regarded as a code template only.
113  * // It will require modifications to work:
114  * // - It may require correct/in-range values for request initialization.
115  * // - It may require specifying regional endpoints when creating the service client as shown in
116  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
117  * DocumentsSettings documentsSettings =
118  *     DocumentsSettings.newBuilder().setEndpoint(myEndpoint).build();
119  * DocumentsClient documentsClient = DocumentsClient.create(documentsSettings);
120  * }</pre>
121  *
122  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
123  * the wire:
124  *
125  * <pre>{@code
126  * // This snippet has been automatically generated and should be regarded as a code template only.
127  * // It will require modifications to work:
128  * // - It may require correct/in-range values for request initialization.
129  * // - It may require specifying regional endpoints when creating the service client as shown in
130  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
131  * DocumentsSettings documentsSettings = DocumentsSettings.newHttpJsonBuilder().build();
132  * DocumentsClient documentsClient = DocumentsClient.create(documentsSettings);
133  * }</pre>
134  *
135  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
136  */
137 @Generated("by gapic-generator-java")
138 public class DocumentsClient implements BackgroundResource {
139   private final DocumentsSettings settings;
140   private final DocumentsStub stub;
141   private final OperationsClient httpJsonOperationsClient;
142   private final com.google.longrunning.OperationsClient operationsClient;
143 
144   /** Constructs an instance of DocumentsClient with default settings. */
create()145   public static final DocumentsClient create() throws IOException {
146     return create(DocumentsSettings.newBuilder().build());
147   }
148 
149   /**
150    * Constructs an instance of DocumentsClient, using the given settings. The channels are created
151    * based on the settings passed in, or defaults for any settings that are not set.
152    */
create(DocumentsSettings settings)153   public static final DocumentsClient create(DocumentsSettings settings) throws IOException {
154     return new DocumentsClient(settings);
155   }
156 
157   /**
158    * Constructs an instance of DocumentsClient, using the given stub for making calls. This is for
159    * advanced usage - prefer using create(DocumentsSettings).
160    */
create(DocumentsStub stub)161   public static final DocumentsClient create(DocumentsStub stub) {
162     return new DocumentsClient(stub);
163   }
164 
165   /**
166    * Constructs an instance of DocumentsClient, using the given settings. This is protected so that
167    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
168    */
DocumentsClient(DocumentsSettings settings)169   protected DocumentsClient(DocumentsSettings settings) throws IOException {
170     this.settings = settings;
171     this.stub = ((DocumentsStubSettings) settings.getStubSettings()).createStub();
172     this.operationsClient =
173         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
174     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
175   }
176 
DocumentsClient(DocumentsStub stub)177   protected DocumentsClient(DocumentsStub stub) {
178     this.settings = null;
179     this.stub = stub;
180     this.operationsClient =
181         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
182     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
183   }
184 
getSettings()185   public final DocumentsSettings getSettings() {
186     return settings;
187   }
188 
getStub()189   public DocumentsStub getStub() {
190     return stub;
191   }
192 
193   /**
194    * Returns the OperationsClient that can be used to query the status of a long-running operation
195    * returned by another API method call.
196    */
getOperationsClient()197   public final com.google.longrunning.OperationsClient getOperationsClient() {
198     return operationsClient;
199   }
200 
201   /**
202    * Returns the OperationsClient that can be used to query the status of a long-running operation
203    * returned by another API method call.
204    */
205   @BetaApi
getHttpJsonOperationsClient()206   public final OperationsClient getHttpJsonOperationsClient() {
207     return httpJsonOperationsClient;
208   }
209 
210   // AUTO-GENERATED DOCUMENTATION AND METHOD.
211   /**
212    * Returns the list of all documents of the knowledge base.
213    *
214    * <p>Sample code:
215    *
216    * <pre>{@code
217    * // This snippet has been automatically generated and should be regarded as a code template only.
218    * // It will require modifications to work:
219    * // - It may require correct/in-range values for request initialization.
220    * // - It may require specifying regional endpoints when creating the service client as shown in
221    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
222    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
223    *   KnowledgeBaseName parent =
224    *       KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]");
225    *   for (Document element : documentsClient.listDocuments(parent).iterateAll()) {
226    *     // doThingsWith(element);
227    *   }
228    * }
229    * }</pre>
230    *
231    * @param parent Required. The knowledge base to list all documents for. Format:
232    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/knowledgeBases/&lt;Knowledge
233    *     Base ID&gt;`.
234    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
235    */
listDocuments(KnowledgeBaseName parent)236   public final ListDocumentsPagedResponse listDocuments(KnowledgeBaseName parent) {
237     ListDocumentsRequest request =
238         ListDocumentsRequest.newBuilder()
239             .setParent(parent == null ? null : parent.toString())
240             .build();
241     return listDocuments(request);
242   }
243 
244   // AUTO-GENERATED DOCUMENTATION AND METHOD.
245   /**
246    * Returns the list of all documents of the knowledge base.
247    *
248    * <p>Sample code:
249    *
250    * <pre>{@code
251    * // This snippet has been automatically generated and should be regarded as a code template only.
252    * // It will require modifications to work:
253    * // - It may require correct/in-range values for request initialization.
254    * // - It may require specifying regional endpoints when creating the service client as shown in
255    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
256    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
257    *   String parent =
258    *       KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString();
259    *   for (Document element : documentsClient.listDocuments(parent).iterateAll()) {
260    *     // doThingsWith(element);
261    *   }
262    * }
263    * }</pre>
264    *
265    * @param parent Required. The knowledge base to list all documents for. Format:
266    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/knowledgeBases/&lt;Knowledge
267    *     Base ID&gt;`.
268    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
269    */
listDocuments(String parent)270   public final ListDocumentsPagedResponse listDocuments(String parent) {
271     ListDocumentsRequest request = ListDocumentsRequest.newBuilder().setParent(parent).build();
272     return listDocuments(request);
273   }
274 
275   // AUTO-GENERATED DOCUMENTATION AND METHOD.
276   /**
277    * Returns the list of all documents of the knowledge base.
278    *
279    * <p>Sample code:
280    *
281    * <pre>{@code
282    * // This snippet has been automatically generated and should be regarded as a code template only.
283    * // It will require modifications to work:
284    * // - It may require correct/in-range values for request initialization.
285    * // - It may require specifying regional endpoints when creating the service client as shown in
286    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
287    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
288    *   ListDocumentsRequest request =
289    *       ListDocumentsRequest.newBuilder()
290    *           .setParent(
291    *               KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
292    *                   .toString())
293    *           .setPageSize(883849137)
294    *           .setPageToken("pageToken873572522")
295    *           .setFilter("filter-1274492040")
296    *           .build();
297    *   for (Document element : documentsClient.listDocuments(request).iterateAll()) {
298    *     // doThingsWith(element);
299    *   }
300    * }
301    * }</pre>
302    *
303    * @param request The request object containing all of the parameters for the API call.
304    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
305    */
listDocuments(ListDocumentsRequest request)306   public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest request) {
307     return listDocumentsPagedCallable().call(request);
308   }
309 
310   // AUTO-GENERATED DOCUMENTATION AND METHOD.
311   /**
312    * Returns the list of all documents of the knowledge base.
313    *
314    * <p>Sample code:
315    *
316    * <pre>{@code
317    * // This snippet has been automatically generated and should be regarded as a code template only.
318    * // It will require modifications to work:
319    * // - It may require correct/in-range values for request initialization.
320    * // - It may require specifying regional endpoints when creating the service client as shown in
321    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
322    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
323    *   ListDocumentsRequest request =
324    *       ListDocumentsRequest.newBuilder()
325    *           .setParent(
326    *               KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
327    *                   .toString())
328    *           .setPageSize(883849137)
329    *           .setPageToken("pageToken873572522")
330    *           .setFilter("filter-1274492040")
331    *           .build();
332    *   ApiFuture<Document> future = documentsClient.listDocumentsPagedCallable().futureCall(request);
333    *   // Do something.
334    *   for (Document element : future.get().iterateAll()) {
335    *     // doThingsWith(element);
336    *   }
337    * }
338    * }</pre>
339    */
340   public final UnaryCallable<ListDocumentsRequest, ListDocumentsPagedResponse>
listDocumentsPagedCallable()341       listDocumentsPagedCallable() {
342     return stub.listDocumentsPagedCallable();
343   }
344 
345   // AUTO-GENERATED DOCUMENTATION AND METHOD.
346   /**
347    * Returns the list of all documents of the knowledge base.
348    *
349    * <p>Sample code:
350    *
351    * <pre>{@code
352    * // This snippet has been automatically generated and should be regarded as a code template only.
353    * // It will require modifications to work:
354    * // - It may require correct/in-range values for request initialization.
355    * // - It may require specifying regional endpoints when creating the service client as shown in
356    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
357    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
358    *   ListDocumentsRequest request =
359    *       ListDocumentsRequest.newBuilder()
360    *           .setParent(
361    *               KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
362    *                   .toString())
363    *           .setPageSize(883849137)
364    *           .setPageToken("pageToken873572522")
365    *           .setFilter("filter-1274492040")
366    *           .build();
367    *   while (true) {
368    *     ListDocumentsResponse response = documentsClient.listDocumentsCallable().call(request);
369    *     for (Document element : response.getDocumentsList()) {
370    *       // doThingsWith(element);
371    *     }
372    *     String nextPageToken = response.getNextPageToken();
373    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
374    *       request = request.toBuilder().setPageToken(nextPageToken).build();
375    *     } else {
376    *       break;
377    *     }
378    *   }
379    * }
380    * }</pre>
381    */
listDocumentsCallable()382   public final UnaryCallable<ListDocumentsRequest, ListDocumentsResponse> listDocumentsCallable() {
383     return stub.listDocumentsCallable();
384   }
385 
386   // AUTO-GENERATED DOCUMENTATION AND METHOD.
387   /**
388    * Retrieves the specified document.
389    *
390    * <p>Sample code:
391    *
392    * <pre>{@code
393    * // This snippet has been automatically generated and should be regarded as a code template only.
394    * // It will require modifications to work:
395    * // - It may require correct/in-range values for request initialization.
396    * // - It may require specifying regional endpoints when creating the service client as shown in
397    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
398    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
399    *   DocumentName name =
400    *       DocumentName.ofProjectKnowledgeBaseDocumentName(
401    *           "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
402    *   Document response = documentsClient.getDocument(name);
403    * }
404    * }</pre>
405    *
406    * @param name Required. The name of the document to retrieve. Format `projects/&lt;Project
407    *     ID&gt;/locations/&lt;Location ID&gt;/knowledgeBases/&lt;Knowledge Base
408    *     ID&gt;/documents/&lt;Document ID&gt;`.
409    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
410    */
getDocument(DocumentName name)411   public final Document getDocument(DocumentName name) {
412     GetDocumentRequest request =
413         GetDocumentRequest.newBuilder().setName(name == null ? null : name.toString()).build();
414     return getDocument(request);
415   }
416 
417   // AUTO-GENERATED DOCUMENTATION AND METHOD.
418   /**
419    * Retrieves the specified document.
420    *
421    * <p>Sample code:
422    *
423    * <pre>{@code
424    * // This snippet has been automatically generated and should be regarded as a code template only.
425    * // It will require modifications to work:
426    * // - It may require correct/in-range values for request initialization.
427    * // - It may require specifying regional endpoints when creating the service client as shown in
428    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
429    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
430    *   String name =
431    *       DocumentName.ofProjectKnowledgeBaseDocumentName(
432    *               "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
433    *           .toString();
434    *   Document response = documentsClient.getDocument(name);
435    * }
436    * }</pre>
437    *
438    * @param name Required. The name of the document to retrieve. Format `projects/&lt;Project
439    *     ID&gt;/locations/&lt;Location ID&gt;/knowledgeBases/&lt;Knowledge Base
440    *     ID&gt;/documents/&lt;Document ID&gt;`.
441    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
442    */
getDocument(String name)443   public final Document getDocument(String name) {
444     GetDocumentRequest request = GetDocumentRequest.newBuilder().setName(name).build();
445     return getDocument(request);
446   }
447 
448   // AUTO-GENERATED DOCUMENTATION AND METHOD.
449   /**
450    * Retrieves the specified document.
451    *
452    * <p>Sample code:
453    *
454    * <pre>{@code
455    * // This snippet has been automatically generated and should be regarded as a code template only.
456    * // It will require modifications to work:
457    * // - It may require correct/in-range values for request initialization.
458    * // - It may require specifying regional endpoints when creating the service client as shown in
459    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
460    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
461    *   GetDocumentRequest request =
462    *       GetDocumentRequest.newBuilder()
463    *           .setName(
464    *               DocumentName.ofProjectKnowledgeBaseDocumentName(
465    *                       "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
466    *                   .toString())
467    *           .build();
468    *   Document response = documentsClient.getDocument(request);
469    * }
470    * }</pre>
471    *
472    * @param request The request object containing all of the parameters for the API call.
473    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
474    */
getDocument(GetDocumentRequest request)475   public final Document getDocument(GetDocumentRequest request) {
476     return getDocumentCallable().call(request);
477   }
478 
479   // AUTO-GENERATED DOCUMENTATION AND METHOD.
480   /**
481    * Retrieves the specified document.
482    *
483    * <p>Sample code:
484    *
485    * <pre>{@code
486    * // This snippet has been automatically generated and should be regarded as a code template only.
487    * // It will require modifications to work:
488    * // - It may require correct/in-range values for request initialization.
489    * // - It may require specifying regional endpoints when creating the service client as shown in
490    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
491    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
492    *   GetDocumentRequest request =
493    *       GetDocumentRequest.newBuilder()
494    *           .setName(
495    *               DocumentName.ofProjectKnowledgeBaseDocumentName(
496    *                       "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
497    *                   .toString())
498    *           .build();
499    *   ApiFuture<Document> future = documentsClient.getDocumentCallable().futureCall(request);
500    *   // Do something.
501    *   Document response = future.get();
502    * }
503    * }</pre>
504    */
getDocumentCallable()505   public final UnaryCallable<GetDocumentRequest, Document> getDocumentCallable() {
506     return stub.getDocumentCallable();
507   }
508 
509   // AUTO-GENERATED DOCUMENTATION AND METHOD.
510   /**
511    * Creates a new document.
512    *
513    * <p>This method is a [long-running
514    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
515    * returned `Operation` type has the following method-specific fields:
516    *
517    * <p>- `metadata`:
518    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
519    * `response`: [Document][google.cloud.dialogflow.v2.Document]
520    *
521    * <p>Sample code:
522    *
523    * <pre>{@code
524    * // This snippet has been automatically generated and should be regarded as a code template only.
525    * // It will require modifications to work:
526    * // - It may require correct/in-range values for request initialization.
527    * // - It may require specifying regional endpoints when creating the service client as shown in
528    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
529    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
530    *   KnowledgeBaseName parent =
531    *       KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]");
532    *   Document document = Document.newBuilder().build();
533    *   Document response = documentsClient.createDocumentAsync(parent, document).get();
534    * }
535    * }</pre>
536    *
537    * @param parent Required. The knowledge base to create a document for. Format:
538    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/knowledgeBases/&lt;Knowledge
539    *     Base ID&gt;`.
540    * @param document Required. The document to create.
541    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
542    */
createDocumentAsync( KnowledgeBaseName parent, Document document)543   public final OperationFuture<Document, KnowledgeOperationMetadata> createDocumentAsync(
544       KnowledgeBaseName parent, Document document) {
545     CreateDocumentRequest request =
546         CreateDocumentRequest.newBuilder()
547             .setParent(parent == null ? null : parent.toString())
548             .setDocument(document)
549             .build();
550     return createDocumentAsync(request);
551   }
552 
553   // AUTO-GENERATED DOCUMENTATION AND METHOD.
554   /**
555    * Creates a new document.
556    *
557    * <p>This method is a [long-running
558    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
559    * returned `Operation` type has the following method-specific fields:
560    *
561    * <p>- `metadata`:
562    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
563    * `response`: [Document][google.cloud.dialogflow.v2.Document]
564    *
565    * <p>Sample code:
566    *
567    * <pre>{@code
568    * // This snippet has been automatically generated and should be regarded as a code template only.
569    * // It will require modifications to work:
570    * // - It may require correct/in-range values for request initialization.
571    * // - It may require specifying regional endpoints when creating the service client as shown in
572    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
573    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
574    *   String parent =
575    *       KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString();
576    *   Document document = Document.newBuilder().build();
577    *   Document response = documentsClient.createDocumentAsync(parent, document).get();
578    * }
579    * }</pre>
580    *
581    * @param parent Required. The knowledge base to create a document for. Format:
582    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/knowledgeBases/&lt;Knowledge
583    *     Base ID&gt;`.
584    * @param document Required. The document to create.
585    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
586    */
createDocumentAsync( String parent, Document document)587   public final OperationFuture<Document, KnowledgeOperationMetadata> createDocumentAsync(
588       String parent, Document document) {
589     CreateDocumentRequest request =
590         CreateDocumentRequest.newBuilder().setParent(parent).setDocument(document).build();
591     return createDocumentAsync(request);
592   }
593 
594   // AUTO-GENERATED DOCUMENTATION AND METHOD.
595   /**
596    * Creates a new document.
597    *
598    * <p>This method is a [long-running
599    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
600    * returned `Operation` type has the following method-specific fields:
601    *
602    * <p>- `metadata`:
603    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
604    * `response`: [Document][google.cloud.dialogflow.v2.Document]
605    *
606    * <p>Sample code:
607    *
608    * <pre>{@code
609    * // This snippet has been automatically generated and should be regarded as a code template only.
610    * // It will require modifications to work:
611    * // - It may require correct/in-range values for request initialization.
612    * // - It may require specifying regional endpoints when creating the service client as shown in
613    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
614    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
615    *   CreateDocumentRequest request =
616    *       CreateDocumentRequest.newBuilder()
617    *           .setParent(
618    *               KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
619    *                   .toString())
620    *           .setDocument(Document.newBuilder().build())
621    *           .build();
622    *   Document response = documentsClient.createDocumentAsync(request).get();
623    * }
624    * }</pre>
625    *
626    * @param request The request object containing all of the parameters for the API call.
627    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
628    */
createDocumentAsync( CreateDocumentRequest request)629   public final OperationFuture<Document, KnowledgeOperationMetadata> createDocumentAsync(
630       CreateDocumentRequest request) {
631     return createDocumentOperationCallable().futureCall(request);
632   }
633 
634   // AUTO-GENERATED DOCUMENTATION AND METHOD.
635   /**
636    * Creates a new document.
637    *
638    * <p>This method is a [long-running
639    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
640    * returned `Operation` type has the following method-specific fields:
641    *
642    * <p>- `metadata`:
643    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
644    * `response`: [Document][google.cloud.dialogflow.v2.Document]
645    *
646    * <p>Sample code:
647    *
648    * <pre>{@code
649    * // This snippet has been automatically generated and should be regarded as a code template only.
650    * // It will require modifications to work:
651    * // - It may require correct/in-range values for request initialization.
652    * // - It may require specifying regional endpoints when creating the service client as shown in
653    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
654    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
655    *   CreateDocumentRequest request =
656    *       CreateDocumentRequest.newBuilder()
657    *           .setParent(
658    *               KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
659    *                   .toString())
660    *           .setDocument(Document.newBuilder().build())
661    *           .build();
662    *   OperationFuture<Document, KnowledgeOperationMetadata> future =
663    *       documentsClient.createDocumentOperationCallable().futureCall(request);
664    *   // Do something.
665    *   Document response = future.get();
666    * }
667    * }</pre>
668    */
669   public final OperationCallable<CreateDocumentRequest, Document, KnowledgeOperationMetadata>
createDocumentOperationCallable()670       createDocumentOperationCallable() {
671     return stub.createDocumentOperationCallable();
672   }
673 
674   // AUTO-GENERATED DOCUMENTATION AND METHOD.
675   /**
676    * Creates a new document.
677    *
678    * <p>This method is a [long-running
679    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
680    * returned `Operation` type has the following method-specific fields:
681    *
682    * <p>- `metadata`:
683    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
684    * `response`: [Document][google.cloud.dialogflow.v2.Document]
685    *
686    * <p>Sample code:
687    *
688    * <pre>{@code
689    * // This snippet has been automatically generated and should be regarded as a code template only.
690    * // It will require modifications to work:
691    * // - It may require correct/in-range values for request initialization.
692    * // - It may require specifying regional endpoints when creating the service client as shown in
693    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
694    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
695    *   CreateDocumentRequest request =
696    *       CreateDocumentRequest.newBuilder()
697    *           .setParent(
698    *               KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
699    *                   .toString())
700    *           .setDocument(Document.newBuilder().build())
701    *           .build();
702    *   ApiFuture<Operation> future = documentsClient.createDocumentCallable().futureCall(request);
703    *   // Do something.
704    *   Operation response = future.get();
705    * }
706    * }</pre>
707    */
createDocumentCallable()708   public final UnaryCallable<CreateDocumentRequest, Operation> createDocumentCallable() {
709     return stub.createDocumentCallable();
710   }
711 
712   // AUTO-GENERATED DOCUMENTATION AND METHOD.
713   /**
714    * Creates documents by importing data from external sources. Dialogflow supports up to 350
715    * documents in each request. If you try to import more, Dialogflow will return an error.
716    *
717    * <p>This method is a [long-running
718    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
719    * returned `Operation` type has the following method-specific fields:
720    *
721    * <p>- `metadata`:
722    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
723    * `response`: [ImportDocumentsResponse][google.cloud.dialogflow.v2.ImportDocumentsResponse]
724    *
725    * <p>Sample code:
726    *
727    * <pre>{@code
728    * // This snippet has been automatically generated and should be regarded as a code template only.
729    * // It will require modifications to work:
730    * // - It may require correct/in-range values for request initialization.
731    * // - It may require specifying regional endpoints when creating the service client as shown in
732    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
733    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
734    *   ImportDocumentsRequest request =
735    *       ImportDocumentsRequest.newBuilder()
736    *           .setParent(
737    *               KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
738    *                   .toString())
739    *           .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build())
740    *           .setImportGcsCustomMetadata(true)
741    *           .build();
742    *   ImportDocumentsResponse response = documentsClient.importDocumentsAsync(request).get();
743    * }
744    * }</pre>
745    *
746    * @param request The request object containing all of the parameters for the API call.
747    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
748    */
749   public final OperationFuture<ImportDocumentsResponse, KnowledgeOperationMetadata>
importDocumentsAsync(ImportDocumentsRequest request)750       importDocumentsAsync(ImportDocumentsRequest request) {
751     return importDocumentsOperationCallable().futureCall(request);
752   }
753 
754   // AUTO-GENERATED DOCUMENTATION AND METHOD.
755   /**
756    * Creates documents by importing data from external sources. Dialogflow supports up to 350
757    * documents in each request. If you try to import more, Dialogflow will return an error.
758    *
759    * <p>This method is a [long-running
760    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
761    * returned `Operation` type has the following method-specific fields:
762    *
763    * <p>- `metadata`:
764    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
765    * `response`: [ImportDocumentsResponse][google.cloud.dialogflow.v2.ImportDocumentsResponse]
766    *
767    * <p>Sample code:
768    *
769    * <pre>{@code
770    * // This snippet has been automatically generated and should be regarded as a code template only.
771    * // It will require modifications to work:
772    * // - It may require correct/in-range values for request initialization.
773    * // - It may require specifying regional endpoints when creating the service client as shown in
774    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
775    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
776    *   ImportDocumentsRequest request =
777    *       ImportDocumentsRequest.newBuilder()
778    *           .setParent(
779    *               KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
780    *                   .toString())
781    *           .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build())
782    *           .setImportGcsCustomMetadata(true)
783    *           .build();
784    *   OperationFuture<ImportDocumentsResponse, KnowledgeOperationMetadata> future =
785    *       documentsClient.importDocumentsOperationCallable().futureCall(request);
786    *   // Do something.
787    *   ImportDocumentsResponse response = future.get();
788    * }
789    * }</pre>
790    */
791   public final OperationCallable<
792           ImportDocumentsRequest, ImportDocumentsResponse, KnowledgeOperationMetadata>
importDocumentsOperationCallable()793       importDocumentsOperationCallable() {
794     return stub.importDocumentsOperationCallable();
795   }
796 
797   // AUTO-GENERATED DOCUMENTATION AND METHOD.
798   /**
799    * Creates documents by importing data from external sources. Dialogflow supports up to 350
800    * documents in each request. If you try to import more, Dialogflow will return an error.
801    *
802    * <p>This method is a [long-running
803    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
804    * returned `Operation` type has the following method-specific fields:
805    *
806    * <p>- `metadata`:
807    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
808    * `response`: [ImportDocumentsResponse][google.cloud.dialogflow.v2.ImportDocumentsResponse]
809    *
810    * <p>Sample code:
811    *
812    * <pre>{@code
813    * // This snippet has been automatically generated and should be regarded as a code template only.
814    * // It will require modifications to work:
815    * // - It may require correct/in-range values for request initialization.
816    * // - It may require specifying regional endpoints when creating the service client as shown in
817    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
818    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
819    *   ImportDocumentsRequest request =
820    *       ImportDocumentsRequest.newBuilder()
821    *           .setParent(
822    *               KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
823    *                   .toString())
824    *           .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build())
825    *           .setImportGcsCustomMetadata(true)
826    *           .build();
827    *   ApiFuture<Operation> future = documentsClient.importDocumentsCallable().futureCall(request);
828    *   // Do something.
829    *   Operation response = future.get();
830    * }
831    * }</pre>
832    */
importDocumentsCallable()833   public final UnaryCallable<ImportDocumentsRequest, Operation> importDocumentsCallable() {
834     return stub.importDocumentsCallable();
835   }
836 
837   // AUTO-GENERATED DOCUMENTATION AND METHOD.
838   /**
839    * Deletes the specified document.
840    *
841    * <p>This method is a [long-running
842    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
843    * returned `Operation` type has the following method-specific fields:
844    *
845    * <p>- `metadata`:
846    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
847    * `response`: An [Empty
848    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
849    *
850    * <p>Sample code:
851    *
852    * <pre>{@code
853    * // This snippet has been automatically generated and should be regarded as a code template only.
854    * // It will require modifications to work:
855    * // - It may require correct/in-range values for request initialization.
856    * // - It may require specifying regional endpoints when creating the service client as shown in
857    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
858    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
859    *   DocumentName name =
860    *       DocumentName.ofProjectKnowledgeBaseDocumentName(
861    *           "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
862    *   documentsClient.deleteDocumentAsync(name).get();
863    * }
864    * }</pre>
865    *
866    * @param name Required. The name of the document to delete. Format: `projects/&lt;Project
867    *     ID&gt;/locations/&lt;Location ID&gt;/knowledgeBases/&lt;Knowledge Base
868    *     ID&gt;/documents/&lt;Document ID&gt;`.
869    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
870    */
deleteDocumentAsync( DocumentName name)871   public final OperationFuture<Empty, KnowledgeOperationMetadata> deleteDocumentAsync(
872       DocumentName name) {
873     DeleteDocumentRequest request =
874         DeleteDocumentRequest.newBuilder().setName(name == null ? null : name.toString()).build();
875     return deleteDocumentAsync(request);
876   }
877 
878   // AUTO-GENERATED DOCUMENTATION AND METHOD.
879   /**
880    * Deletes the specified document.
881    *
882    * <p>This method is a [long-running
883    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
884    * returned `Operation` type has the following method-specific fields:
885    *
886    * <p>- `metadata`:
887    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
888    * `response`: An [Empty
889    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
890    *
891    * <p>Sample code:
892    *
893    * <pre>{@code
894    * // This snippet has been automatically generated and should be regarded as a code template only.
895    * // It will require modifications to work:
896    * // - It may require correct/in-range values for request initialization.
897    * // - It may require specifying regional endpoints when creating the service client as shown in
898    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
899    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
900    *   String name =
901    *       DocumentName.ofProjectKnowledgeBaseDocumentName(
902    *               "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
903    *           .toString();
904    *   documentsClient.deleteDocumentAsync(name).get();
905    * }
906    * }</pre>
907    *
908    * @param name Required. The name of the document to delete. Format: `projects/&lt;Project
909    *     ID&gt;/locations/&lt;Location ID&gt;/knowledgeBases/&lt;Knowledge Base
910    *     ID&gt;/documents/&lt;Document ID&gt;`.
911    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
912    */
deleteDocumentAsync(String name)913   public final OperationFuture<Empty, KnowledgeOperationMetadata> deleteDocumentAsync(String name) {
914     DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder().setName(name).build();
915     return deleteDocumentAsync(request);
916   }
917 
918   // AUTO-GENERATED DOCUMENTATION AND METHOD.
919   /**
920    * Deletes the specified document.
921    *
922    * <p>This method is a [long-running
923    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
924    * returned `Operation` type has the following method-specific fields:
925    *
926    * <p>- `metadata`:
927    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
928    * `response`: An [Empty
929    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
930    *
931    * <p>Sample code:
932    *
933    * <pre>{@code
934    * // This snippet has been automatically generated and should be regarded as a code template only.
935    * // It will require modifications to work:
936    * // - It may require correct/in-range values for request initialization.
937    * // - It may require specifying regional endpoints when creating the service client as shown in
938    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
939    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
940    *   DeleteDocumentRequest request =
941    *       DeleteDocumentRequest.newBuilder()
942    *           .setName(
943    *               DocumentName.ofProjectKnowledgeBaseDocumentName(
944    *                       "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
945    *                   .toString())
946    *           .build();
947    *   documentsClient.deleteDocumentAsync(request).get();
948    * }
949    * }</pre>
950    *
951    * @param request The request object containing all of the parameters for the API call.
952    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
953    */
deleteDocumentAsync( DeleteDocumentRequest request)954   public final OperationFuture<Empty, KnowledgeOperationMetadata> deleteDocumentAsync(
955       DeleteDocumentRequest request) {
956     return deleteDocumentOperationCallable().futureCall(request);
957   }
958 
959   // AUTO-GENERATED DOCUMENTATION AND METHOD.
960   /**
961    * Deletes the specified document.
962    *
963    * <p>This method is a [long-running
964    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
965    * returned `Operation` type has the following method-specific fields:
966    *
967    * <p>- `metadata`:
968    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
969    * `response`: An [Empty
970    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
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 (DocumentsClient documentsClient = DocumentsClient.create()) {
981    *   DeleteDocumentRequest request =
982    *       DeleteDocumentRequest.newBuilder()
983    *           .setName(
984    *               DocumentName.ofProjectKnowledgeBaseDocumentName(
985    *                       "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
986    *                   .toString())
987    *           .build();
988    *   OperationFuture<Empty, KnowledgeOperationMetadata> future =
989    *       documentsClient.deleteDocumentOperationCallable().futureCall(request);
990    *   // Do something.
991    *   future.get();
992    * }
993    * }</pre>
994    */
995   public final OperationCallable<DeleteDocumentRequest, Empty, KnowledgeOperationMetadata>
deleteDocumentOperationCallable()996       deleteDocumentOperationCallable() {
997     return stub.deleteDocumentOperationCallable();
998   }
999 
1000   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1001   /**
1002    * Deletes the specified document.
1003    *
1004    * <p>This method is a [long-running
1005    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1006    * returned `Operation` type has the following method-specific fields:
1007    *
1008    * <p>- `metadata`:
1009    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1010    * `response`: An [Empty
1011    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
1012    *
1013    * <p>Sample code:
1014    *
1015    * <pre>{@code
1016    * // This snippet has been automatically generated and should be regarded as a code template only.
1017    * // It will require modifications to work:
1018    * // - It may require correct/in-range values for request initialization.
1019    * // - It may require specifying regional endpoints when creating the service client as shown in
1020    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1021    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1022    *   DeleteDocumentRequest request =
1023    *       DeleteDocumentRequest.newBuilder()
1024    *           .setName(
1025    *               DocumentName.ofProjectKnowledgeBaseDocumentName(
1026    *                       "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
1027    *                   .toString())
1028    *           .build();
1029    *   ApiFuture<Operation> future = documentsClient.deleteDocumentCallable().futureCall(request);
1030    *   // Do something.
1031    *   future.get();
1032    * }
1033    * }</pre>
1034    */
deleteDocumentCallable()1035   public final UnaryCallable<DeleteDocumentRequest, Operation> deleteDocumentCallable() {
1036     return stub.deleteDocumentCallable();
1037   }
1038 
1039   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1040   /**
1041    * Updates the specified document.
1042    *
1043    * <p>This method is a [long-running
1044    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1045    * returned `Operation` type has the following method-specific fields:
1046    *
1047    * <p>- `metadata`:
1048    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1049    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1050    *
1051    * <p>Sample code:
1052    *
1053    * <pre>{@code
1054    * // This snippet has been automatically generated and should be regarded as a code template only.
1055    * // It will require modifications to work:
1056    * // - It may require correct/in-range values for request initialization.
1057    * // - It may require specifying regional endpoints when creating the service client as shown in
1058    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1059    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1060    *   Document document = Document.newBuilder().build();
1061    *   FieldMask updateMask = FieldMask.newBuilder().build();
1062    *   Document response = documentsClient.updateDocumentAsync(document, updateMask).get();
1063    * }
1064    * }</pre>
1065    *
1066    * @param document Required. The document to update.
1067    * @param updateMask Optional. Not specified means `update all`. Currently, only `display_name`
1068    *     can be updated, an InvalidArgument will be returned for attempting to update other fields.
1069    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1070    */
updateDocumentAsync( Document document, FieldMask updateMask)1071   public final OperationFuture<Document, KnowledgeOperationMetadata> updateDocumentAsync(
1072       Document document, FieldMask updateMask) {
1073     UpdateDocumentRequest request =
1074         UpdateDocumentRequest.newBuilder().setDocument(document).setUpdateMask(updateMask).build();
1075     return updateDocumentAsync(request);
1076   }
1077 
1078   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1079   /**
1080    * Updates the specified document.
1081    *
1082    * <p>This method is a [long-running
1083    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1084    * returned `Operation` type has the following method-specific fields:
1085    *
1086    * <p>- `metadata`:
1087    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1088    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1089    *
1090    * <p>Sample code:
1091    *
1092    * <pre>{@code
1093    * // This snippet has been automatically generated and should be regarded as a code template only.
1094    * // It will require modifications to work:
1095    * // - It may require correct/in-range values for request initialization.
1096    * // - It may require specifying regional endpoints when creating the service client as shown in
1097    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1098    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1099    *   UpdateDocumentRequest request =
1100    *       UpdateDocumentRequest.newBuilder()
1101    *           .setDocument(Document.newBuilder().build())
1102    *           .setUpdateMask(FieldMask.newBuilder().build())
1103    *           .build();
1104    *   Document response = documentsClient.updateDocumentAsync(request).get();
1105    * }
1106    * }</pre>
1107    *
1108    * @param request The request object containing all of the parameters for the API call.
1109    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1110    */
updateDocumentAsync( UpdateDocumentRequest request)1111   public final OperationFuture<Document, KnowledgeOperationMetadata> updateDocumentAsync(
1112       UpdateDocumentRequest request) {
1113     return updateDocumentOperationCallable().futureCall(request);
1114   }
1115 
1116   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1117   /**
1118    * Updates the specified document.
1119    *
1120    * <p>This method is a [long-running
1121    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1122    * returned `Operation` type has the following method-specific fields:
1123    *
1124    * <p>- `metadata`:
1125    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1126    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1127    *
1128    * <p>Sample code:
1129    *
1130    * <pre>{@code
1131    * // This snippet has been automatically generated and should be regarded as a code template only.
1132    * // It will require modifications to work:
1133    * // - It may require correct/in-range values for request initialization.
1134    * // - It may require specifying regional endpoints when creating the service client as shown in
1135    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1136    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1137    *   UpdateDocumentRequest request =
1138    *       UpdateDocumentRequest.newBuilder()
1139    *           .setDocument(Document.newBuilder().build())
1140    *           .setUpdateMask(FieldMask.newBuilder().build())
1141    *           .build();
1142    *   OperationFuture<Document, KnowledgeOperationMetadata> future =
1143    *       documentsClient.updateDocumentOperationCallable().futureCall(request);
1144    *   // Do something.
1145    *   Document response = future.get();
1146    * }
1147    * }</pre>
1148    */
1149   public final OperationCallable<UpdateDocumentRequest, Document, KnowledgeOperationMetadata>
updateDocumentOperationCallable()1150       updateDocumentOperationCallable() {
1151     return stub.updateDocumentOperationCallable();
1152   }
1153 
1154   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1155   /**
1156    * Updates the specified document.
1157    *
1158    * <p>This method is a [long-running
1159    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1160    * returned `Operation` type has the following method-specific fields:
1161    *
1162    * <p>- `metadata`:
1163    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1164    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1165    *
1166    * <p>Sample code:
1167    *
1168    * <pre>{@code
1169    * // This snippet has been automatically generated and should be regarded as a code template only.
1170    * // It will require modifications to work:
1171    * // - It may require correct/in-range values for request initialization.
1172    * // - It may require specifying regional endpoints when creating the service client as shown in
1173    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1174    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1175    *   UpdateDocumentRequest request =
1176    *       UpdateDocumentRequest.newBuilder()
1177    *           .setDocument(Document.newBuilder().build())
1178    *           .setUpdateMask(FieldMask.newBuilder().build())
1179    *           .build();
1180    *   ApiFuture<Operation> future = documentsClient.updateDocumentCallable().futureCall(request);
1181    *   // Do something.
1182    *   Operation response = future.get();
1183    * }
1184    * }</pre>
1185    */
updateDocumentCallable()1186   public final UnaryCallable<UpdateDocumentRequest, Operation> updateDocumentCallable() {
1187     return stub.updateDocumentCallable();
1188   }
1189 
1190   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1191   /**
1192    * Reloads the specified document from its specified source, content_uri or content. The
1193    * previously loaded content of the document will be deleted. Note: Even when the content of the
1194    * document has not changed, there still may be side effects because of internal implementation
1195    * changes.
1196    *
1197    * <p>This method is a [long-running
1198    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1199    * returned `Operation` type has the following method-specific fields:
1200    *
1201    * <p>- `metadata`:
1202    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1203    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1204    *
1205    * <p>Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; only use
1206    * `projects.knowledgeBases.documents`.
1207    *
1208    * <p>Sample code:
1209    *
1210    * <pre>{@code
1211    * // This snippet has been automatically generated and should be regarded as a code template only.
1212    * // It will require modifications to work:
1213    * // - It may require correct/in-range values for request initialization.
1214    * // - It may require specifying regional endpoints when creating the service client as shown in
1215    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1216    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1217    *   DocumentName name =
1218    *       DocumentName.ofProjectKnowledgeBaseDocumentName(
1219    *           "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
1220    *   String contentUri = "contentUri264542771";
1221    *   Document response = documentsClient.reloadDocumentAsync(name, contentUri).get();
1222    * }
1223    * }</pre>
1224    *
1225    * @param name Required. The name of the document to reload. Format: `projects/&lt;Project
1226    *     ID&gt;/locations/&lt;Location ID&gt;/knowledgeBases/&lt;Knowledge Base
1227    *     ID&gt;/documents/&lt;Document ID&gt;`
1228    * @param contentUri Optional. The path of gcs source file for reloading document content. For
1229    *     now, only gcs uri is supported.
1230    *     <p>For documents stored in Google Cloud Storage, these URIs must have the form
1231    *     `gs://&lt;bucket-name&gt;/&lt;object-name&gt;`.
1232    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1233    */
reloadDocumentAsync( DocumentName name, String contentUri)1234   public final OperationFuture<Document, KnowledgeOperationMetadata> reloadDocumentAsync(
1235       DocumentName name, String contentUri) {
1236     ReloadDocumentRequest request =
1237         ReloadDocumentRequest.newBuilder()
1238             .setName(name == null ? null : name.toString())
1239             .setContentUri(contentUri)
1240             .build();
1241     return reloadDocumentAsync(request);
1242   }
1243 
1244   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1245   /**
1246    * Reloads the specified document from its specified source, content_uri or content. The
1247    * previously loaded content of the document will be deleted. Note: Even when the content of the
1248    * document has not changed, there still may be side effects because of internal implementation
1249    * changes.
1250    *
1251    * <p>This method is a [long-running
1252    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1253    * returned `Operation` type has the following method-specific fields:
1254    *
1255    * <p>- `metadata`:
1256    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1257    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1258    *
1259    * <p>Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; only use
1260    * `projects.knowledgeBases.documents`.
1261    *
1262    * <p>Sample code:
1263    *
1264    * <pre>{@code
1265    * // This snippet has been automatically generated and should be regarded as a code template only.
1266    * // It will require modifications to work:
1267    * // - It may require correct/in-range values for request initialization.
1268    * // - It may require specifying regional endpoints when creating the service client as shown in
1269    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1270    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1271    *   String name =
1272    *       DocumentName.ofProjectKnowledgeBaseDocumentName(
1273    *               "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
1274    *           .toString();
1275    *   String contentUri = "contentUri264542771";
1276    *   Document response = documentsClient.reloadDocumentAsync(name, contentUri).get();
1277    * }
1278    * }</pre>
1279    *
1280    * @param name Required. The name of the document to reload. Format: `projects/&lt;Project
1281    *     ID&gt;/locations/&lt;Location ID&gt;/knowledgeBases/&lt;Knowledge Base
1282    *     ID&gt;/documents/&lt;Document ID&gt;`
1283    * @param contentUri Optional. The path of gcs source file for reloading document content. For
1284    *     now, only gcs uri is supported.
1285    *     <p>For documents stored in Google Cloud Storage, these URIs must have the form
1286    *     `gs://&lt;bucket-name&gt;/&lt;object-name&gt;`.
1287    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1288    */
reloadDocumentAsync( String name, String contentUri)1289   public final OperationFuture<Document, KnowledgeOperationMetadata> reloadDocumentAsync(
1290       String name, String contentUri) {
1291     ReloadDocumentRequest request =
1292         ReloadDocumentRequest.newBuilder().setName(name).setContentUri(contentUri).build();
1293     return reloadDocumentAsync(request);
1294   }
1295 
1296   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1297   /**
1298    * Reloads the specified document from its specified source, content_uri or content. The
1299    * previously loaded content of the document will be deleted. Note: Even when the content of the
1300    * document has not changed, there still may be side effects because of internal implementation
1301    * changes.
1302    *
1303    * <p>This method is a [long-running
1304    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1305    * returned `Operation` type has the following method-specific fields:
1306    *
1307    * <p>- `metadata`:
1308    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1309    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1310    *
1311    * <p>Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; only use
1312    * `projects.knowledgeBases.documents`.
1313    *
1314    * <p>Sample code:
1315    *
1316    * <pre>{@code
1317    * // This snippet has been automatically generated and should be regarded as a code template only.
1318    * // It will require modifications to work:
1319    * // - It may require correct/in-range values for request initialization.
1320    * // - It may require specifying regional endpoints when creating the service client as shown in
1321    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1322    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1323    *   ReloadDocumentRequest request =
1324    *       ReloadDocumentRequest.newBuilder()
1325    *           .setName(
1326    *               DocumentName.ofProjectKnowledgeBaseDocumentName(
1327    *                       "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
1328    *                   .toString())
1329    *           .setImportGcsCustomMetadata(true)
1330    *           .setSmartMessagingPartialUpdate(true)
1331    *           .build();
1332    *   Document response = documentsClient.reloadDocumentAsync(request).get();
1333    * }
1334    * }</pre>
1335    *
1336    * @param request The request object containing all of the parameters for the API call.
1337    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1338    */
reloadDocumentAsync( ReloadDocumentRequest request)1339   public final OperationFuture<Document, KnowledgeOperationMetadata> reloadDocumentAsync(
1340       ReloadDocumentRequest request) {
1341     return reloadDocumentOperationCallable().futureCall(request);
1342   }
1343 
1344   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1345   /**
1346    * Reloads the specified document from its specified source, content_uri or content. The
1347    * previously loaded content of the document will be deleted. Note: Even when the content of the
1348    * document has not changed, there still may be side effects because of internal implementation
1349    * changes.
1350    *
1351    * <p>This method is a [long-running
1352    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1353    * returned `Operation` type has the following method-specific fields:
1354    *
1355    * <p>- `metadata`:
1356    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1357    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1358    *
1359    * <p>Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; only use
1360    * `projects.knowledgeBases.documents`.
1361    *
1362    * <p>Sample code:
1363    *
1364    * <pre>{@code
1365    * // This snippet has been automatically generated and should be regarded as a code template only.
1366    * // It will require modifications to work:
1367    * // - It may require correct/in-range values for request initialization.
1368    * // - It may require specifying regional endpoints when creating the service client as shown in
1369    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1370    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1371    *   ReloadDocumentRequest request =
1372    *       ReloadDocumentRequest.newBuilder()
1373    *           .setName(
1374    *               DocumentName.ofProjectKnowledgeBaseDocumentName(
1375    *                       "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
1376    *                   .toString())
1377    *           .setImportGcsCustomMetadata(true)
1378    *           .setSmartMessagingPartialUpdate(true)
1379    *           .build();
1380    *   OperationFuture<Document, KnowledgeOperationMetadata> future =
1381    *       documentsClient.reloadDocumentOperationCallable().futureCall(request);
1382    *   // Do something.
1383    *   Document response = future.get();
1384    * }
1385    * }</pre>
1386    */
1387   public final OperationCallable<ReloadDocumentRequest, Document, KnowledgeOperationMetadata>
reloadDocumentOperationCallable()1388       reloadDocumentOperationCallable() {
1389     return stub.reloadDocumentOperationCallable();
1390   }
1391 
1392   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1393   /**
1394    * Reloads the specified document from its specified source, content_uri or content. The
1395    * previously loaded content of the document will be deleted. Note: Even when the content of the
1396    * document has not changed, there still may be side effects because of internal implementation
1397    * changes.
1398    *
1399    * <p>This method is a [long-running
1400    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1401    * returned `Operation` type has the following method-specific fields:
1402    *
1403    * <p>- `metadata`:
1404    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1405    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1406    *
1407    * <p>Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; only use
1408    * `projects.knowledgeBases.documents`.
1409    *
1410    * <p>Sample code:
1411    *
1412    * <pre>{@code
1413    * // This snippet has been automatically generated and should be regarded as a code template only.
1414    * // It will require modifications to work:
1415    * // - It may require correct/in-range values for request initialization.
1416    * // - It may require specifying regional endpoints when creating the service client as shown in
1417    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1418    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1419    *   ReloadDocumentRequest request =
1420    *       ReloadDocumentRequest.newBuilder()
1421    *           .setName(
1422    *               DocumentName.ofProjectKnowledgeBaseDocumentName(
1423    *                       "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
1424    *                   .toString())
1425    *           .setImportGcsCustomMetadata(true)
1426    *           .setSmartMessagingPartialUpdate(true)
1427    *           .build();
1428    *   ApiFuture<Operation> future = documentsClient.reloadDocumentCallable().futureCall(request);
1429    *   // Do something.
1430    *   Operation response = future.get();
1431    * }
1432    * }</pre>
1433    */
reloadDocumentCallable()1434   public final UnaryCallable<ReloadDocumentRequest, Operation> reloadDocumentCallable() {
1435     return stub.reloadDocumentCallable();
1436   }
1437 
1438   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1439   /**
1440    * Exports a smart messaging candidate document into the specified destination.
1441    *
1442    * <p>This method is a [long-running
1443    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1444    * returned `Operation` type has the following method-specific fields:
1445    *
1446    * <p>- `metadata`:
1447    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1448    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1449    *
1450    * <p>Sample code:
1451    *
1452    * <pre>{@code
1453    * // This snippet has been automatically generated and should be regarded as a code template only.
1454    * // It will require modifications to work:
1455    * // - It may require correct/in-range values for request initialization.
1456    * // - It may require specifying regional endpoints when creating the service client as shown in
1457    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1458    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1459    *   ExportDocumentRequest request =
1460    *       ExportDocumentRequest.newBuilder()
1461    *           .setName(
1462    *               DocumentName.ofProjectKnowledgeBaseDocumentName(
1463    *                       "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
1464    *                   .toString())
1465    *           .setExportFullContent(true)
1466    *           .setSmartMessagingPartialUpdate(true)
1467    *           .build();
1468    *   Document response = documentsClient.exportDocumentAsync(request).get();
1469    * }
1470    * }</pre>
1471    *
1472    * @param request The request object containing all of the parameters for the API call.
1473    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1474    */
exportDocumentAsync( ExportDocumentRequest request)1475   public final OperationFuture<Document, KnowledgeOperationMetadata> exportDocumentAsync(
1476       ExportDocumentRequest request) {
1477     return exportDocumentOperationCallable().futureCall(request);
1478   }
1479 
1480   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1481   /**
1482    * Exports a smart messaging candidate document into the specified destination.
1483    *
1484    * <p>This method is a [long-running
1485    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1486    * returned `Operation` type has the following method-specific fields:
1487    *
1488    * <p>- `metadata`:
1489    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1490    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1491    *
1492    * <p>Sample code:
1493    *
1494    * <pre>{@code
1495    * // This snippet has been automatically generated and should be regarded as a code template only.
1496    * // It will require modifications to work:
1497    * // - It may require correct/in-range values for request initialization.
1498    * // - It may require specifying regional endpoints when creating the service client as shown in
1499    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1500    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1501    *   ExportDocumentRequest request =
1502    *       ExportDocumentRequest.newBuilder()
1503    *           .setName(
1504    *               DocumentName.ofProjectKnowledgeBaseDocumentName(
1505    *                       "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
1506    *                   .toString())
1507    *           .setExportFullContent(true)
1508    *           .setSmartMessagingPartialUpdate(true)
1509    *           .build();
1510    *   OperationFuture<Document, KnowledgeOperationMetadata> future =
1511    *       documentsClient.exportDocumentOperationCallable().futureCall(request);
1512    *   // Do something.
1513    *   Document response = future.get();
1514    * }
1515    * }</pre>
1516    */
1517   public final OperationCallable<ExportDocumentRequest, Document, KnowledgeOperationMetadata>
exportDocumentOperationCallable()1518       exportDocumentOperationCallable() {
1519     return stub.exportDocumentOperationCallable();
1520   }
1521 
1522   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1523   /**
1524    * Exports a smart messaging candidate document into the specified destination.
1525    *
1526    * <p>This method is a [long-running
1527    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1528    * returned `Operation` type has the following method-specific fields:
1529    *
1530    * <p>- `metadata`:
1531    * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] -
1532    * `response`: [Document][google.cloud.dialogflow.v2.Document]
1533    *
1534    * <p>Sample code:
1535    *
1536    * <pre>{@code
1537    * // This snippet has been automatically generated and should be regarded as a code template only.
1538    * // It will require modifications to work:
1539    * // - It may require correct/in-range values for request initialization.
1540    * // - It may require specifying regional endpoints when creating the service client as shown in
1541    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1542    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1543    *   ExportDocumentRequest request =
1544    *       ExportDocumentRequest.newBuilder()
1545    *           .setName(
1546    *               DocumentName.ofProjectKnowledgeBaseDocumentName(
1547    *                       "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
1548    *                   .toString())
1549    *           .setExportFullContent(true)
1550    *           .setSmartMessagingPartialUpdate(true)
1551    *           .build();
1552    *   ApiFuture<Operation> future = documentsClient.exportDocumentCallable().futureCall(request);
1553    *   // Do something.
1554    *   Operation response = future.get();
1555    * }
1556    * }</pre>
1557    */
exportDocumentCallable()1558   public final UnaryCallable<ExportDocumentRequest, Operation> exportDocumentCallable() {
1559     return stub.exportDocumentCallable();
1560   }
1561 
1562   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1563   /**
1564    * Lists information about the supported locations for this service.
1565    *
1566    * <p>Sample code:
1567    *
1568    * <pre>{@code
1569    * // This snippet has been automatically generated and should be regarded as a code template only.
1570    * // It will require modifications to work:
1571    * // - It may require correct/in-range values for request initialization.
1572    * // - It may require specifying regional endpoints when creating the service client as shown in
1573    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1574    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1575    *   ListLocationsRequest request =
1576    *       ListLocationsRequest.newBuilder()
1577    *           .setName("name3373707")
1578    *           .setFilter("filter-1274492040")
1579    *           .setPageSize(883849137)
1580    *           .setPageToken("pageToken873572522")
1581    *           .build();
1582    *   for (Location element : documentsClient.listLocations(request).iterateAll()) {
1583    *     // doThingsWith(element);
1584    *   }
1585    * }
1586    * }</pre>
1587    *
1588    * @param request The request object containing all of the parameters for the API call.
1589    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1590    */
listLocations(ListLocationsRequest request)1591   public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
1592     return listLocationsPagedCallable().call(request);
1593   }
1594 
1595   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1596   /**
1597    * Lists information about the supported locations for this service.
1598    *
1599    * <p>Sample code:
1600    *
1601    * <pre>{@code
1602    * // This snippet has been automatically generated and should be regarded as a code template only.
1603    * // It will require modifications to work:
1604    * // - It may require correct/in-range values for request initialization.
1605    * // - It may require specifying regional endpoints when creating the service client as shown in
1606    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1607    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1608    *   ListLocationsRequest request =
1609    *       ListLocationsRequest.newBuilder()
1610    *           .setName("name3373707")
1611    *           .setFilter("filter-1274492040")
1612    *           .setPageSize(883849137)
1613    *           .setPageToken("pageToken873572522")
1614    *           .build();
1615    *   ApiFuture<Location> future = documentsClient.listLocationsPagedCallable().futureCall(request);
1616    *   // Do something.
1617    *   for (Location element : future.get().iterateAll()) {
1618    *     // doThingsWith(element);
1619    *   }
1620    * }
1621    * }</pre>
1622    */
1623   public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable()1624       listLocationsPagedCallable() {
1625     return stub.listLocationsPagedCallable();
1626   }
1627 
1628   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1629   /**
1630    * Lists information about the supported locations for this service.
1631    *
1632    * <p>Sample code:
1633    *
1634    * <pre>{@code
1635    * // This snippet has been automatically generated and should be regarded as a code template only.
1636    * // It will require modifications to work:
1637    * // - It may require correct/in-range values for request initialization.
1638    * // - It may require specifying regional endpoints when creating the service client as shown in
1639    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1640    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1641    *   ListLocationsRequest request =
1642    *       ListLocationsRequest.newBuilder()
1643    *           .setName("name3373707")
1644    *           .setFilter("filter-1274492040")
1645    *           .setPageSize(883849137)
1646    *           .setPageToken("pageToken873572522")
1647    *           .build();
1648    *   while (true) {
1649    *     ListLocationsResponse response = documentsClient.listLocationsCallable().call(request);
1650    *     for (Location element : response.getLocationsList()) {
1651    *       // doThingsWith(element);
1652    *     }
1653    *     String nextPageToken = response.getNextPageToken();
1654    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
1655    *       request = request.toBuilder().setPageToken(nextPageToken).build();
1656    *     } else {
1657    *       break;
1658    *     }
1659    *   }
1660    * }
1661    * }</pre>
1662    */
listLocationsCallable()1663   public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
1664     return stub.listLocationsCallable();
1665   }
1666 
1667   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1668   /**
1669    * Gets information about a location.
1670    *
1671    * <p>Sample code:
1672    *
1673    * <pre>{@code
1674    * // This snippet has been automatically generated and should be regarded as a code template only.
1675    * // It will require modifications to work:
1676    * // - It may require correct/in-range values for request initialization.
1677    * // - It may require specifying regional endpoints when creating the service client as shown in
1678    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1679    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1680    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
1681    *   Location response = documentsClient.getLocation(request);
1682    * }
1683    * }</pre>
1684    *
1685    * @param request The request object containing all of the parameters for the API call.
1686    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1687    */
getLocation(GetLocationRequest request)1688   public final Location getLocation(GetLocationRequest request) {
1689     return getLocationCallable().call(request);
1690   }
1691 
1692   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1693   /**
1694    * Gets information about a location.
1695    *
1696    * <p>Sample code:
1697    *
1698    * <pre>{@code
1699    * // This snippet has been automatically generated and should be regarded as a code template only.
1700    * // It will require modifications to work:
1701    * // - It may require correct/in-range values for request initialization.
1702    * // - It may require specifying regional endpoints when creating the service client as shown in
1703    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1704    * try (DocumentsClient documentsClient = DocumentsClient.create()) {
1705    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
1706    *   ApiFuture<Location> future = documentsClient.getLocationCallable().futureCall(request);
1707    *   // Do something.
1708    *   Location response = future.get();
1709    * }
1710    * }</pre>
1711    */
getLocationCallable()1712   public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() {
1713     return stub.getLocationCallable();
1714   }
1715 
1716   @Override
close()1717   public final void close() {
1718     stub.close();
1719   }
1720 
1721   @Override
shutdown()1722   public void shutdown() {
1723     stub.shutdown();
1724   }
1725 
1726   @Override
isShutdown()1727   public boolean isShutdown() {
1728     return stub.isShutdown();
1729   }
1730 
1731   @Override
isTerminated()1732   public boolean isTerminated() {
1733     return stub.isTerminated();
1734   }
1735 
1736   @Override
shutdownNow()1737   public void shutdownNow() {
1738     stub.shutdownNow();
1739   }
1740 
1741   @Override
awaitTermination(long duration, TimeUnit unit)1742   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
1743     return stub.awaitTermination(duration, unit);
1744   }
1745 
1746   public static class ListDocumentsPagedResponse
1747       extends AbstractPagedListResponse<
1748           ListDocumentsRequest,
1749           ListDocumentsResponse,
1750           Document,
1751           ListDocumentsPage,
1752           ListDocumentsFixedSizeCollection> {
1753 
createAsync( PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context, ApiFuture<ListDocumentsResponse> futureResponse)1754     public static ApiFuture<ListDocumentsPagedResponse> createAsync(
1755         PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context,
1756         ApiFuture<ListDocumentsResponse> futureResponse) {
1757       ApiFuture<ListDocumentsPage> futurePage =
1758           ListDocumentsPage.createEmptyPage().createPageAsync(context, futureResponse);
1759       return ApiFutures.transform(
1760           futurePage,
1761           input -> new ListDocumentsPagedResponse(input),
1762           MoreExecutors.directExecutor());
1763     }
1764 
ListDocumentsPagedResponse(ListDocumentsPage page)1765     private ListDocumentsPagedResponse(ListDocumentsPage page) {
1766       super(page, ListDocumentsFixedSizeCollection.createEmptyCollection());
1767     }
1768   }
1769 
1770   public static class ListDocumentsPage
1771       extends AbstractPage<
1772           ListDocumentsRequest, ListDocumentsResponse, Document, ListDocumentsPage> {
1773 
ListDocumentsPage( PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context, ListDocumentsResponse response)1774     private ListDocumentsPage(
1775         PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context,
1776         ListDocumentsResponse response) {
1777       super(context, response);
1778     }
1779 
createEmptyPage()1780     private static ListDocumentsPage createEmptyPage() {
1781       return new ListDocumentsPage(null, null);
1782     }
1783 
1784     @Override
createPage( PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context, ListDocumentsResponse response)1785     protected ListDocumentsPage createPage(
1786         PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context,
1787         ListDocumentsResponse response) {
1788       return new ListDocumentsPage(context, response);
1789     }
1790 
1791     @Override
createPageAsync( PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context, ApiFuture<ListDocumentsResponse> futureResponse)1792     public ApiFuture<ListDocumentsPage> createPageAsync(
1793         PageContext<ListDocumentsRequest, ListDocumentsResponse, Document> context,
1794         ApiFuture<ListDocumentsResponse> futureResponse) {
1795       return super.createPageAsync(context, futureResponse);
1796     }
1797   }
1798 
1799   public static class ListDocumentsFixedSizeCollection
1800       extends AbstractFixedSizeCollection<
1801           ListDocumentsRequest,
1802           ListDocumentsResponse,
1803           Document,
1804           ListDocumentsPage,
1805           ListDocumentsFixedSizeCollection> {
1806 
ListDocumentsFixedSizeCollection(List<ListDocumentsPage> pages, int collectionSize)1807     private ListDocumentsFixedSizeCollection(List<ListDocumentsPage> pages, int collectionSize) {
1808       super(pages, collectionSize);
1809     }
1810 
createEmptyCollection()1811     private static ListDocumentsFixedSizeCollection createEmptyCollection() {
1812       return new ListDocumentsFixedSizeCollection(null, 0);
1813     }
1814 
1815     @Override
createCollection( List<ListDocumentsPage> pages, int collectionSize)1816     protected ListDocumentsFixedSizeCollection createCollection(
1817         List<ListDocumentsPage> pages, int collectionSize) {
1818       return new ListDocumentsFixedSizeCollection(pages, collectionSize);
1819     }
1820   }
1821 
1822   public static class ListLocationsPagedResponse
1823       extends AbstractPagedListResponse<
1824           ListLocationsRequest,
1825           ListLocationsResponse,
1826           Location,
1827           ListLocationsPage,
1828           ListLocationsFixedSizeCollection> {
1829 
createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1830     public static ApiFuture<ListLocationsPagedResponse> createAsync(
1831         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1832         ApiFuture<ListLocationsResponse> futureResponse) {
1833       ApiFuture<ListLocationsPage> futurePage =
1834           ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
1835       return ApiFutures.transform(
1836           futurePage,
1837           input -> new ListLocationsPagedResponse(input),
1838           MoreExecutors.directExecutor());
1839     }
1840 
ListLocationsPagedResponse(ListLocationsPage page)1841     private ListLocationsPagedResponse(ListLocationsPage page) {
1842       super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
1843     }
1844   }
1845 
1846   public static class ListLocationsPage
1847       extends AbstractPage<
1848           ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
1849 
ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1850     private ListLocationsPage(
1851         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1852         ListLocationsResponse response) {
1853       super(context, response);
1854     }
1855 
createEmptyPage()1856     private static ListLocationsPage createEmptyPage() {
1857       return new ListLocationsPage(null, null);
1858     }
1859 
1860     @Override
createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1861     protected ListLocationsPage createPage(
1862         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1863         ListLocationsResponse response) {
1864       return new ListLocationsPage(context, response);
1865     }
1866 
1867     @Override
createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1868     public ApiFuture<ListLocationsPage> createPageAsync(
1869         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1870         ApiFuture<ListLocationsResponse> futureResponse) {
1871       return super.createPageAsync(context, futureResponse);
1872     }
1873   }
1874 
1875   public static class ListLocationsFixedSizeCollection
1876       extends AbstractFixedSizeCollection<
1877           ListLocationsRequest,
1878           ListLocationsResponse,
1879           Location,
1880           ListLocationsPage,
1881           ListLocationsFixedSizeCollection> {
1882 
ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)1883     private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
1884       super(pages, collectionSize);
1885     }
1886 
createEmptyCollection()1887     private static ListLocationsFixedSizeCollection createEmptyCollection() {
1888       return new ListLocationsFixedSizeCollection(null, 0);
1889     }
1890 
1891     @Override
createCollection( List<ListLocationsPage> pages, int collectionSize)1892     protected ListLocationsFixedSizeCollection createCollection(
1893         List<ListLocationsPage> pages, int collectionSize) {
1894       return new ListLocationsFixedSizeCollection(pages, collectionSize);
1895     }
1896   }
1897 }
1898