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