|
16 | 16 |
|
17 | 17 | package com.google.cloud.documentai.v1beta2;
|
18 | 18 |
|
| 19 | +import com.google.api.core.ApiFuture; |
| 20 | +import com.google.api.core.ApiFutures; |
19 | 21 | import com.google.api.core.BetaApi;
|
20 | 22 | import com.google.api.gax.core.BackgroundResource;
|
21 | 23 | import com.google.api.gax.longrunning.OperationFuture;
|
| 24 | +import com.google.api.gax.paging.AbstractFixedSizeCollection; |
| 25 | +import com.google.api.gax.paging.AbstractPage; |
| 26 | +import com.google.api.gax.paging.AbstractPagedListResponse; |
22 | 27 | import com.google.api.gax.rpc.OperationCallable;
|
| 28 | +import com.google.api.gax.rpc.PageContext; |
23 | 29 | import com.google.api.gax.rpc.UnaryCallable;
|
24 | 30 | import com.google.cloud.documentai.v1beta2.stub.DocumentUnderstandingServiceStub;
|
25 | 31 | import com.google.cloud.documentai.v1beta2.stub.DocumentUnderstandingServiceStubSettings;
|
| 32 | +import com.google.cloud.location.GetLocationRequest; |
| 33 | +import com.google.cloud.location.ListLocationsRequest; |
| 34 | +import com.google.cloud.location.ListLocationsResponse; |
| 35 | +import com.google.cloud.location.Location; |
| 36 | +import com.google.common.util.concurrent.MoreExecutors; |
26 | 37 | import com.google.longrunning.Operation;
|
27 | 38 | import com.google.longrunning.OperationsClient;
|
28 | 39 | import java.io.IOException;
|
@@ -393,6 +404,169 @@ public final UnaryCallable<ProcessDocumentRequest, Document> processDocumentCall
|
393 | 404 | return stub.processDocumentCallable();
|
394 | 405 | }
|
395 | 406 |
|
| 407 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 408 | + /** |
| 409 | + * Lists information about the supported locations for this service. |
| 410 | + * |
| 411 | + * <p>Sample code: |
| 412 | + * |
| 413 | + * <pre>{@code |
| 414 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 415 | + * // It will require modifications to work: |
| 416 | + * // - It may require correct/in-range values for request initialization. |
| 417 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 418 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 419 | + * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = |
| 420 | + * DocumentUnderstandingServiceClient.create()) { |
| 421 | + * ListLocationsRequest request = |
| 422 | + * ListLocationsRequest.newBuilder() |
| 423 | + * .setName("name3373707") |
| 424 | + * .setFilter("filter-1274492040") |
| 425 | + * .setPageSize(883849137) |
| 426 | + * .setPageToken("pageToken873572522") |
| 427 | + * .build(); |
| 428 | + * for (Location element : |
| 429 | + * documentUnderstandingServiceClient.listLocations(request).iterateAll()) { |
| 430 | + * // doThingsWith(element); |
| 431 | + * } |
| 432 | + * } |
| 433 | + * }</pre> |
| 434 | + * |
| 435 | + * @param request The request object containing all of the parameters for the API call. |
| 436 | + * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
| 437 | + */ |
| 438 | + public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { |
| 439 | + return listLocationsPagedCallable().call(request); |
| 440 | + } |
| 441 | + |
| 442 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 443 | + /** |
| 444 | + * Lists information about the supported locations for this service. |
| 445 | + * |
| 446 | + * <p>Sample code: |
| 447 | + * |
| 448 | + * <pre>{@code |
| 449 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 450 | + * // It will require modifications to work: |
| 451 | + * // - It may require correct/in-range values for request initialization. |
| 452 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 453 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 454 | + * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = |
| 455 | + * DocumentUnderstandingServiceClient.create()) { |
| 456 | + * ListLocationsRequest request = |
| 457 | + * ListLocationsRequest.newBuilder() |
| 458 | + * .setName("name3373707") |
| 459 | + * .setFilter("filter-1274492040") |
| 460 | + * .setPageSize(883849137) |
| 461 | + * .setPageToken("pageToken873572522") |
| 462 | + * .build(); |
| 463 | + * ApiFuture<Location> future = |
| 464 | + * documentUnderstandingServiceClient.listLocationsPagedCallable().futureCall(request); |
| 465 | + * // Do something. |
| 466 | + * for (Location element : future.get().iterateAll()) { |
| 467 | + * // doThingsWith(element); |
| 468 | + * } |
| 469 | + * } |
| 470 | + * }</pre> |
| 471 | + */ |
| 472 | + public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse> |
| 473 | + listLocationsPagedCallable() { |
| 474 | + return stub.listLocationsPagedCallable(); |
| 475 | + } |
| 476 | + |
| 477 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 478 | + /** |
| 479 | + * Lists information about the supported locations for this service. |
| 480 | + * |
| 481 | + * <p>Sample code: |
| 482 | + * |
| 483 | + * <pre>{@code |
| 484 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 485 | + * // It will require modifications to work: |
| 486 | + * // - It may require correct/in-range values for request initialization. |
| 487 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 488 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 489 | + * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = |
| 490 | + * DocumentUnderstandingServiceClient.create()) { |
| 491 | + * ListLocationsRequest request = |
| 492 | + * ListLocationsRequest.newBuilder() |
| 493 | + * .setName("name3373707") |
| 494 | + * .setFilter("filter-1274492040") |
| 495 | + * .setPageSize(883849137) |
| 496 | + * .setPageToken("pageToken873572522") |
| 497 | + * .build(); |
| 498 | + * while (true) { |
| 499 | + * ListLocationsResponse response = |
| 500 | + * documentUnderstandingServiceClient.listLocationsCallable().call(request); |
| 501 | + * for (Location element : response.getLocationsList()) { |
| 502 | + * // doThingsWith(element); |
| 503 | + * } |
| 504 | + * String nextPageToken = response.getNextPageToken(); |
| 505 | + * if (!Strings.isNullOrEmpty(nextPageToken)) { |
| 506 | + * request = request.toBuilder().setPageToken(nextPageToken).build(); |
| 507 | + * } else { |
| 508 | + * break; |
| 509 | + * } |
| 510 | + * } |
| 511 | + * } |
| 512 | + * }</pre> |
| 513 | + */ |
| 514 | + public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() { |
| 515 | + return stub.listLocationsCallable(); |
| 516 | + } |
| 517 | + |
| 518 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 519 | + /** |
| 520 | + * Gets information about a location. |
| 521 | + * |
| 522 | + * <p>Sample code: |
| 523 | + * |
| 524 | + * <pre>{@code |
| 525 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 526 | + * // It will require modifications to work: |
| 527 | + * // - It may require correct/in-range values for request initialization. |
| 528 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 529 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 530 | + * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = |
| 531 | + * DocumentUnderstandingServiceClient.create()) { |
| 532 | + * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); |
| 533 | + * Location response = documentUnderstandingServiceClient.getLocation(request); |
| 534 | + * } |
| 535 | + * }</pre> |
| 536 | + * |
| 537 | + * @param request The request object containing all of the parameters for the API call. |
| 538 | + * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
| 539 | + */ |
| 540 | + public final Location getLocation(GetLocationRequest request) { |
| 541 | + return getLocationCallable().call(request); |
| 542 | + } |
| 543 | + |
| 544 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 545 | + /** |
| 546 | + * Gets information about a location. |
| 547 | + * |
| 548 | + * <p>Sample code: |
| 549 | + * |
| 550 | + * <pre>{@code |
| 551 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 552 | + * // It will require modifications to work: |
| 553 | + * // - It may require correct/in-range values for request initialization. |
| 554 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 555 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 556 | + * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = |
| 557 | + * DocumentUnderstandingServiceClient.create()) { |
| 558 | + * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); |
| 559 | + * ApiFuture<Location> future = |
| 560 | + * documentUnderstandingServiceClient.getLocationCallable().futureCall(request); |
| 561 | + * // Do something. |
| 562 | + * Location response = future.get(); |
| 563 | + * } |
| 564 | + * }</pre> |
| 565 | + */ |
| 566 | + public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() { |
| 567 | + return stub.getLocationCallable(); |
| 568 | + } |
| 569 | + |
396 | 570 | @Override
|
397 | 571 | public final void close() {
|
398 | 572 | stub.close();
|
@@ -422,4 +596,80 @@ public void shutdownNow() {
|
422 | 596 | public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
|
423 | 597 | return stub.awaitTermination(duration, unit);
|
424 | 598 | }
|
| 599 | + |
| 600 | + public static class ListLocationsPagedResponse |
| 601 | + extends AbstractPagedListResponse< |
| 602 | + ListLocationsRequest, |
| 603 | + ListLocationsResponse, |
| 604 | + Location, |
| 605 | + ListLocationsPage, |
| 606 | + ListLocationsFixedSizeCollection> { |
| 607 | + |
| 608 | + public static ApiFuture<ListLocationsPagedResponse> createAsync( |
| 609 | + PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, |
| 610 | + ApiFuture<ListLocationsResponse> futureResponse) { |
| 611 | + ApiFuture<ListLocationsPage> futurePage = |
| 612 | + ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); |
| 613 | + return ApiFutures.transform( |
| 614 | + futurePage, |
| 615 | + input -> new ListLocationsPagedResponse(input), |
| 616 | + MoreExecutors.directExecutor()); |
| 617 | + } |
| 618 | + |
| 619 | + private ListLocationsPagedResponse(ListLocationsPage page) { |
| 620 | + super(page, ListLocationsFixedSizeCollection.createEmptyCollection()); |
| 621 | + } |
| 622 | + } |
| 623 | + |
| 624 | + public static class ListLocationsPage |
| 625 | + extends AbstractPage< |
| 626 | + ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> { |
| 627 | + |
| 628 | + private ListLocationsPage( |
| 629 | + PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, |
| 630 | + ListLocationsResponse response) { |
| 631 | + super(context, response); |
| 632 | + } |
| 633 | + |
| 634 | + private static ListLocationsPage createEmptyPage() { |
| 635 | + return new ListLocationsPage(null, null); |
| 636 | + } |
| 637 | + |
| 638 | + @Override |
| 639 | + protected ListLocationsPage createPage( |
| 640 | + PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, |
| 641 | + ListLocationsResponse response) { |
| 642 | + return new ListLocationsPage(context, response); |
| 643 | + } |
| 644 | + |
| 645 | + @Override |
| 646 | + public ApiFuture<ListLocationsPage> createPageAsync( |
| 647 | + PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, |
| 648 | + ApiFuture<ListLocationsResponse> futureResponse) { |
| 649 | + return super.createPageAsync(context, futureResponse); |
| 650 | + } |
| 651 | + } |
| 652 | + |
| 653 | + public static class ListLocationsFixedSizeCollection |
| 654 | + extends AbstractFixedSizeCollection< |
| 655 | + ListLocationsRequest, |
| 656 | + ListLocationsResponse, |
| 657 | + Location, |
| 658 | + ListLocationsPage, |
| 659 | + ListLocationsFixedSizeCollection> { |
| 660 | + |
| 661 | + private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) { |
| 662 | + super(pages, collectionSize); |
| 663 | + } |
| 664 | + |
| 665 | + private static ListLocationsFixedSizeCollection createEmptyCollection() { |
| 666 | + return new ListLocationsFixedSizeCollection(null, 0); |
| 667 | + } |
| 668 | + |
| 669 | + @Override |
| 670 | + protected ListLocationsFixedSizeCollection createCollection( |
| 671 | + List<ListLocationsPage> pages, int collectionSize) { |
| 672 | + return new ListLocationsFixedSizeCollection(pages, collectionSize); |
| 673 | + } |
| 674 | + } |
425 | 675 | }
|
0 commit comments