From 9af2813437a96704d1781185fee8b839b4467eee Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 23 Jun 2022 16:16:28 +0000 Subject: [PATCH 1/7] chore(main): release 2.5.3-SNAPSHOT (#842) :robot: I have created a release *beep* *boop* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- google-cloud-document-ai-bom/pom.xml | 20 +++++++++---------- google-cloud-document-ai/pom.xml | 4 ++-- grpc-google-cloud-document-ai-v1/pom.xml | 4 ++-- grpc-google-cloud-document-ai-v1beta1/pom.xml | 4 ++-- grpc-google-cloud-document-ai-v1beta2/pom.xml | 4 ++-- grpc-google-cloud-document-ai-v1beta3/pom.xml | 4 ++-- pom.xml | 20 +++++++++---------- proto-google-cloud-document-ai-v1/pom.xml | 4 ++-- .../pom.xml | 4 ++-- .../pom.xml | 4 ++-- .../pom.xml | 4 ++-- versions.txt | 18 ++++++++--------- 12 files changed, 47 insertions(+), 47 deletions(-) diff --git a/google-cloud-document-ai-bom/pom.xml b/google-cloud-document-ai-bom/pom.xml index 92cfc325..c1e7119f 100644 --- a/google-cloud-document-ai-bom/pom.xml +++ b/google-cloud-document-ai-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-document-ai-bom - 2.5.2 + 2.5.3-SNAPSHOT pom com.google.cloud @@ -50,47 +50,47 @@ com.google.cloud google-cloud-document-ai - 2.5.2 + 2.5.3-SNAPSHOT com.google.api.grpc grpc-google-cloud-document-ai-v1beta1 - 0.17.2 + 0.17.3-SNAPSHOT com.google.api.grpc grpc-google-cloud-document-ai-v1beta2 - 0.17.2 + 0.17.3-SNAPSHOT com.google.api.grpc grpc-google-cloud-document-ai-v1beta3 - 0.17.2 + 0.17.3-SNAPSHOT com.google.api.grpc grpc-google-cloud-document-ai-v1 - 2.5.2 + 2.5.3-SNAPSHOT com.google.api.grpc proto-google-cloud-document-ai-v1beta1 - 0.17.2 + 0.17.3-SNAPSHOT com.google.api.grpc proto-google-cloud-document-ai-v1beta2 - 0.17.2 + 0.17.3-SNAPSHOT com.google.api.grpc proto-google-cloud-document-ai-v1beta3 - 0.17.2 + 0.17.3-SNAPSHOT com.google.api.grpc proto-google-cloud-document-ai-v1 - 2.5.2 + 2.5.3-SNAPSHOT diff --git a/google-cloud-document-ai/pom.xml b/google-cloud-document-ai/pom.xml index 849fc784..34134c7f 100644 --- a/google-cloud-document-ai/pom.xml +++ b/google-cloud-document-ai/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-document-ai - 2.5.2 + 2.5.3-SNAPSHOT jar Google Cloud Document AI https://github.com/googleapis/java-document-ai @@ -11,7 +11,7 @@ com.google.cloud google-cloud-document-ai-parent - 2.5.2 + 2.5.3-SNAPSHOT google-cloud-document-ai diff --git a/grpc-google-cloud-document-ai-v1/pom.xml b/grpc-google-cloud-document-ai-v1/pom.xml index 50743629..87cbd273 100644 --- a/grpc-google-cloud-document-ai-v1/pom.xml +++ b/grpc-google-cloud-document-ai-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-document-ai-v1 - 2.5.2 + 2.5.3-SNAPSHOT grpc-google-cloud-document-ai-v1 GRPC library for google-cloud-document-ai com.google.cloud google-cloud-document-ai-parent - 2.5.2 + 2.5.3-SNAPSHOT diff --git a/grpc-google-cloud-document-ai-v1beta1/pom.xml b/grpc-google-cloud-document-ai-v1beta1/pom.xml index 106fc5ce..9b1d4766 100644 --- a/grpc-google-cloud-document-ai-v1beta1/pom.xml +++ b/grpc-google-cloud-document-ai-v1beta1/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta1 - 0.17.2 + 0.17.3-SNAPSHOT grpc-google-cloud-document-ai-v1beta1 GRPC library for grpc-google-cloud-document-ai-v1beta1 com.google.cloud google-cloud-document-ai-parent - 2.5.2 + 2.5.3-SNAPSHOT diff --git a/grpc-google-cloud-document-ai-v1beta2/pom.xml b/grpc-google-cloud-document-ai-v1beta2/pom.xml index 164b6a91..faabe869 100644 --- a/grpc-google-cloud-document-ai-v1beta2/pom.xml +++ b/grpc-google-cloud-document-ai-v1beta2/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta2 - 0.17.2 + 0.17.3-SNAPSHOT grpc-google-cloud-document-ai-v1beta2 GRPC library for grpc-google-cloud-document-ai-v1beta2 com.google.cloud google-cloud-document-ai-parent - 2.5.2 + 2.5.3-SNAPSHOT diff --git a/grpc-google-cloud-document-ai-v1beta3/pom.xml b/grpc-google-cloud-document-ai-v1beta3/pom.xml index 05f1862d..426d5417 100644 --- a/grpc-google-cloud-document-ai-v1beta3/pom.xml +++ b/grpc-google-cloud-document-ai-v1beta3/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta3 - 0.17.2 + 0.17.3-SNAPSHOT grpc-google-cloud-document-ai-v1beta3 GRPC library for grpc-google-cloud-document-ai-v1beta3 com.google.cloud google-cloud-document-ai-parent - 2.5.2 + 2.5.3-SNAPSHOT diff --git a/pom.xml b/pom.xml index ddb71238..19dc2be5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-document-ai-parent pom - 2.5.2 + 2.5.3-SNAPSHOT Google Cloud Document AI Parent https://github.com/googleapis/java-document-ai @@ -61,47 +61,47 @@ com.google.api.grpc grpc-google-cloud-document-ai-v1beta1 - 0.17.2 + 0.17.3-SNAPSHOT com.google.api.grpc proto-google-cloud-document-ai-v1 - 2.5.2 + 2.5.3-SNAPSHOT com.google.api.grpc grpc-google-cloud-document-ai-v1 - 2.5.2 + 2.5.3-SNAPSHOT com.google.cloud google-cloud-document-ai - 2.5.2 + 2.5.3-SNAPSHOT com.google.api.grpc grpc-google-cloud-document-ai-v1beta2 - 0.17.2 + 0.17.3-SNAPSHOT com.google.api.grpc grpc-google-cloud-document-ai-v1beta3 - 0.17.2 + 0.17.3-SNAPSHOT com.google.api.grpc proto-google-cloud-document-ai-v1beta1 - 0.17.2 + 0.17.3-SNAPSHOT com.google.api.grpc proto-google-cloud-document-ai-v1beta2 - 0.17.2 + 0.17.3-SNAPSHOT com.google.api.grpc proto-google-cloud-document-ai-v1beta3 - 0.17.2 + 0.17.3-SNAPSHOT diff --git a/proto-google-cloud-document-ai-v1/pom.xml b/proto-google-cloud-document-ai-v1/pom.xml index 683188ba..fb6e9f49 100644 --- a/proto-google-cloud-document-ai-v1/pom.xml +++ b/proto-google-cloud-document-ai-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-document-ai-v1 - 2.5.2 + 2.5.3-SNAPSHOT proto-google-cloud-document-ai-v1 Proto library for google-cloud-document-ai com.google.cloud google-cloud-document-ai-parent - 2.5.2 + 2.5.3-SNAPSHOT diff --git a/proto-google-cloud-document-ai-v1beta1/pom.xml b/proto-google-cloud-document-ai-v1beta1/pom.xml index 3b8ce444..8e331de9 100644 --- a/proto-google-cloud-document-ai-v1beta1/pom.xml +++ b/proto-google-cloud-document-ai-v1beta1/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta1 - 0.17.2 + 0.17.3-SNAPSHOT proto-google-cloud-document-ai-v1beta1 PROTO library for proto-google-cloud-document-ai-v1beta1 com.google.cloud google-cloud-document-ai-parent - 2.5.2 + 2.5.3-SNAPSHOT diff --git a/proto-google-cloud-document-ai-v1beta2/pom.xml b/proto-google-cloud-document-ai-v1beta2/pom.xml index 47363971..d6be55e4 100644 --- a/proto-google-cloud-document-ai-v1beta2/pom.xml +++ b/proto-google-cloud-document-ai-v1beta2/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta2 - 0.17.2 + 0.17.3-SNAPSHOT proto-google-cloud-document-ai-v1beta2 PROTO library for proto-google-cloud-document-ai-v1beta2 com.google.cloud google-cloud-document-ai-parent - 2.5.2 + 2.5.3-SNAPSHOT diff --git a/proto-google-cloud-document-ai-v1beta3/pom.xml b/proto-google-cloud-document-ai-v1beta3/pom.xml index d170075c..b712b035 100644 --- a/proto-google-cloud-document-ai-v1beta3/pom.xml +++ b/proto-google-cloud-document-ai-v1beta3/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta3 - 0.17.2 + 0.17.3-SNAPSHOT proto-google-cloud-document-ai-v1beta3 PROTO library for proto-google-cloud-document-ai-v1beta3 com.google.cloud google-cloud-document-ai-parent - 2.5.2 + 2.5.3-SNAPSHOT diff --git a/versions.txt b/versions.txt index 41f08781..1d8fef76 100644 --- a/versions.txt +++ b/versions.txt @@ -1,12 +1,12 @@ # Format: # module:released-version:current-version -google-cloud-document-ai:2.5.2:2.5.2 -grpc-google-cloud-document-ai-v1beta1:0.17.2:0.17.2 -grpc-google-cloud-document-ai-v1beta2:0.17.2:0.17.2 -grpc-google-cloud-document-ai-v1beta3:0.17.2:0.17.2 -grpc-google-cloud-document-ai-v1:2.5.2:2.5.2 -proto-google-cloud-document-ai-v1beta1:0.17.2:0.17.2 -proto-google-cloud-document-ai-v1beta2:0.17.2:0.17.2 -proto-google-cloud-document-ai-v1beta3:0.17.2:0.17.2 -proto-google-cloud-document-ai-v1:2.5.2:2.5.2 +google-cloud-document-ai:2.5.2:2.5.3-SNAPSHOT +grpc-google-cloud-document-ai-v1beta1:0.17.2:0.17.3-SNAPSHOT +grpc-google-cloud-document-ai-v1beta2:0.17.2:0.17.3-SNAPSHOT +grpc-google-cloud-document-ai-v1beta3:0.17.2:0.17.3-SNAPSHOT +grpc-google-cloud-document-ai-v1:2.5.2:2.5.3-SNAPSHOT +proto-google-cloud-document-ai-v1beta1:0.17.2:0.17.3-SNAPSHOT +proto-google-cloud-document-ai-v1beta2:0.17.2:0.17.3-SNAPSHOT +proto-google-cloud-document-ai-v1beta3:0.17.2:0.17.3-SNAPSHOT +proto-google-cloud-document-ai-v1:2.5.2:2.5.3-SNAPSHOT From 59f99a7d47adc63811367dd1225cbbd3139bb430 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 23 Jun 2022 21:12:11 +0000 Subject: [PATCH 2/7] feat: Enable REST transport for most of Java and Go clients (#840) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 456641589 Source-Link: https://github.com/googleapis/googleapis/commit/8a251f5225b789b2383207ffd978f6aa3d77fcf7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 --- README.md | 4 +- google-cloud-document-ai/pom.xml | 16 + .../v1/DocumentProcessorServiceClient.java | 38 +- .../v1/DocumentProcessorServiceSettings.java | 23 +- .../v1/stub/DocumentProcessorServiceStub.java | 6 +- .../DocumentProcessorServiceStubSettings.java | 53 +- ...cumentProcessorServiceCallableFactory.java | 105 +++ .../HttpJsonDocumentProcessorServiceStub.java | 365 ++++++++ .../DocumentProcessorServiceClient.java | 38 +- .../DocumentProcessorServiceSettings.java | 23 +- .../stub/DocumentProcessorServiceStub.java | 6 +- .../DocumentProcessorServiceStubSettings.java | 53 +- ...cumentProcessorServiceCallableFactory.java | 105 +++ .../HttpJsonDocumentProcessorServiceStub.java | 765 ++++++++++++++++ ...entProcessorServiceClientHttpJsonTest.java | 356 ++++++++ ...entProcessorServiceClientHttpJsonTest.java | 851 ++++++++++++++++++ .../AsyncBatchProcessDocuments.java | 53 ++ .../AsyncBatchProcessDocumentsLRO.java | 56 ++ .../SyncBatchProcessDocuments.java | 50 + ...yncBatchProcessDocumentsProcessorname.java | 41 + .../SyncBatchProcessDocumentsString.java | 41 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../processdocument/AsyncProcessDocument.java | 49 + .../processdocument/SyncProcessDocument.java | 45 + .../SyncProcessDocumentProcessorname.java | 40 + .../SyncProcessDocumentString.java | 40 + .../reviewdocument/AsyncReviewDocument.java | 50 + .../AsyncReviewDocumentLRO.java | 51 ++ .../reviewdocument/SyncReviewDocument.java | 47 + ...ncReviewDocumentHumanreviewconfigname.java | 42 + .../SyncReviewDocumentString.java | 42 + .../processdocument/SyncProcessDocument.java | 47 + .../processdocument/SyncProcessDocument.java | 47 + .../AsyncBatchProcessDocuments.java | 50 + .../AsyncBatchProcessDocumentsLRO.java | 53 ++ .../SyncBatchProcessDocuments.java | 47 + ...ssDocumentsListprocessdocumentrequest.java | 43 + .../SyncCreateSetCredentialsProvider.java | 42 + .../create/SyncCreateSetEndpoint.java | 39 + .../SyncBatchProcessDocuments.java | 47 + .../SyncBatchProcessDocuments.java | 47 + .../AsyncBatchProcessDocuments.java | 50 + .../AsyncBatchProcessDocumentsLRO.java | 53 ++ .../SyncBatchProcessDocuments.java | 47 + ...ssDocumentsListprocessdocumentrequest.java | 43 + .../SyncCreateSetCredentialsProvider.java | 42 + .../create/SyncCreateSetEndpoint.java | 39 + .../processdocument/AsyncProcessDocument.java | 62 ++ .../processdocument/SyncProcessDocument.java | 58 ++ .../processdocument/SyncProcessDocument.java | 47 + .../processdocument/SyncProcessDocument.java | 47 + .../AsyncBatchProcessDocuments.java | 56 ++ .../AsyncBatchProcessDocumentsLRO.java | 59 ++ .../SyncBatchProcessDocuments.java | 53 ++ ...yncBatchProcessDocumentsProcessorname.java | 41 + .../SyncBatchProcessDocumentsString.java | 41 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../createprocessor/AsyncCreateProcessor.java | 49 + .../createprocessor/SyncCreateProcessor.java | 45 + ...cCreateProcessorLocationnameProcessor.java | 41 + .../SyncCreateProcessorStringProcessor.java | 41 + .../deleteprocessor/AsyncDeleteProcessor.java | 48 + .../AsyncDeleteProcessorLRO.java | 49 + .../deleteprocessor/SyncDeleteProcessor.java | 44 + .../SyncDeleteProcessorProcessorname.java | 40 + .../SyncDeleteProcessorString.java | 40 + .../AsyncDisableProcessor.java | 48 + .../AsyncDisableProcessorLRO.java | 49 + .../SyncDisableProcessor.java | 45 + .../enableprocessor/AsyncEnableProcessor.java | 48 + .../AsyncEnableProcessorLRO.java | 49 + .../enableprocessor/SyncEnableProcessor.java | 45 + .../AsyncFetchProcessorTypes.java | 48 + .../SyncFetchProcessorTypes.java | 45 + .../SyncFetchProcessorTypesLocationname.java | 41 + .../SyncFetchProcessorTypesString.java | 41 + .../listprocessors/AsyncListProcessors.java | 52 ++ .../AsyncListProcessorsPaged.java | 60 ++ .../listprocessors/SyncListProcessors.java | 49 + .../SyncListProcessorsLocationname.java | 42 + .../SyncListProcessorsString.java | 42 + .../processdocument/AsyncProcessDocument.java | 51 ++ .../processdocument/SyncProcessDocument.java | 47 + .../SyncProcessDocumentProcessorname.java | 40 + .../SyncProcessDocumentString.java | 40 + .../reviewdocument/AsyncReviewDocument.java | 52 ++ .../AsyncReviewDocumentLRO.java | 53 ++ .../reviewdocument/SyncReviewDocument.java | 49 + ...ncReviewDocumentHumanreviewconfigname.java | 42 + .../SyncReviewDocumentString.java | 42 + .../processdocument/SyncProcessDocument.java | 47 + .../processdocument/SyncProcessDocument.java | 47 + 96 files changed, 6485 insertions(+), 24 deletions(-) create mode 100644 google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/HttpJsonDocumentProcessorServiceCallableFactory.java create mode 100644 google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/HttpJsonDocumentProcessorServiceStub.java create mode 100644 google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/HttpJsonDocumentProcessorServiceCallableFactory.java create mode 100644 google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/HttpJsonDocumentProcessorServiceStub.java create mode 100644 google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClientHttpJsonTest.java create mode 100644 google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClientHttpJsonTest.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsProcessorname.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsString.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/AsyncProcessDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocumentProcessorname.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocumentString.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/AsyncReviewDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/AsyncReviewDocumentLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentHumanreviewconfigname.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentString.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorservicesettings/processdocument/SyncProcessDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1/stub/documentprocessorservicestubsettings/processdocument/SyncProcessDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsListprocessdocumentrequest.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingservicesettings/batchprocessdocuments/SyncBatchProcessDocuments.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta1/stub/documentunderstandingservicestubsettings/batchprocessdocuments/SyncBatchProcessDocuments.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsListprocessdocumentrequest.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/processdocument/AsyncProcessDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/processdocument/SyncProcessDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingservicesettings/processdocument/SyncProcessDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta2/stub/documentunderstandingservicestubsettings/processdocument/SyncProcessDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsProcessorname.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsString.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/AsyncCreateProcessor.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessor.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessorLocationnameProcessor.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessorStringProcessor.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/AsyncDeleteProcessor.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/AsyncDeleteProcessorLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessor.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessorProcessorname.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessorString.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/AsyncDisableProcessor.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/AsyncDisableProcessorLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/SyncDisableProcessor.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/AsyncEnableProcessor.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/AsyncEnableProcessorLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/SyncEnableProcessor.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/AsyncFetchProcessorTypes.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypes.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypesLocationname.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypesString.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/AsyncListProcessors.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/AsyncListProcessorsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessors.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessorsLocationname.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessorsString.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/AsyncProcessDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocumentProcessorname.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocumentString.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/AsyncReviewDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/AsyncReviewDocumentLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentHumanreviewconfigname.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentString.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorservicesettings/processdocument/SyncProcessDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/documentai/v1beta3/stub/documentprocessorservicestubsettings/processdocument/SyncProcessDocument.java diff --git a/README.md b/README.md index 49c65c2a..ce3e842f 100644 --- a/README.md +++ b/README.md @@ -57,13 +57,13 @@ implementation 'com.google.cloud:google-cloud-document-ai' If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-document-ai:2.5.1' +implementation 'com.google.cloud:google-cloud-document-ai:2.5.2' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-document-ai" % "2.5.1" +libraryDependencies += "com.google.cloud" % "google-cloud-document-ai" % "2.5.2" ``` ## Authentication diff --git a/google-cloud-document-ai/pom.xml b/google-cloud-document-ai/pom.xml index 34134c7f..f1337f8f 100644 --- a/google-cloud-document-ai/pom.xml +++ b/google-cloud-document-ai/pom.xml @@ -70,6 +70,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -103,12 +107,24 @@ + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClient.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClient.java index 858c5b47..3355b300 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClient.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClient.java @@ -17,13 +17,13 @@ package com.google.cloud.documentai.v1; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.documentai.v1.stub.DocumentProcessorServiceStub; import com.google.cloud.documentai.v1.stub.DocumentProcessorServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -99,13 +99,29 @@ * DocumentProcessorServiceClient.create(documentProcessorServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * DocumentProcessorServiceSettings documentProcessorServiceSettings =
+ *     DocumentProcessorServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             DocumentProcessorServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * DocumentProcessorServiceClient documentProcessorServiceClient =
+ *     DocumentProcessorServiceClient.create(documentProcessorServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class DocumentProcessorServiceClient implements BackgroundResource { private final DocumentProcessorServiceSettings settings; private final DocumentProcessorServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of DocumentProcessorServiceClient with default settings. */ public static final DocumentProcessorServiceClient create() throws IOException { @@ -139,13 +155,17 @@ protected DocumentProcessorServiceClient(DocumentProcessorServiceSettings settin throws IOException { this.settings = settings; this.stub = ((DocumentProcessorServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected DocumentProcessorServiceClient(DocumentProcessorServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final DocumentProcessorServiceSettings getSettings() { @@ -160,10 +180,18 @@ public DocumentProcessorServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Processes a single document. diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceSettings.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceSettings.java index d483d039..6207218d 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceSettings.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -128,11 +129,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return DocumentProcessorServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return DocumentProcessorServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DocumentProcessorServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return DocumentProcessorServiceStubSettings.defaultTransportChannelProvider(); } @@ -142,11 +150,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return DocumentProcessorServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -185,6 +199,11 @@ private static Builder createDefault() { return new Builder(DocumentProcessorServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(DocumentProcessorServiceStubSettings.newHttpJsonBuilder()); + } + public DocumentProcessorServiceStubSettings.Builder getStubSettingsBuilder() { return ((DocumentProcessorServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/DocumentProcessorServiceStub.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/DocumentProcessorServiceStub.java index aea812f9..370b89a2 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/DocumentProcessorServiceStub.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/DocumentProcessorServiceStub.java @@ -41,7 +41,11 @@ public abstract class DocumentProcessorServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable processDocumentCallable() { diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/DocumentProcessorServiceStubSettings.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/DocumentProcessorServiceStubSettings.java index abed65d9..7da61e8f 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/DocumentProcessorServiceStubSettings.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/DocumentProcessorServiceStubSettings.java @@ -25,6 +25,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -139,6 +142,11 @@ public DocumentProcessorServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDocumentProcessorServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDocumentProcessorServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -171,18 +179,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(DocumentProcessorServiceStubSettings.class)) @@ -190,11 +205,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(DocumentProcessorServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DocumentProcessorServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -312,6 +346,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .processDocumentSettings() diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/HttpJsonDocumentProcessorServiceCallableFactory.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/HttpJsonDocumentProcessorServiceCallableFactory.java new file mode 100644 index 00000000..d1c4d2a5 --- /dev/null +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/HttpJsonDocumentProcessorServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the DocumentProcessorService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDocumentProcessorServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/HttpJsonDocumentProcessorServiceStub.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/HttpJsonDocumentProcessorServiceStub.java new file mode 100644 index 00000000..745b9ea5 --- /dev/null +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/stub/HttpJsonDocumentProcessorServiceStub.java @@ -0,0 +1,365 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.documentai.v1.BatchProcessMetadata; +import com.google.cloud.documentai.v1.BatchProcessRequest; +import com.google.cloud.documentai.v1.BatchProcessResponse; +import com.google.cloud.documentai.v1.ProcessRequest; +import com.google.cloud.documentai.v1.ProcessResponse; +import com.google.cloud.documentai.v1.ReviewDocumentOperationMetadata; +import com.google.cloud.documentai.v1.ReviewDocumentRequest; +import com.google.cloud.documentai.v1.ReviewDocumentResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the DocumentProcessorService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDocumentProcessorServiceStub extends DocumentProcessorServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(BatchProcessResponse.getDescriptor()) + .add(ReviewDocumentResponse.getDescriptor()) + .add(ReviewDocumentOperationMetadata.getDescriptor()) + .add(BatchProcessMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + processDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1.DocumentProcessorService/ProcessDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/processors/*}:process", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ProcessResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchProcessDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1.DocumentProcessorService/BatchProcessDocuments") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/processors/*}:batchProcess", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchProcessRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + reviewDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1.DocumentProcessorService/ReviewDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{humanReviewConfig=projects/*/locations/*/processors/*/humanReviewConfig}:reviewDocument", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "humanReviewConfig", request.getHumanReviewConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody( + "*", request.toBuilder().clearHumanReviewConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ReviewDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable processDocumentCallable; + private final UnaryCallable batchProcessDocumentsCallable; + private final OperationCallable + batchProcessDocumentsOperationCallable; + private final UnaryCallable reviewDocumentCallable; + private final OperationCallable< + ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> + reviewDocumentOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDocumentProcessorServiceStub create( + DocumentProcessorServiceStubSettings settings) throws IOException { + return new HttpJsonDocumentProcessorServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDocumentProcessorServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonDocumentProcessorServiceStub( + DocumentProcessorServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDocumentProcessorServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDocumentProcessorServiceStub( + DocumentProcessorServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonDocumentProcessorServiceStub, using the given settings. This + * is protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonDocumentProcessorServiceStub( + DocumentProcessorServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonDocumentProcessorServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDocumentProcessorServiceStub, using the given settings. This + * is protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonDocumentProcessorServiceStub( + DocumentProcessorServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings processDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(processDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings batchProcessDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchProcessDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings reviewDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(reviewDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.processDocumentCallable = + callableFactory.createUnaryCallable( + processDocumentTransportSettings, settings.processDocumentSettings(), clientContext); + this.batchProcessDocumentsCallable = + callableFactory.createUnaryCallable( + batchProcessDocumentsTransportSettings, + settings.batchProcessDocumentsSettings(), + clientContext); + this.batchProcessDocumentsOperationCallable = + callableFactory.createOperationCallable( + batchProcessDocumentsTransportSettings, + settings.batchProcessDocumentsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.reviewDocumentCallable = + callableFactory.createUnaryCallable( + reviewDocumentTransportSettings, settings.reviewDocumentSettings(), clientContext); + this.reviewDocumentOperationCallable = + callableFactory.createOperationCallable( + reviewDocumentTransportSettings, + settings.reviewDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(processDocumentMethodDescriptor); + methodDescriptors.add(batchProcessDocumentsMethodDescriptor); + methodDescriptors.add(reviewDocumentMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable processDocumentCallable() { + return processDocumentCallable; + } + + @Override + public UnaryCallable batchProcessDocumentsCallable() { + return batchProcessDocumentsCallable; + } + + @Override + public OperationCallable + batchProcessDocumentsOperationCallable() { + return batchProcessDocumentsOperationCallable; + } + + @Override + public UnaryCallable reviewDocumentCallable() { + return reviewDocumentCallable; + } + + @Override + public OperationCallable< + ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> + reviewDocumentOperationCallable() { + return reviewDocumentOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java index 2f72c56c..e66c4ea0 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.documentai.v1beta3.stub.DocumentProcessorServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -109,6 +109,21 @@ * DocumentProcessorServiceClient.create(documentProcessorServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * DocumentProcessorServiceSettings documentProcessorServiceSettings =
+ *     DocumentProcessorServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             DocumentProcessorServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * DocumentProcessorServiceClient documentProcessorServiceClient =
+ *     DocumentProcessorServiceClient.create(documentProcessorServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -116,7 +131,8 @@ public class DocumentProcessorServiceClient implements BackgroundResource { private final DocumentProcessorServiceSettings settings; private final DocumentProcessorServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of DocumentProcessorServiceClient with default settings. */ public static final DocumentProcessorServiceClient create() throws IOException { @@ -150,13 +166,17 @@ protected DocumentProcessorServiceClient(DocumentProcessorServiceSettings settin throws IOException { this.settings = settings; this.stub = ((DocumentProcessorServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected DocumentProcessorServiceClient(DocumentProcessorServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final DocumentProcessorServiceSettings getSettings() { @@ -171,10 +191,18 @@ public DocumentProcessorServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Processes a single document. diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceSettings.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceSettings.java index 8bac2b6b..951a2264 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceSettings.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -189,11 +190,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return DocumentProcessorServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return DocumentProcessorServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DocumentProcessorServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return DocumentProcessorServiceStubSettings.defaultTransportChannelProvider(); } @@ -203,11 +211,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return DocumentProcessorServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -246,6 +260,11 @@ private static Builder createDefault() { return new Builder(DocumentProcessorServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(DocumentProcessorServiceStubSettings.newHttpJsonBuilder()); + } + public DocumentProcessorServiceStubSettings.Builder getStubSettingsBuilder() { return ((DocumentProcessorServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStub.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStub.java index c301b665..c327462a 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStub.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStub.java @@ -60,7 +60,11 @@ public abstract class DocumentProcessorServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable processDocumentCallable() { diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStubSettings.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStubSettings.java index 3d9a55f6..c6fa4888 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStubSettings.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -288,6 +291,11 @@ public DocumentProcessorServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDocumentProcessorServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDocumentProcessorServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -320,18 +328,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(DocumentProcessorServiceStubSettings.class)) @@ -339,11 +354,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(DocumentProcessorServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DocumentProcessorServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -529,6 +563,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .processDocumentSettings() diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/HttpJsonDocumentProcessorServiceCallableFactory.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/HttpJsonDocumentProcessorServiceCallableFactory.java new file mode 100644 index 00000000..750c1df5 --- /dev/null +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/HttpJsonDocumentProcessorServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the DocumentProcessorService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonDocumentProcessorServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/HttpJsonDocumentProcessorServiceStub.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/HttpJsonDocumentProcessorServiceStub.java new file mode 100644 index 00000000..6bffd115 --- /dev/null +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/HttpJsonDocumentProcessorServiceStub.java @@ -0,0 +1,765 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.stub; + +import static com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient.ListProcessorsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.documentai.v1beta3.BatchProcessMetadata; +import com.google.cloud.documentai.v1beta3.BatchProcessRequest; +import com.google.cloud.documentai.v1beta3.BatchProcessResponse; +import com.google.cloud.documentai.v1beta3.CreateProcessorRequest; +import com.google.cloud.documentai.v1beta3.DeleteProcessorMetadata; +import com.google.cloud.documentai.v1beta3.DeleteProcessorRequest; +import com.google.cloud.documentai.v1beta3.DisableProcessorMetadata; +import com.google.cloud.documentai.v1beta3.DisableProcessorRequest; +import com.google.cloud.documentai.v1beta3.DisableProcessorResponse; +import com.google.cloud.documentai.v1beta3.EnableProcessorMetadata; +import com.google.cloud.documentai.v1beta3.EnableProcessorRequest; +import com.google.cloud.documentai.v1beta3.EnableProcessorResponse; +import com.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest; +import com.google.cloud.documentai.v1beta3.FetchProcessorTypesResponse; +import com.google.cloud.documentai.v1beta3.ListProcessorsRequest; +import com.google.cloud.documentai.v1beta3.ListProcessorsResponse; +import com.google.cloud.documentai.v1beta3.ProcessRequest; +import com.google.cloud.documentai.v1beta3.ProcessResponse; +import com.google.cloud.documentai.v1beta3.Processor; +import com.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata; +import com.google.cloud.documentai.v1beta3.ReviewDocumentRequest; +import com.google.cloud.documentai.v1beta3.ReviewDocumentResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the DocumentProcessorService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonDocumentProcessorServiceStub extends DocumentProcessorServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(BatchProcessMetadata.getDescriptor()) + .add(Empty.getDescriptor()) + .add(DisableProcessorMetadata.getDescriptor()) + .add(EnableProcessorMetadata.getDescriptor()) + .add(DeleteProcessorMetadata.getDescriptor()) + .add(ReviewDocumentResponse.getDescriptor()) + .add(EnableProcessorResponse.getDescriptor()) + .add(BatchProcessResponse.getDescriptor()) + .add(DisableProcessorResponse.getDescriptor()) + .add(ReviewDocumentOperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + processDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1beta3.DocumentProcessorService/ProcessDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta3/{name=projects/*/locations/*/processors/*}:process", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ProcessResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchProcessDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1beta3.DocumentProcessorService/BatchProcessDocuments") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta3/{name=projects/*/locations/*/processors/*}:batchProcess", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchProcessRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + fetchProcessorTypesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1beta3.DocumentProcessorService/FetchProcessorTypes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta3/{parent=projects/*/locations/*}:fetchProcessorTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(FetchProcessorTypesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listProcessorsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1beta3.DocumentProcessorService/ListProcessors") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta3/{parent=projects/*/locations/*}/processors", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProcessorsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createProcessorMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1beta3.DocumentProcessorService/CreateProcessor") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta3/{parent=projects/*/locations/*}/processors", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("processor", request.getProcessor())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Processor.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteProcessorMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1beta3.DocumentProcessorService/DeleteProcessor") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta3/{name=projects/*/locations/*/processors/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteProcessorRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + enableProcessorMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1beta3.DocumentProcessorService/EnableProcessor") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta3/{name=projects/*/locations/*/processors/*}:enable", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (EnableProcessorRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + disableProcessorMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1beta3.DocumentProcessorService/DisableProcessor") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta3/{name=projects/*/locations/*/processors/*}:disable", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DisableProcessorRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + reviewDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.documentai.v1beta3.DocumentProcessorService/ReviewDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta3/{humanReviewConfig=projects/*/locations/*/processors/*/humanReviewConfig}:reviewDocument", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "humanReviewConfig", request.getHumanReviewConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody( + "*", request.toBuilder().clearHumanReviewConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ReviewDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable processDocumentCallable; + private final UnaryCallable batchProcessDocumentsCallable; + private final OperationCallable + batchProcessDocumentsOperationCallable; + private final UnaryCallable + fetchProcessorTypesCallable; + private final UnaryCallable listProcessorsCallable; + private final UnaryCallable + listProcessorsPagedCallable; + private final UnaryCallable createProcessorCallable; + private final UnaryCallable deleteProcessorCallable; + private final OperationCallable + deleteProcessorOperationCallable; + private final UnaryCallable enableProcessorCallable; + private final OperationCallable< + EnableProcessorRequest, EnableProcessorResponse, EnableProcessorMetadata> + enableProcessorOperationCallable; + private final UnaryCallable disableProcessorCallable; + private final OperationCallable< + DisableProcessorRequest, DisableProcessorResponse, DisableProcessorMetadata> + disableProcessorOperationCallable; + private final UnaryCallable reviewDocumentCallable; + private final OperationCallable< + ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> + reviewDocumentOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDocumentProcessorServiceStub create( + DocumentProcessorServiceStubSettings settings) throws IOException { + return new HttpJsonDocumentProcessorServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDocumentProcessorServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonDocumentProcessorServiceStub( + DocumentProcessorServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDocumentProcessorServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDocumentProcessorServiceStub( + DocumentProcessorServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonDocumentProcessorServiceStub, using the given settings. This + * is protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonDocumentProcessorServiceStub( + DocumentProcessorServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonDocumentProcessorServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDocumentProcessorServiceStub, using the given settings. This + * is protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonDocumentProcessorServiceStub( + DocumentProcessorServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings processDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(processDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings batchProcessDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchProcessDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + fetchProcessorTypesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(fetchProcessorTypesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listProcessorsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProcessorsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createProcessorTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProcessorMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProcessorTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProcessorMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings enableProcessorTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(enableProcessorMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings disableProcessorTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(disableProcessorMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings reviewDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(reviewDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.processDocumentCallable = + callableFactory.createUnaryCallable( + processDocumentTransportSettings, settings.processDocumentSettings(), clientContext); + this.batchProcessDocumentsCallable = + callableFactory.createUnaryCallable( + batchProcessDocumentsTransportSettings, + settings.batchProcessDocumentsSettings(), + clientContext); + this.batchProcessDocumentsOperationCallable = + callableFactory.createOperationCallable( + batchProcessDocumentsTransportSettings, + settings.batchProcessDocumentsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.fetchProcessorTypesCallable = + callableFactory.createUnaryCallable( + fetchProcessorTypesTransportSettings, + settings.fetchProcessorTypesSettings(), + clientContext); + this.listProcessorsCallable = + callableFactory.createUnaryCallable( + listProcessorsTransportSettings, settings.listProcessorsSettings(), clientContext); + this.listProcessorsPagedCallable = + callableFactory.createPagedCallable( + listProcessorsTransportSettings, settings.listProcessorsSettings(), clientContext); + this.createProcessorCallable = + callableFactory.createUnaryCallable( + createProcessorTransportSettings, settings.createProcessorSettings(), clientContext); + this.deleteProcessorCallable = + callableFactory.createUnaryCallable( + deleteProcessorTransportSettings, settings.deleteProcessorSettings(), clientContext); + this.deleteProcessorOperationCallable = + callableFactory.createOperationCallable( + deleteProcessorTransportSettings, + settings.deleteProcessorOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.enableProcessorCallable = + callableFactory.createUnaryCallable( + enableProcessorTransportSettings, settings.enableProcessorSettings(), clientContext); + this.enableProcessorOperationCallable = + callableFactory.createOperationCallable( + enableProcessorTransportSettings, + settings.enableProcessorOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.disableProcessorCallable = + callableFactory.createUnaryCallable( + disableProcessorTransportSettings, settings.disableProcessorSettings(), clientContext); + this.disableProcessorOperationCallable = + callableFactory.createOperationCallable( + disableProcessorTransportSettings, + settings.disableProcessorOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.reviewDocumentCallable = + callableFactory.createUnaryCallable( + reviewDocumentTransportSettings, settings.reviewDocumentSettings(), clientContext); + this.reviewDocumentOperationCallable = + callableFactory.createOperationCallable( + reviewDocumentTransportSettings, + settings.reviewDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(processDocumentMethodDescriptor); + methodDescriptors.add(batchProcessDocumentsMethodDescriptor); + methodDescriptors.add(fetchProcessorTypesMethodDescriptor); + methodDescriptors.add(listProcessorsMethodDescriptor); + methodDescriptors.add(createProcessorMethodDescriptor); + methodDescriptors.add(deleteProcessorMethodDescriptor); + methodDescriptors.add(enableProcessorMethodDescriptor); + methodDescriptors.add(disableProcessorMethodDescriptor); + methodDescriptors.add(reviewDocumentMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable processDocumentCallable() { + return processDocumentCallable; + } + + @Override + public UnaryCallable batchProcessDocumentsCallable() { + return batchProcessDocumentsCallable; + } + + @Override + public OperationCallable + batchProcessDocumentsOperationCallable() { + return batchProcessDocumentsOperationCallable; + } + + @Override + public UnaryCallable + fetchProcessorTypesCallable() { + return fetchProcessorTypesCallable; + } + + @Override + public UnaryCallable listProcessorsCallable() { + return listProcessorsCallable; + } + + @Override + public UnaryCallable + listProcessorsPagedCallable() { + return listProcessorsPagedCallable; + } + + @Override + public UnaryCallable createProcessorCallable() { + return createProcessorCallable; + } + + @Override + public UnaryCallable deleteProcessorCallable() { + return deleteProcessorCallable; + } + + @Override + public OperationCallable + deleteProcessorOperationCallable() { + return deleteProcessorOperationCallable; + } + + @Override + public UnaryCallable enableProcessorCallable() { + return enableProcessorCallable; + } + + @Override + public OperationCallable + enableProcessorOperationCallable() { + return enableProcessorOperationCallable; + } + + @Override + public UnaryCallable disableProcessorCallable() { + return disableProcessorCallable; + } + + @Override + public OperationCallable< + DisableProcessorRequest, DisableProcessorResponse, DisableProcessorMetadata> + disableProcessorOperationCallable() { + return disableProcessorOperationCallable; + } + + @Override + public UnaryCallable reviewDocumentCallable() { + return reviewDocumentCallable; + } + + @Override + public OperationCallable< + ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> + reviewDocumentOperationCallable() { + return reviewDocumentOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClientHttpJsonTest.java b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClientHttpJsonTest.java new file mode 100644 index 00000000..e1de51f9 --- /dev/null +++ b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClientHttpJsonTest.java @@ -0,0 +1,356 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.documentai.v1.stub.HttpJsonDocumentProcessorServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class DocumentProcessorServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static DocumentProcessorServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDocumentProcessorServiceStub.getMethodDescriptors(), + DocumentProcessorServiceSettings.getDefaultEndpoint()); + DocumentProcessorServiceSettings settings = + DocumentProcessorServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DocumentProcessorServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DocumentProcessorServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void processDocumentTest() throws Exception { + ProcessResponse expectedResponse = + ProcessResponse.newBuilder() + .setDocument(Document.newBuilder().build()) + .setHumanReviewStatus(HumanReviewStatus.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + + ProcessResponse actualResponse = client.processDocument(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void processDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + client.processDocument(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void processDocumentTest2() throws Exception { + ProcessResponse expectedResponse = + ProcessResponse.newBuilder() + .setDocument(Document.newBuilder().build()) + .setHumanReviewStatus(HumanReviewStatus.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5167/locations/location-5167/processors/processor-5167"; + + ProcessResponse actualResponse = client.processDocument(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void processDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5167/locations/location-5167/processors/processor-5167"; + client.processDocument(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchProcessDocumentsTest() throws Exception { + BatchProcessResponse expectedResponse = BatchProcessResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchProcessDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + + BatchProcessResponse actualResponse = client.batchProcessDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchProcessDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + client.batchProcessDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchProcessDocumentsTest2() throws Exception { + BatchProcessResponse expectedResponse = BatchProcessResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchProcessDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-5167/locations/location-5167/processors/processor-5167"; + + BatchProcessResponse actualResponse = client.batchProcessDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchProcessDocumentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5167/locations/location-5167/processors/processor-5167"; + client.batchProcessDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void reviewDocumentTest() throws Exception { + ReviewDocumentResponse expectedResponse = + ReviewDocumentResponse.newBuilder().setGcsDestination("gcsDestination-1612392329").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("reviewDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + HumanReviewConfigName humanReviewConfig = + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + + ReviewDocumentResponse actualResponse = client.reviewDocumentAsync(humanReviewConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reviewDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + HumanReviewConfigName humanReviewConfig = + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + client.reviewDocumentAsync(humanReviewConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void reviewDocumentTest2() throws Exception { + ReviewDocumentResponse expectedResponse = + ReviewDocumentResponse.newBuilder().setGcsDestination("gcsDestination-1612392329").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("reviewDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String humanReviewConfig = + "projects/project-1917/locations/location-1917/processors/processor-1917/humanReviewConfig"; + + ReviewDocumentResponse actualResponse = client.reviewDocumentAsync(humanReviewConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reviewDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String humanReviewConfig = + "projects/project-1917/locations/location-1917/processors/processor-1917/humanReviewConfig"; + client.reviewDocumentAsync(humanReviewConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClientHttpJsonTest.java b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClientHttpJsonTest.java new file mode 100644 index 00000000..68ff6c34 --- /dev/null +++ b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClientHttpJsonTest.java @@ -0,0 +1,851 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3; + +import static com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient.ListProcessorsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.documentai.v1beta3.stub.HttpJsonDocumentProcessorServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class DocumentProcessorServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static DocumentProcessorServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDocumentProcessorServiceStub.getMethodDescriptors(), + DocumentProcessorServiceSettings.getDefaultEndpoint()); + DocumentProcessorServiceSettings settings = + DocumentProcessorServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DocumentProcessorServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DocumentProcessorServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void processDocumentTest() throws Exception { + ProcessResponse expectedResponse = + ProcessResponse.newBuilder() + .setDocument(Document.newBuilder().build()) + .setHumanReviewOperation("humanReviewOperation1807415298") + .setHumanReviewStatus(HumanReviewStatus.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + + ProcessResponse actualResponse = client.processDocument(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void processDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + client.processDocument(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void processDocumentTest2() throws Exception { + ProcessResponse expectedResponse = + ProcessResponse.newBuilder() + .setDocument(Document.newBuilder().build()) + .setHumanReviewOperation("humanReviewOperation1807415298") + .setHumanReviewStatus(HumanReviewStatus.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5167/locations/location-5167/processors/processor-5167"; + + ProcessResponse actualResponse = client.processDocument(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void processDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5167/locations/location-5167/processors/processor-5167"; + client.processDocument(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchProcessDocumentsTest() throws Exception { + BatchProcessResponse expectedResponse = BatchProcessResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchProcessDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + + BatchProcessResponse actualResponse = client.batchProcessDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchProcessDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + client.batchProcessDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchProcessDocumentsTest2() throws Exception { + BatchProcessResponse expectedResponse = BatchProcessResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchProcessDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-5167/locations/location-5167/processors/processor-5167"; + + BatchProcessResponse actualResponse = client.batchProcessDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchProcessDocumentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5167/locations/location-5167/processors/processor-5167"; + client.batchProcessDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void fetchProcessorTypesTest() throws Exception { + FetchProcessorTypesResponse expectedResponse = + FetchProcessorTypesResponse.newBuilder() + .addAllProcessorTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + FetchProcessorTypesResponse actualResponse = client.fetchProcessorTypes(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void fetchProcessorTypesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.fetchProcessorTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void fetchProcessorTypesTest2() throws Exception { + FetchProcessorTypesResponse expectedResponse = + FetchProcessorTypesResponse.newBuilder() + .addAllProcessorTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + FetchProcessorTypesResponse actualResponse = client.fetchProcessorTypes(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void fetchProcessorTypesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.fetchProcessorTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProcessorsTest() throws Exception { + Processor responsesElement = Processor.newBuilder().build(); + ListProcessorsResponse expectedResponse = + ListProcessorsResponse.newBuilder() + .setNextPageToken("") + .addAllProcessors(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListProcessorsPagedResponse pagedListResponse = client.listProcessors(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProcessorsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProcessorsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listProcessors(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProcessorsTest2() throws Exception { + Processor responsesElement = Processor.newBuilder().build(); + ListProcessorsResponse expectedResponse = + ListProcessorsResponse.newBuilder() + .setNextPageToken("") + .addAllProcessors(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListProcessorsPagedResponse pagedListResponse = client.listProcessors(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProcessorsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProcessorsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listProcessors(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProcessorTest() throws Exception { + Processor expectedResponse = + Processor.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setType("type3575610") + .setDisplayName("displayName1714148973") + .setDefaultProcessorVersion("defaultProcessorVersion-1428555705") + .setProcessEndpoint("processEndpoint-891502300") + .setCreateTime(Timestamp.newBuilder().build()) + .setKmsKeyName("kmsKeyName412586233") + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Processor processor = Processor.newBuilder().build(); + + Processor actualResponse = client.createProcessor(parent, processor); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProcessorExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Processor processor = Processor.newBuilder().build(); + client.createProcessor(parent, processor); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProcessorTest2() throws Exception { + Processor expectedResponse = + Processor.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setType("type3575610") + .setDisplayName("displayName1714148973") + .setDefaultProcessorVersion("defaultProcessorVersion-1428555705") + .setProcessEndpoint("processEndpoint-891502300") + .setCreateTime(Timestamp.newBuilder().build()) + .setKmsKeyName("kmsKeyName412586233") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Processor processor = Processor.newBuilder().build(); + + Processor actualResponse = client.createProcessor(parent, processor); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProcessorExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Processor processor = Processor.newBuilder().build(); + client.createProcessor(parent, processor); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProcessorTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteProcessorTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + + client.deleteProcessorAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProcessorExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + client.deleteProcessorAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteProcessorTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteProcessorTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-5167/locations/location-5167/processors/processor-5167"; + + client.deleteProcessorAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProcessorExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5167/locations/location-5167/processors/processor-5167"; + client.deleteProcessorAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void enableProcessorTest() throws Exception { + EnableProcessorResponse expectedResponse = EnableProcessorResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("enableProcessorTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EnableProcessorRequest request = + EnableProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + + EnableProcessorResponse actualResponse = client.enableProcessorAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void enableProcessorExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EnableProcessorRequest request = + EnableProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + client.enableProcessorAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void disableProcessorTest() throws Exception { + DisableProcessorResponse expectedResponse = DisableProcessorResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("disableProcessorTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DisableProcessorRequest request = + DisableProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + + DisableProcessorResponse actualResponse = client.disableProcessorAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void disableProcessorExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DisableProcessorRequest request = + DisableProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + client.disableProcessorAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void reviewDocumentTest() throws Exception { + ReviewDocumentResponse expectedResponse = + ReviewDocumentResponse.newBuilder().setGcsDestination("gcsDestination-1612392329").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("reviewDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + HumanReviewConfigName humanReviewConfig = + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + + ReviewDocumentResponse actualResponse = client.reviewDocumentAsync(humanReviewConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reviewDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + HumanReviewConfigName humanReviewConfig = + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + client.reviewDocumentAsync(humanReviewConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void reviewDocumentTest2() throws Exception { + ReviewDocumentResponse expectedResponse = + ReviewDocumentResponse.newBuilder().setGcsDestination("gcsDestination-1612392329").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("reviewDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String humanReviewConfig = + "projects/project-1917/locations/location-1917/processors/processor-1917/humanReviewConfig"; + + ReviewDocumentResponse actualResponse = client.reviewDocumentAsync(humanReviewConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reviewDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String humanReviewConfig = + "projects/project-1917/locations/location-1917/processors/processor-1917/humanReviewConfig"; + client.reviewDocumentAsync(humanReviewConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java new file mode 100644 index 00000000..18ab39b8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_batchprocessdocuments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1.BatchDocumentsInputConfig; +import com.google.cloud.documentai.v1.BatchProcessRequest; +import com.google.cloud.documentai.v1.DocumentOutputConfig; +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.ProcessorName; +import com.google.longrunning.Operation; + +public class AsyncBatchProcessDocuments { + + public static void main(String[] args) throws Exception { + asyncBatchProcessDocuments(); + } + + public static void asyncBatchProcessDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + BatchProcessRequest request = + BatchProcessRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setSkipHumanReview(true) + .build(); + ApiFuture future = + documentProcessorServiceClient.batchProcessDocumentsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_batchprocessdocuments_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java new file mode 100644 index 00000000..3ad5a46c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_batchprocessdocuments_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.documentai.v1.BatchDocumentsInputConfig; +import com.google.cloud.documentai.v1.BatchProcessMetadata; +import com.google.cloud.documentai.v1.BatchProcessRequest; +import com.google.cloud.documentai.v1.BatchProcessResponse; +import com.google.cloud.documentai.v1.DocumentOutputConfig; +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.ProcessorName; + +public class AsyncBatchProcessDocumentsLRO { + + public static void main(String[] args) throws Exception { + asyncBatchProcessDocumentsLRO(); + } + + public static void asyncBatchProcessDocumentsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + BatchProcessRequest request = + BatchProcessRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setSkipHumanReview(true) + .build(); + OperationFuture future = + documentProcessorServiceClient + .batchProcessDocumentsOperationCallable() + .futureCall(request); + // Do something. + BatchProcessResponse response = future.get(); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_batchprocessdocuments_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java new file mode 100644 index 00000000..0f9ba56c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_batchprocessdocuments_sync] +import com.google.cloud.documentai.v1.BatchDocumentsInputConfig; +import com.google.cloud.documentai.v1.BatchProcessRequest; +import com.google.cloud.documentai.v1.BatchProcessResponse; +import com.google.cloud.documentai.v1.DocumentOutputConfig; +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.ProcessorName; + +public class SyncBatchProcessDocuments { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocuments(); + } + + public static void syncBatchProcessDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + BatchProcessRequest request = + BatchProcessRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setSkipHumanReview(true) + .build(); + BatchProcessResponse response = + documentProcessorServiceClient.batchProcessDocumentsAsync(request).get(); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_batchprocessdocuments_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsProcessorname.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsProcessorname.java new file mode 100644 index 00000000..fc0da471 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsProcessorname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_batchprocessdocuments_processorname_sync] +import com.google.cloud.documentai.v1.BatchProcessResponse; +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.ProcessorName; + +public class SyncBatchProcessDocumentsProcessorname { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocumentsProcessorname(); + } + + public static void syncBatchProcessDocumentsProcessorname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + BatchProcessResponse response = + documentProcessorServiceClient.batchProcessDocumentsAsync(name).get(); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_batchprocessdocuments_processorname_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsString.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsString.java new file mode 100644 index 00000000..9b24b826 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_batchprocessdocuments_string_sync] +import com.google.cloud.documentai.v1.BatchProcessResponse; +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.ProcessorName; + +public class SyncBatchProcessDocumentsString { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocumentsString(); + } + + public static void syncBatchProcessDocumentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + String name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString(); + BatchProcessResponse response = + documentProcessorServiceClient.batchProcessDocumentsAsync(name).get(); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_batchprocessdocuments_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..c2bd29e7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.DocumentProcessorServiceSettings; +import com.google.cloud.documentai.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentProcessorServiceSettings documentProcessorServiceSettings = + DocumentProcessorServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create(documentProcessorServiceSettings); + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..a3265099 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.DocumentProcessorServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentProcessorServiceSettings documentProcessorServiceSettings = + DocumentProcessorServiceSettings.newBuilder() + .setTransportChannelProvider( + DocumentProcessorServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create(documentProcessorServiceSettings); + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..0808638e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_create_setendpoint_sync] +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.DocumentProcessorServiceSettings; +import com.google.cloud.documentai.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentProcessorServiceSettings documentProcessorServiceSettings = + DocumentProcessorServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create(documentProcessorServiceSettings); + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/AsyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/AsyncProcessDocument.java new file mode 100644 index 00000000..29358a64 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/AsyncProcessDocument.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_processdocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.ProcessRequest; +import com.google.cloud.documentai.v1.ProcessResponse; +import com.google.cloud.documentai.v1.ProcessorName; + +public class AsyncProcessDocument { + + public static void main(String[] args) throws Exception { + asyncProcessDocument(); + } + + public static void asyncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ProcessRequest request = + ProcessRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setSkipHumanReview(true) + .build(); + ApiFuture future = + documentProcessorServiceClient.processDocumentCallable().futureCall(request); + // Do something. + ProcessResponse response = future.get(); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_processdocument_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocument.java new file mode 100644 index 00000000..cba90962 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocument.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_processdocument_sync] +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.ProcessRequest; +import com.google.cloud.documentai.v1.ProcessResponse; +import com.google.cloud.documentai.v1.ProcessorName; + +public class SyncProcessDocument { + + public static void main(String[] args) throws Exception { + syncProcessDocument(); + } + + public static void syncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ProcessRequest request = + ProcessRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setSkipHumanReview(true) + .build(); + ProcessResponse response = documentProcessorServiceClient.processDocument(request); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_processdocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocumentProcessorname.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocumentProcessorname.java new file mode 100644 index 00000000..6f94a5ab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocumentProcessorname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_processdocument_processorname_sync] +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.ProcessResponse; +import com.google.cloud.documentai.v1.ProcessorName; + +public class SyncProcessDocumentProcessorname { + + public static void main(String[] args) throws Exception { + syncProcessDocumentProcessorname(); + } + + public static void syncProcessDocumentProcessorname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + ProcessResponse response = documentProcessorServiceClient.processDocument(name); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_processdocument_processorname_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocumentString.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocumentString.java new file mode 100644 index 00000000..54dc9fcf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/processdocument/SyncProcessDocumentString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_processdocument_string_sync] +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.ProcessResponse; +import com.google.cloud.documentai.v1.ProcessorName; + +public class SyncProcessDocumentString { + + public static void main(String[] args) throws Exception { + syncProcessDocumentString(); + } + + public static void syncProcessDocumentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + String name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString(); + ProcessResponse response = documentProcessorServiceClient.processDocument(name); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_processdocument_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/AsyncReviewDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/AsyncReviewDocument.java new file mode 100644 index 00000000..c0691f64 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/AsyncReviewDocument.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_reviewdocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.HumanReviewConfigName; +import com.google.cloud.documentai.v1.ReviewDocumentRequest; +import com.google.longrunning.Operation; + +public class AsyncReviewDocument { + + public static void main(String[] args) throws Exception { + asyncReviewDocument(); + } + + public static void asyncReviewDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ReviewDocumentRequest request = + ReviewDocumentRequest.newBuilder() + .setHumanReviewConfig( + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setEnableSchemaValidation(true) + .build(); + ApiFuture future = + documentProcessorServiceClient.reviewDocumentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_reviewdocument_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/AsyncReviewDocumentLRO.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/AsyncReviewDocumentLRO.java new file mode 100644 index 00000000..a6db4fa2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/AsyncReviewDocumentLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_reviewdocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.HumanReviewConfigName; +import com.google.cloud.documentai.v1.ReviewDocumentOperationMetadata; +import com.google.cloud.documentai.v1.ReviewDocumentRequest; +import com.google.cloud.documentai.v1.ReviewDocumentResponse; + +public class AsyncReviewDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncReviewDocumentLRO(); + } + + public static void asyncReviewDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ReviewDocumentRequest request = + ReviewDocumentRequest.newBuilder() + .setHumanReviewConfig( + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setEnableSchemaValidation(true) + .build(); + OperationFuture future = + documentProcessorServiceClient.reviewDocumentOperationCallable().futureCall(request); + // Do something. + ReviewDocumentResponse response = future.get(); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_reviewdocument_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocument.java new file mode 100644 index 00000000..68714cea --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocument.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_reviewdocument_sync] +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.HumanReviewConfigName; +import com.google.cloud.documentai.v1.ReviewDocumentRequest; +import com.google.cloud.documentai.v1.ReviewDocumentResponse; + +public class SyncReviewDocument { + + public static void main(String[] args) throws Exception { + syncReviewDocument(); + } + + public static void syncReviewDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ReviewDocumentRequest request = + ReviewDocumentRequest.newBuilder() + .setHumanReviewConfig( + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setEnableSchemaValidation(true) + .build(); + ReviewDocumentResponse response = + documentProcessorServiceClient.reviewDocumentAsync(request).get(); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_reviewdocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentHumanreviewconfigname.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentHumanreviewconfigname.java new file mode 100644 index 00000000..ededd882 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentHumanreviewconfigname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_reviewdocument_humanreviewconfigname_sync] +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.HumanReviewConfigName; +import com.google.cloud.documentai.v1.ReviewDocumentResponse; + +public class SyncReviewDocumentHumanreviewconfigname { + + public static void main(String[] args) throws Exception { + syncReviewDocumentHumanreviewconfigname(); + } + + public static void syncReviewDocumentHumanreviewconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + HumanReviewConfigName humanReviewConfig = + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + ReviewDocumentResponse response = + documentProcessorServiceClient.reviewDocumentAsync(humanReviewConfig).get(); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_reviewdocument_humanreviewconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentString.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentString.java new file mode 100644 index 00000000..97e4a502 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorserviceclient_reviewdocument_string_sync] +import com.google.cloud.documentai.v1.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1.HumanReviewConfigName; +import com.google.cloud.documentai.v1.ReviewDocumentResponse; + +public class SyncReviewDocumentString { + + public static void main(String[] args) throws Exception { + syncReviewDocumentString(); + } + + public static void syncReviewDocumentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + String humanReviewConfig = + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString(); + ReviewDocumentResponse response = + documentProcessorServiceClient.reviewDocumentAsync(humanReviewConfig).get(); + } + } +} +// [END documentai_v1_generated_documentprocessorserviceclient_reviewdocument_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorservicesettings/processdocument/SyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorservicesettings/processdocument/SyncProcessDocument.java new file mode 100644 index 00000000..32cac420 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/documentprocessorservicesettings/processdocument/SyncProcessDocument.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.samples; + +// [START documentai_v1_generated_documentprocessorservicesettings_processdocument_sync] +import com.google.cloud.documentai.v1.DocumentProcessorServiceSettings; +import java.time.Duration; + +public class SyncProcessDocument { + + public static void main(String[] args) throws Exception { + syncProcessDocument(); + } + + public static void syncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentProcessorServiceSettings.Builder documentProcessorServiceSettingsBuilder = + DocumentProcessorServiceSettings.newBuilder(); + documentProcessorServiceSettingsBuilder + .processDocumentSettings() + .setRetrySettings( + documentProcessorServiceSettingsBuilder + .processDocumentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentProcessorServiceSettings documentProcessorServiceSettings = + documentProcessorServiceSettingsBuilder.build(); + } +} +// [END documentai_v1_generated_documentprocessorservicesettings_processdocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1/stub/documentprocessorservicestubsettings/processdocument/SyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1/stub/documentprocessorservicestubsettings/processdocument/SyncProcessDocument.java new file mode 100644 index 00000000..34e358e6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1/stub/documentprocessorservicestubsettings/processdocument/SyncProcessDocument.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1.stub.samples; + +// [START documentai_v1_generated_documentprocessorservicestubsettings_processdocument_sync] +import com.google.cloud.documentai.v1.stub.DocumentProcessorServiceStubSettings; +import java.time.Duration; + +public class SyncProcessDocument { + + public static void main(String[] args) throws Exception { + syncProcessDocument(); + } + + public static void syncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentProcessorServiceStubSettings.Builder documentProcessorServiceSettingsBuilder = + DocumentProcessorServiceStubSettings.newBuilder(); + documentProcessorServiceSettingsBuilder + .processDocumentSettings() + .setRetrySettings( + documentProcessorServiceSettingsBuilder + .processDocumentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentProcessorServiceStubSettings documentProcessorServiceSettings = + documentProcessorServiceSettingsBuilder.build(); + } +} +// [END documentai_v1_generated_documentprocessorservicestubsettings_processdocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java new file mode 100644 index 00000000..8f691918 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta1.samples; + +// [START documentai_v1beta1_generated_documentunderstandingserviceclient_batchprocessdocuments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest; +import com.google.cloud.documentai.v1beta1.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta1.ProcessDocumentRequest; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncBatchProcessDocuments { + + public static void main(String[] args) throws Exception { + asyncBatchProcessDocuments(); + } + + public static void asyncBatchProcessDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create()) { + BatchProcessDocumentsRequest request = + BatchProcessDocumentsRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + ApiFuture future = + documentUnderstandingServiceClient.batchProcessDocumentsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END documentai_v1beta1_generated_documentunderstandingserviceclient_batchprocessdocuments_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java new file mode 100644 index 00000000..9d5a373f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta1.samples; + +// [START documentai_v1beta1_generated_documentunderstandingserviceclient_batchprocessdocuments_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest; +import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsResponse; +import com.google.cloud.documentai.v1beta1.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta1.OperationMetadata; +import com.google.cloud.documentai.v1beta1.ProcessDocumentRequest; +import java.util.ArrayList; + +public class AsyncBatchProcessDocumentsLRO { + + public static void main(String[] args) throws Exception { + asyncBatchProcessDocumentsLRO(); + } + + public static void asyncBatchProcessDocumentsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create()) { + BatchProcessDocumentsRequest request = + BatchProcessDocumentsRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + OperationFuture future = + documentUnderstandingServiceClient + .batchProcessDocumentsOperationCallable() + .futureCall(request); + // Do something. + BatchProcessDocumentsResponse response = future.get(); + } + } +} +// [END documentai_v1beta1_generated_documentunderstandingserviceclient_batchprocessdocuments_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java new file mode 100644 index 00000000..91607eb1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta1.samples; + +// [START documentai_v1beta1_generated_documentunderstandingserviceclient_batchprocessdocuments_sync] +import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest; +import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsResponse; +import com.google.cloud.documentai.v1beta1.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta1.ProcessDocumentRequest; +import java.util.ArrayList; + +public class SyncBatchProcessDocuments { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocuments(); + } + + public static void syncBatchProcessDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create()) { + BatchProcessDocumentsRequest request = + BatchProcessDocumentsRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + BatchProcessDocumentsResponse response = + documentUnderstandingServiceClient.batchProcessDocumentsAsync(request).get(); + } + } +} +// [END documentai_v1beta1_generated_documentunderstandingserviceclient_batchprocessdocuments_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsListprocessdocumentrequest.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsListprocessdocumentrequest.java new file mode 100644 index 00000000..53be6028 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsListprocessdocumentrequest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta1.samples; + +// [START documentai_v1beta1_generated_documentunderstandingserviceclient_batchprocessdocuments_listprocessdocumentrequest_sync] +import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsResponse; +import com.google.cloud.documentai.v1beta1.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta1.ProcessDocumentRequest; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchProcessDocumentsListprocessdocumentrequest { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocumentsListprocessdocumentrequest(); + } + + public static void syncBatchProcessDocumentsListprocessdocumentrequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create()) { + List requests = new ArrayList<>(); + BatchProcessDocumentsResponse response = + documentUnderstandingServiceClient.batchProcessDocumentsAsync(requests).get(); + } + } +} +// [END documentai_v1beta1_generated_documentunderstandingserviceclient_batchprocessdocuments_listprocessdocumentrequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..c0038171 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta1.samples; + +// [START documentai_v1beta1_generated_documentunderstandingserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.documentai.v1beta1.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta1.DocumentUnderstandingServiceSettings; +import com.google.cloud.documentai.v1beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings = + DocumentUnderstandingServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create(documentUnderstandingServiceSettings); + } +} +// [END documentai_v1beta1_generated_documentunderstandingserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..160894e1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta1.samples; + +// [START documentai_v1beta1_generated_documentunderstandingserviceclient_create_setendpoint_sync] +import com.google.cloud.documentai.v1beta1.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta1.DocumentUnderstandingServiceSettings; +import com.google.cloud.documentai.v1beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings = + DocumentUnderstandingServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create(documentUnderstandingServiceSettings); + } +} +// [END documentai_v1beta1_generated_documentunderstandingserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingservicesettings/batchprocessdocuments/SyncBatchProcessDocuments.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingservicesettings/batchprocessdocuments/SyncBatchProcessDocuments.java new file mode 100644 index 00000000..ff1063cc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/documentunderstandingservicesettings/batchprocessdocuments/SyncBatchProcessDocuments.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta1.samples; + +// [START documentai_v1beta1_generated_documentunderstandingservicesettings_batchprocessdocuments_sync] +import com.google.cloud.documentai.v1beta1.DocumentUnderstandingServiceSettings; +import java.time.Duration; + +public class SyncBatchProcessDocuments { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocuments(); + } + + public static void syncBatchProcessDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentUnderstandingServiceSettings.Builder documentUnderstandingServiceSettingsBuilder = + DocumentUnderstandingServiceSettings.newBuilder(); + documentUnderstandingServiceSettingsBuilder + .batchProcessDocumentsSettings() + .setRetrySettings( + documentUnderstandingServiceSettingsBuilder + .batchProcessDocumentsSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings = + documentUnderstandingServiceSettingsBuilder.build(); + } +} +// [END documentai_v1beta1_generated_documentunderstandingservicesettings_batchprocessdocuments_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta1/stub/documentunderstandingservicestubsettings/batchprocessdocuments/SyncBatchProcessDocuments.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/stub/documentunderstandingservicestubsettings/batchprocessdocuments/SyncBatchProcessDocuments.java new file mode 100644 index 00000000..1f27c8a7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta1/stub/documentunderstandingservicestubsettings/batchprocessdocuments/SyncBatchProcessDocuments.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta1.stub.samples; + +// [START documentai_v1beta1_generated_documentunderstandingservicestubsettings_batchprocessdocuments_sync] +import com.google.cloud.documentai.v1beta1.stub.DocumentUnderstandingServiceStubSettings; +import java.time.Duration; + +public class SyncBatchProcessDocuments { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocuments(); + } + + public static void syncBatchProcessDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentUnderstandingServiceStubSettings.Builder documentUnderstandingServiceSettingsBuilder = + DocumentUnderstandingServiceStubSettings.newBuilder(); + documentUnderstandingServiceSettingsBuilder + .batchProcessDocumentsSettings() + .setRetrySettings( + documentUnderstandingServiceSettingsBuilder + .batchProcessDocumentsSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentUnderstandingServiceStubSettings documentUnderstandingServiceSettings = + documentUnderstandingServiceSettingsBuilder.build(); + } +} +// [END documentai_v1beta1_generated_documentunderstandingservicestubsettings_batchprocessdocuments_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java new file mode 100644 index 00000000..90026c4f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta2.samples; + +// [START documentai_v1beta2_generated_documentunderstandingserviceclient_batchprocessdocuments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest; +import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta2.ProcessDocumentRequest; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncBatchProcessDocuments { + + public static void main(String[] args) throws Exception { + asyncBatchProcessDocuments(); + } + + public static void asyncBatchProcessDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create()) { + BatchProcessDocumentsRequest request = + BatchProcessDocumentsRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + ApiFuture future = + documentUnderstandingServiceClient.batchProcessDocumentsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END documentai_v1beta2_generated_documentunderstandingserviceclient_batchprocessdocuments_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java new file mode 100644 index 00000000..5e593604 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta2.samples; + +// [START documentai_v1beta2_generated_documentunderstandingserviceclient_batchprocessdocuments_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest; +import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsResponse; +import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta2.OperationMetadata; +import com.google.cloud.documentai.v1beta2.ProcessDocumentRequest; +import java.util.ArrayList; + +public class AsyncBatchProcessDocumentsLRO { + + public static void main(String[] args) throws Exception { + asyncBatchProcessDocumentsLRO(); + } + + public static void asyncBatchProcessDocumentsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create()) { + BatchProcessDocumentsRequest request = + BatchProcessDocumentsRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + OperationFuture future = + documentUnderstandingServiceClient + .batchProcessDocumentsOperationCallable() + .futureCall(request); + // Do something. + BatchProcessDocumentsResponse response = future.get(); + } + } +} +// [END documentai_v1beta2_generated_documentunderstandingserviceclient_batchprocessdocuments_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java new file mode 100644 index 00000000..a78ef890 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta2.samples; + +// [START documentai_v1beta2_generated_documentunderstandingserviceclient_batchprocessdocuments_sync] +import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest; +import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsResponse; +import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta2.ProcessDocumentRequest; +import java.util.ArrayList; + +public class SyncBatchProcessDocuments { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocuments(); + } + + public static void syncBatchProcessDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create()) { + BatchProcessDocumentsRequest request = + BatchProcessDocumentsRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + BatchProcessDocumentsResponse response = + documentUnderstandingServiceClient.batchProcessDocumentsAsync(request).get(); + } + } +} +// [END documentai_v1beta2_generated_documentunderstandingserviceclient_batchprocessdocuments_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsListprocessdocumentrequest.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsListprocessdocumentrequest.java new file mode 100644 index 00000000..1c83d28c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsListprocessdocumentrequest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta2.samples; + +// [START documentai_v1beta2_generated_documentunderstandingserviceclient_batchprocessdocuments_listprocessdocumentrequest_sync] +import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsResponse; +import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta2.ProcessDocumentRequest; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchProcessDocumentsListprocessdocumentrequest { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocumentsListprocessdocumentrequest(); + } + + public static void syncBatchProcessDocumentsListprocessdocumentrequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create()) { + List requests = new ArrayList<>(); + BatchProcessDocumentsResponse response = + documentUnderstandingServiceClient.batchProcessDocumentsAsync(requests).get(); + } + } +} +// [END documentai_v1beta2_generated_documentunderstandingserviceclient_batchprocessdocuments_listprocessdocumentrequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..bb40e379 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta2.samples; + +// [START documentai_v1beta2_generated_documentunderstandingserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceSettings; +import com.google.cloud.documentai.v1beta2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings = + DocumentUnderstandingServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create(documentUnderstandingServiceSettings); + } +} +// [END documentai_v1beta2_generated_documentunderstandingserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..0ec97dc4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta2.samples; + +// [START documentai_v1beta2_generated_documentunderstandingserviceclient_create_setendpoint_sync] +import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceSettings; +import com.google.cloud.documentai.v1beta2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings = + DocumentUnderstandingServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create(documentUnderstandingServiceSettings); + } +} +// [END documentai_v1beta2_generated_documentunderstandingserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/processdocument/AsyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/processdocument/AsyncProcessDocument.java new file mode 100644 index 00000000..4d8a080a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/processdocument/AsyncProcessDocument.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta2.samples; + +// [START documentai_v1beta2_generated_documentunderstandingserviceclient_processdocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta2.AutoMlParams; +import com.google.cloud.documentai.v1beta2.Document; +import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta2.EntityExtractionParams; +import com.google.cloud.documentai.v1beta2.FormExtractionParams; +import com.google.cloud.documentai.v1beta2.InputConfig; +import com.google.cloud.documentai.v1beta2.OcrParams; +import com.google.cloud.documentai.v1beta2.OutputConfig; +import com.google.cloud.documentai.v1beta2.ProcessDocumentRequest; +import com.google.cloud.documentai.v1beta2.TableExtractionParams; + +public class AsyncProcessDocument { + + public static void main(String[] args) throws Exception { + asyncProcessDocument(); + } + + public static void asyncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create()) { + ProcessDocumentRequest request = + ProcessDocumentRequest.newBuilder() + .setParent("parent-995424086") + .setInputConfig(InputConfig.newBuilder().build()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .setDocumentType("documentType-1473196299") + .setTableExtractionParams(TableExtractionParams.newBuilder().build()) + .setFormExtractionParams(FormExtractionParams.newBuilder().build()) + .setEntityExtractionParams(EntityExtractionParams.newBuilder().build()) + .setOcrParams(OcrParams.newBuilder().build()) + .setAutomlParams(AutoMlParams.newBuilder().build()) + .build(); + ApiFuture future = + documentUnderstandingServiceClient.processDocumentCallable().futureCall(request); + // Do something. + Document response = future.get(); + } + } +} +// [END documentai_v1beta2_generated_documentunderstandingserviceclient_processdocument_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/processdocument/SyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/processdocument/SyncProcessDocument.java new file mode 100644 index 00000000..2368f200 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingserviceclient/processdocument/SyncProcessDocument.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta2.samples; + +// [START documentai_v1beta2_generated_documentunderstandingserviceclient_processdocument_sync] +import com.google.cloud.documentai.v1beta2.AutoMlParams; +import com.google.cloud.documentai.v1beta2.Document; +import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient; +import com.google.cloud.documentai.v1beta2.EntityExtractionParams; +import com.google.cloud.documentai.v1beta2.FormExtractionParams; +import com.google.cloud.documentai.v1beta2.InputConfig; +import com.google.cloud.documentai.v1beta2.OcrParams; +import com.google.cloud.documentai.v1beta2.OutputConfig; +import com.google.cloud.documentai.v1beta2.ProcessDocumentRequest; +import com.google.cloud.documentai.v1beta2.TableExtractionParams; + +public class SyncProcessDocument { + + public static void main(String[] args) throws Exception { + syncProcessDocument(); + } + + public static void syncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = + DocumentUnderstandingServiceClient.create()) { + ProcessDocumentRequest request = + ProcessDocumentRequest.newBuilder() + .setParent("parent-995424086") + .setInputConfig(InputConfig.newBuilder().build()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .setDocumentType("documentType-1473196299") + .setTableExtractionParams(TableExtractionParams.newBuilder().build()) + .setFormExtractionParams(FormExtractionParams.newBuilder().build()) + .setEntityExtractionParams(EntityExtractionParams.newBuilder().build()) + .setOcrParams(OcrParams.newBuilder().build()) + .setAutomlParams(AutoMlParams.newBuilder().build()) + .build(); + Document response = documentUnderstandingServiceClient.processDocument(request); + } + } +} +// [END documentai_v1beta2_generated_documentunderstandingserviceclient_processdocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingservicesettings/processdocument/SyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingservicesettings/processdocument/SyncProcessDocument.java new file mode 100644 index 00000000..56cff858 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/documentunderstandingservicesettings/processdocument/SyncProcessDocument.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta2.samples; + +// [START documentai_v1beta2_generated_documentunderstandingservicesettings_processdocument_sync] +import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceSettings; +import java.time.Duration; + +public class SyncProcessDocument { + + public static void main(String[] args) throws Exception { + syncProcessDocument(); + } + + public static void syncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentUnderstandingServiceSettings.Builder documentUnderstandingServiceSettingsBuilder = + DocumentUnderstandingServiceSettings.newBuilder(); + documentUnderstandingServiceSettingsBuilder + .processDocumentSettings() + .setRetrySettings( + documentUnderstandingServiceSettingsBuilder + .processDocumentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings = + documentUnderstandingServiceSettingsBuilder.build(); + } +} +// [END documentai_v1beta2_generated_documentunderstandingservicesettings_processdocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta2/stub/documentunderstandingservicestubsettings/processdocument/SyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/stub/documentunderstandingservicestubsettings/processdocument/SyncProcessDocument.java new file mode 100644 index 00000000..119a1172 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta2/stub/documentunderstandingservicestubsettings/processdocument/SyncProcessDocument.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta2.stub.samples; + +// [START documentai_v1beta2_generated_documentunderstandingservicestubsettings_processdocument_sync] +import com.google.cloud.documentai.v1beta2.stub.DocumentUnderstandingServiceStubSettings; +import java.time.Duration; + +public class SyncProcessDocument { + + public static void main(String[] args) throws Exception { + syncProcessDocument(); + } + + public static void syncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentUnderstandingServiceStubSettings.Builder documentUnderstandingServiceSettingsBuilder = + DocumentUnderstandingServiceStubSettings.newBuilder(); + documentUnderstandingServiceSettingsBuilder + .processDocumentSettings() + .setRetrySettings( + documentUnderstandingServiceSettingsBuilder + .processDocumentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentUnderstandingServiceStubSettings documentUnderstandingServiceSettings = + documentUnderstandingServiceSettingsBuilder.build(); + } +} +// [END documentai_v1beta2_generated_documentunderstandingservicestubsettings_processdocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java new file mode 100644 index 00000000..d4d23ca4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocuments.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_batchprocessdocuments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig; +import com.google.cloud.documentai.v1beta3.BatchProcessRequest; +import com.google.cloud.documentai.v1beta3.DocumentOutputConfig; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncBatchProcessDocuments { + + public static void main(String[] args) throws Exception { + asyncBatchProcessDocuments(); + } + + public static void asyncBatchProcessDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + BatchProcessRequest request = + BatchProcessRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(BatchProcessRequest.BatchOutputConfig.newBuilder().build()) + .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setSkipHumanReview(true) + .build(); + ApiFuture future = + documentProcessorServiceClient.batchProcessDocumentsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_batchprocessdocuments_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java new file mode 100644 index 00000000..de56a225 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/AsyncBatchProcessDocumentsLRO.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_batchprocessdocuments_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig; +import com.google.cloud.documentai.v1beta3.BatchProcessMetadata; +import com.google.cloud.documentai.v1beta3.BatchProcessRequest; +import com.google.cloud.documentai.v1beta3.BatchProcessResponse; +import com.google.cloud.documentai.v1beta3.DocumentOutputConfig; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; +import java.util.ArrayList; + +public class AsyncBatchProcessDocumentsLRO { + + public static void main(String[] args) throws Exception { + asyncBatchProcessDocumentsLRO(); + } + + public static void asyncBatchProcessDocumentsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + BatchProcessRequest request = + BatchProcessRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(BatchProcessRequest.BatchOutputConfig.newBuilder().build()) + .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setSkipHumanReview(true) + .build(); + OperationFuture future = + documentProcessorServiceClient + .batchProcessDocumentsOperationCallable() + .futureCall(request); + // Do something. + BatchProcessResponse response = future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_batchprocessdocuments_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java new file mode 100644 index 00000000..fe2f497c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocuments.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_batchprocessdocuments_sync] +import com.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig; +import com.google.cloud.documentai.v1beta3.BatchProcessRequest; +import com.google.cloud.documentai.v1beta3.BatchProcessResponse; +import com.google.cloud.documentai.v1beta3.DocumentOutputConfig; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; +import java.util.ArrayList; + +public class SyncBatchProcessDocuments { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocuments(); + } + + public static void syncBatchProcessDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + BatchProcessRequest request = + BatchProcessRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(BatchProcessRequest.BatchOutputConfig.newBuilder().build()) + .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setSkipHumanReview(true) + .build(); + BatchProcessResponse response = + documentProcessorServiceClient.batchProcessDocumentsAsync(request).get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_batchprocessdocuments_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsProcessorname.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsProcessorname.java new file mode 100644 index 00000000..8dbb9858 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsProcessorname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_batchprocessdocuments_processorname_sync] +import com.google.cloud.documentai.v1beta3.BatchProcessResponse; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; + +public class SyncBatchProcessDocumentsProcessorname { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocumentsProcessorname(); + } + + public static void syncBatchProcessDocumentsProcessorname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + BatchProcessResponse response = + documentProcessorServiceClient.batchProcessDocumentsAsync(name).get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_batchprocessdocuments_processorname_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsString.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsString.java new file mode 100644 index 00000000..7859be78 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/batchprocessdocuments/SyncBatchProcessDocumentsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_batchprocessdocuments_string_sync] +import com.google.cloud.documentai.v1beta3.BatchProcessResponse; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; + +public class SyncBatchProcessDocumentsString { + + public static void main(String[] args) throws Exception { + syncBatchProcessDocumentsString(); + } + + public static void syncBatchProcessDocumentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + String name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString(); + BatchProcessResponse response = + documentProcessorServiceClient.batchProcessDocumentsAsync(name).get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_batchprocessdocuments_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..e8e8d539 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceSettings; +import com.google.cloud.documentai.v1beta3.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentProcessorServiceSettings documentProcessorServiceSettings = + DocumentProcessorServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create(documentProcessorServiceSettings); + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..6f31ddc7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentProcessorServiceSettings documentProcessorServiceSettings = + DocumentProcessorServiceSettings.newBuilder() + .setTransportChannelProvider( + DocumentProcessorServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create(documentProcessorServiceSettings); + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..08226d2b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_create_setendpoint_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceSettings; +import com.google.cloud.documentai.v1beta3.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentProcessorServiceSettings documentProcessorServiceSettings = + DocumentProcessorServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create(documentProcessorServiceSettings); + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/AsyncCreateProcessor.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/AsyncCreateProcessor.java new file mode 100644 index 00000000..9b8cc546 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/AsyncCreateProcessor.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_createprocessor_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta3.CreateProcessorRequest; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.LocationName; +import com.google.cloud.documentai.v1beta3.Processor; + +public class AsyncCreateProcessor { + + public static void main(String[] args) throws Exception { + asyncCreateProcessor(); + } + + public static void asyncCreateProcessor() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + CreateProcessorRequest request = + CreateProcessorRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProcessor(Processor.newBuilder().build()) + .build(); + ApiFuture future = + documentProcessorServiceClient.createProcessorCallable().futureCall(request); + // Do something. + Processor response = future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_createprocessor_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessor.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessor.java new file mode 100644 index 00000000..f5120dc5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessor.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_createprocessor_sync] +import com.google.cloud.documentai.v1beta3.CreateProcessorRequest; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.LocationName; +import com.google.cloud.documentai.v1beta3.Processor; + +public class SyncCreateProcessor { + + public static void main(String[] args) throws Exception { + syncCreateProcessor(); + } + + public static void syncCreateProcessor() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + CreateProcessorRequest request = + CreateProcessorRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProcessor(Processor.newBuilder().build()) + .build(); + Processor response = documentProcessorServiceClient.createProcessor(request); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_createprocessor_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessorLocationnameProcessor.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessorLocationnameProcessor.java new file mode 100644 index 00000000..ef1ba3c4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessorLocationnameProcessor.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_createprocessor_locationnameprocessor_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.LocationName; +import com.google.cloud.documentai.v1beta3.Processor; + +public class SyncCreateProcessorLocationnameProcessor { + + public static void main(String[] args) throws Exception { + syncCreateProcessorLocationnameProcessor(); + } + + public static void syncCreateProcessorLocationnameProcessor() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Processor processor = Processor.newBuilder().build(); + Processor response = documentProcessorServiceClient.createProcessor(parent, processor); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_createprocessor_locationnameprocessor_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessorStringProcessor.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessorStringProcessor.java new file mode 100644 index 00000000..35161829 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/createprocessor/SyncCreateProcessorStringProcessor.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_createprocessor_stringprocessor_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.LocationName; +import com.google.cloud.documentai.v1beta3.Processor; + +public class SyncCreateProcessorStringProcessor { + + public static void main(String[] args) throws Exception { + syncCreateProcessorStringProcessor(); + } + + public static void syncCreateProcessorStringProcessor() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Processor processor = Processor.newBuilder().build(); + Processor response = documentProcessorServiceClient.createProcessor(parent, processor); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_createprocessor_stringprocessor_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/AsyncDeleteProcessor.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/AsyncDeleteProcessor.java new file mode 100644 index 00000000..c3a8d3e7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/AsyncDeleteProcessor.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_deleteprocessor_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta3.DeleteProcessorRequest; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; +import com.google.longrunning.Operation; + +public class AsyncDeleteProcessor { + + public static void main(String[] args) throws Exception { + asyncDeleteProcessor(); + } + + public static void asyncDeleteProcessor() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + DeleteProcessorRequest request = + DeleteProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + ApiFuture future = + documentProcessorServiceClient.deleteProcessorCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_deleteprocessor_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/AsyncDeleteProcessorLRO.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/AsyncDeleteProcessorLRO.java new file mode 100644 index 00000000..c37049b1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/AsyncDeleteProcessorLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_deleteprocessor_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.documentai.v1beta3.DeleteProcessorMetadata; +import com.google.cloud.documentai.v1beta3.DeleteProcessorRequest; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; +import com.google.protobuf.Empty; + +public class AsyncDeleteProcessorLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteProcessorLRO(); + } + + public static void asyncDeleteProcessorLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + DeleteProcessorRequest request = + DeleteProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + OperationFuture future = + documentProcessorServiceClient.deleteProcessorOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_deleteprocessor_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessor.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessor.java new file mode 100644 index 00000000..79530313 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessor.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_deleteprocessor_sync] +import com.google.cloud.documentai.v1beta3.DeleteProcessorRequest; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; +import com.google.protobuf.Empty; + +public class SyncDeleteProcessor { + + public static void main(String[] args) throws Exception { + syncDeleteProcessor(); + } + + public static void syncDeleteProcessor() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + DeleteProcessorRequest request = + DeleteProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + documentProcessorServiceClient.deleteProcessorAsync(request).get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_deleteprocessor_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessorProcessorname.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessorProcessorname.java new file mode 100644 index 00000000..c94f754d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessorProcessorname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_deleteprocessor_processorname_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; +import com.google.protobuf.Empty; + +public class SyncDeleteProcessorProcessorname { + + public static void main(String[] args) throws Exception { + syncDeleteProcessorProcessorname(); + } + + public static void syncDeleteProcessorProcessorname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + documentProcessorServiceClient.deleteProcessorAsync(name).get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_deleteprocessor_processorname_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessorString.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessorString.java new file mode 100644 index 00000000..2f093c1f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/deleteprocessor/SyncDeleteProcessorString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_deleteprocessor_string_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; +import com.google.protobuf.Empty; + +public class SyncDeleteProcessorString { + + public static void main(String[] args) throws Exception { + syncDeleteProcessorString(); + } + + public static void syncDeleteProcessorString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + String name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString(); + documentProcessorServiceClient.deleteProcessorAsync(name).get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_deleteprocessor_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/AsyncDisableProcessor.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/AsyncDisableProcessor.java new file mode 100644 index 00000000..883cf82f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/AsyncDisableProcessor.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_disableprocessor_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta3.DisableProcessorRequest; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; +import com.google.longrunning.Operation; + +public class AsyncDisableProcessor { + + public static void main(String[] args) throws Exception { + asyncDisableProcessor(); + } + + public static void asyncDisableProcessor() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + DisableProcessorRequest request = + DisableProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + ApiFuture future = + documentProcessorServiceClient.disableProcessorCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_disableprocessor_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/AsyncDisableProcessorLRO.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/AsyncDisableProcessorLRO.java new file mode 100644 index 00000000..2ece1112 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/AsyncDisableProcessorLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_disableprocessor_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.documentai.v1beta3.DisableProcessorMetadata; +import com.google.cloud.documentai.v1beta3.DisableProcessorRequest; +import com.google.cloud.documentai.v1beta3.DisableProcessorResponse; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; + +public class AsyncDisableProcessorLRO { + + public static void main(String[] args) throws Exception { + asyncDisableProcessorLRO(); + } + + public static void asyncDisableProcessorLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + DisableProcessorRequest request = + DisableProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + OperationFuture future = + documentProcessorServiceClient.disableProcessorOperationCallable().futureCall(request); + // Do something. + DisableProcessorResponse response = future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_disableprocessor_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/SyncDisableProcessor.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/SyncDisableProcessor.java new file mode 100644 index 00000000..6ee72eb5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/disableprocessor/SyncDisableProcessor.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_disableprocessor_sync] +import com.google.cloud.documentai.v1beta3.DisableProcessorRequest; +import com.google.cloud.documentai.v1beta3.DisableProcessorResponse; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessorName; + +public class SyncDisableProcessor { + + public static void main(String[] args) throws Exception { + syncDisableProcessor(); + } + + public static void syncDisableProcessor() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + DisableProcessorRequest request = + DisableProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + DisableProcessorResponse response = + documentProcessorServiceClient.disableProcessorAsync(request).get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_disableprocessor_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/AsyncEnableProcessor.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/AsyncEnableProcessor.java new file mode 100644 index 00000000..db78cce3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/AsyncEnableProcessor.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_enableprocessor_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.EnableProcessorRequest; +import com.google.cloud.documentai.v1beta3.ProcessorName; +import com.google.longrunning.Operation; + +public class AsyncEnableProcessor { + + public static void main(String[] args) throws Exception { + asyncEnableProcessor(); + } + + public static void asyncEnableProcessor() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + EnableProcessorRequest request = + EnableProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + ApiFuture future = + documentProcessorServiceClient.enableProcessorCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_enableprocessor_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/AsyncEnableProcessorLRO.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/AsyncEnableProcessorLRO.java new file mode 100644 index 00000000..77f9cd31 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/AsyncEnableProcessorLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_enableprocessor_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.EnableProcessorMetadata; +import com.google.cloud.documentai.v1beta3.EnableProcessorRequest; +import com.google.cloud.documentai.v1beta3.EnableProcessorResponse; +import com.google.cloud.documentai.v1beta3.ProcessorName; + +public class AsyncEnableProcessorLRO { + + public static void main(String[] args) throws Exception { + asyncEnableProcessorLRO(); + } + + public static void asyncEnableProcessorLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + EnableProcessorRequest request = + EnableProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + OperationFuture future = + documentProcessorServiceClient.enableProcessorOperationCallable().futureCall(request); + // Do something. + EnableProcessorResponse response = future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_enableprocessor_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/SyncEnableProcessor.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/SyncEnableProcessor.java new file mode 100644 index 00000000..aeaf467b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/enableprocessor/SyncEnableProcessor.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_enableprocessor_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.EnableProcessorRequest; +import com.google.cloud.documentai.v1beta3.EnableProcessorResponse; +import com.google.cloud.documentai.v1beta3.ProcessorName; + +public class SyncEnableProcessor { + + public static void main(String[] args) throws Exception { + syncEnableProcessor(); + } + + public static void syncEnableProcessor() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + EnableProcessorRequest request = + EnableProcessorRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .build(); + EnableProcessorResponse response = + documentProcessorServiceClient.enableProcessorAsync(request).get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_enableprocessor_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/AsyncFetchProcessorTypes.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/AsyncFetchProcessorTypes.java new file mode 100644 index 00000000..b6801043 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/AsyncFetchProcessorTypes.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_fetchprocessortypes_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest; +import com.google.cloud.documentai.v1beta3.FetchProcessorTypesResponse; +import com.google.cloud.documentai.v1beta3.LocationName; + +public class AsyncFetchProcessorTypes { + + public static void main(String[] args) throws Exception { + asyncFetchProcessorTypes(); + } + + public static void asyncFetchProcessorTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + FetchProcessorTypesRequest request = + FetchProcessorTypesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + ApiFuture future = + documentProcessorServiceClient.fetchProcessorTypesCallable().futureCall(request); + // Do something. + FetchProcessorTypesResponse response = future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_fetchprocessortypes_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypes.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypes.java new file mode 100644 index 00000000..f66ae8cf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypes.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_fetchprocessortypes_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest; +import com.google.cloud.documentai.v1beta3.FetchProcessorTypesResponse; +import com.google.cloud.documentai.v1beta3.LocationName; + +public class SyncFetchProcessorTypes { + + public static void main(String[] args) throws Exception { + syncFetchProcessorTypes(); + } + + public static void syncFetchProcessorTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + FetchProcessorTypesRequest request = + FetchProcessorTypesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + FetchProcessorTypesResponse response = + documentProcessorServiceClient.fetchProcessorTypes(request); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_fetchprocessortypes_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypesLocationname.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypesLocationname.java new file mode 100644 index 00000000..574e8f43 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypesLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_fetchprocessortypes_locationname_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.FetchProcessorTypesResponse; +import com.google.cloud.documentai.v1beta3.LocationName; + +public class SyncFetchProcessorTypesLocationname { + + public static void main(String[] args) throws Exception { + syncFetchProcessorTypesLocationname(); + } + + public static void syncFetchProcessorTypesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + FetchProcessorTypesResponse response = + documentProcessorServiceClient.fetchProcessorTypes(parent); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_fetchprocessortypes_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypesString.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypesString.java new file mode 100644 index 00000000..92139988 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/fetchprocessortypes/SyncFetchProcessorTypesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_fetchprocessortypes_string_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.FetchProcessorTypesResponse; +import com.google.cloud.documentai.v1beta3.LocationName; + +public class SyncFetchProcessorTypesString { + + public static void main(String[] args) throws Exception { + syncFetchProcessorTypesString(); + } + + public static void syncFetchProcessorTypesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + FetchProcessorTypesResponse response = + documentProcessorServiceClient.fetchProcessorTypes(parent); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_fetchprocessortypes_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/AsyncListProcessors.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/AsyncListProcessors.java new file mode 100644 index 00000000..c08b7a4a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/AsyncListProcessors.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_listprocessors_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ListProcessorsRequest; +import com.google.cloud.documentai.v1beta3.LocationName; +import com.google.cloud.documentai.v1beta3.Processor; + +public class AsyncListProcessors { + + public static void main(String[] args) throws Exception { + asyncListProcessors(); + } + + public static void asyncListProcessors() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ListProcessorsRequest request = + ListProcessorsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + documentProcessorServiceClient.listProcessorsPagedCallable().futureCall(request); + // Do something. + for (Processor element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_listprocessors_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/AsyncListProcessorsPaged.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/AsyncListProcessorsPaged.java new file mode 100644 index 00000000..17897737 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/AsyncListProcessorsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_listprocessors_paged_async] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ListProcessorsRequest; +import com.google.cloud.documentai.v1beta3.ListProcessorsResponse; +import com.google.cloud.documentai.v1beta3.LocationName; +import com.google.cloud.documentai.v1beta3.Processor; +import com.google.common.base.Strings; + +public class AsyncListProcessorsPaged { + + public static void main(String[] args) throws Exception { + asyncListProcessorsPaged(); + } + + public static void asyncListProcessorsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ListProcessorsRequest request = + ListProcessorsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListProcessorsResponse response = + documentProcessorServiceClient.listProcessorsCallable().call(request); + for (Processor element : response.getProcessorsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_listprocessors_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessors.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessors.java new file mode 100644 index 00000000..3c4d5cdb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessors.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_listprocessors_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ListProcessorsRequest; +import com.google.cloud.documentai.v1beta3.LocationName; +import com.google.cloud.documentai.v1beta3.Processor; + +public class SyncListProcessors { + + public static void main(String[] args) throws Exception { + syncListProcessors(); + } + + public static void syncListProcessors() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ListProcessorsRequest request = + ListProcessorsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Processor element : + documentProcessorServiceClient.listProcessors(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_listprocessors_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessorsLocationname.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessorsLocationname.java new file mode 100644 index 00000000..374de510 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessorsLocationname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_listprocessors_locationname_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.LocationName; +import com.google.cloud.documentai.v1beta3.Processor; + +public class SyncListProcessorsLocationname { + + public static void main(String[] args) throws Exception { + syncListProcessorsLocationname(); + } + + public static void syncListProcessorsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Processor element : documentProcessorServiceClient.listProcessors(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_listprocessors_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessorsString.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessorsString.java new file mode 100644 index 00000000..836d3b0a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/listprocessors/SyncListProcessorsString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_listprocessors_string_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.LocationName; +import com.google.cloud.documentai.v1beta3.Processor; + +public class SyncListProcessorsString { + + public static void main(String[] args) throws Exception { + syncListProcessorsString(); + } + + public static void syncListProcessorsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Processor element : documentProcessorServiceClient.listProcessors(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_listprocessors_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/AsyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/AsyncProcessDocument.java new file mode 100644 index 00000000..290511bf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/AsyncProcessDocument.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_processdocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta3.Document; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessRequest; +import com.google.cloud.documentai.v1beta3.ProcessResponse; +import com.google.cloud.documentai.v1beta3.ProcessorName; + +public class AsyncProcessDocument { + + public static void main(String[] args) throws Exception { + asyncProcessDocument(); + } + + public static void asyncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ProcessRequest request = + ProcessRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setDocument(Document.newBuilder().build()) + .setSkipHumanReview(true) + .build(); + ApiFuture future = + documentProcessorServiceClient.processDocumentCallable().futureCall(request); + // Do something. + ProcessResponse response = future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_processdocument_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocument.java new file mode 100644 index 00000000..b378eb25 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocument.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_processdocument_sync] +import com.google.cloud.documentai.v1beta3.Document; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessRequest; +import com.google.cloud.documentai.v1beta3.ProcessResponse; +import com.google.cloud.documentai.v1beta3.ProcessorName; + +public class SyncProcessDocument { + + public static void main(String[] args) throws Exception { + syncProcessDocument(); + } + + public static void syncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ProcessRequest request = + ProcessRequest.newBuilder() + .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setDocument(Document.newBuilder().build()) + .setSkipHumanReview(true) + .build(); + ProcessResponse response = documentProcessorServiceClient.processDocument(request); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_processdocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocumentProcessorname.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocumentProcessorname.java new file mode 100644 index 00000000..4d71676d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocumentProcessorname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_processdocument_processorname_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessResponse; +import com.google.cloud.documentai.v1beta3.ProcessorName; + +public class SyncProcessDocumentProcessorname { + + public static void main(String[] args) throws Exception { + syncProcessDocumentProcessorname(); + } + + public static void syncProcessDocumentProcessorname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + ProcessResponse response = documentProcessorServiceClient.processDocument(name); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_processdocument_processorname_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocumentString.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocumentString.java new file mode 100644 index 00000000..405e9c15 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/processdocument/SyncProcessDocumentString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_processdocument_string_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.ProcessResponse; +import com.google.cloud.documentai.v1beta3.ProcessorName; + +public class SyncProcessDocumentString { + + public static void main(String[] args) throws Exception { + syncProcessDocumentString(); + } + + public static void syncProcessDocumentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + String name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString(); + ProcessResponse response = documentProcessorServiceClient.processDocument(name); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_processdocument_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/AsyncReviewDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/AsyncReviewDocument.java new file mode 100644 index 00000000..08363469 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/AsyncReviewDocument.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_reviewdocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.documentai.v1beta3.Document; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.HumanReviewConfigName; +import com.google.cloud.documentai.v1beta3.ReviewDocumentRequest; +import com.google.longrunning.Operation; + +public class AsyncReviewDocument { + + public static void main(String[] args) throws Exception { + asyncReviewDocument(); + } + + public static void asyncReviewDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ReviewDocumentRequest request = + ReviewDocumentRequest.newBuilder() + .setHumanReviewConfig( + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setDocument(Document.newBuilder().build()) + .setEnableSchemaValidation(true) + .build(); + ApiFuture future = + documentProcessorServiceClient.reviewDocumentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_reviewdocument_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/AsyncReviewDocumentLRO.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/AsyncReviewDocumentLRO.java new file mode 100644 index 00000000..46124a10 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/AsyncReviewDocumentLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_reviewdocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.documentai.v1beta3.Document; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.HumanReviewConfigName; +import com.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata; +import com.google.cloud.documentai.v1beta3.ReviewDocumentRequest; +import com.google.cloud.documentai.v1beta3.ReviewDocumentResponse; + +public class AsyncReviewDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncReviewDocumentLRO(); + } + + public static void asyncReviewDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ReviewDocumentRequest request = + ReviewDocumentRequest.newBuilder() + .setHumanReviewConfig( + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setDocument(Document.newBuilder().build()) + .setEnableSchemaValidation(true) + .build(); + OperationFuture future = + documentProcessorServiceClient.reviewDocumentOperationCallable().futureCall(request); + // Do something. + ReviewDocumentResponse response = future.get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_reviewdocument_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocument.java new file mode 100644 index 00000000..ec43c9ac --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocument.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_reviewdocument_sync] +import com.google.cloud.documentai.v1beta3.Document; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.HumanReviewConfigName; +import com.google.cloud.documentai.v1beta3.ReviewDocumentRequest; +import com.google.cloud.documentai.v1beta3.ReviewDocumentResponse; + +public class SyncReviewDocument { + + public static void main(String[] args) throws Exception { + syncReviewDocument(); + } + + public static void syncReviewDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + ReviewDocumentRequest request = + ReviewDocumentRequest.newBuilder() + .setHumanReviewConfig( + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString()) + .setDocument(Document.newBuilder().build()) + .setEnableSchemaValidation(true) + .build(); + ReviewDocumentResponse response = + documentProcessorServiceClient.reviewDocumentAsync(request).get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_reviewdocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentHumanreviewconfigname.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentHumanreviewconfigname.java new file mode 100644 index 00000000..cc11d186 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentHumanreviewconfigname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_reviewdocument_humanreviewconfigname_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.HumanReviewConfigName; +import com.google.cloud.documentai.v1beta3.ReviewDocumentResponse; + +public class SyncReviewDocumentHumanreviewconfigname { + + public static void main(String[] args) throws Exception { + syncReviewDocumentHumanreviewconfigname(); + } + + public static void syncReviewDocumentHumanreviewconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + HumanReviewConfigName humanReviewConfig = + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + ReviewDocumentResponse response = + documentProcessorServiceClient.reviewDocumentAsync(humanReviewConfig).get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_reviewdocument_humanreviewconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentString.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentString.java new file mode 100644 index 00000000..6c10b860 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorserviceclient/reviewdocument/SyncReviewDocumentString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorserviceclient_reviewdocument_string_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.documentai.v1beta3.HumanReviewConfigName; +import com.google.cloud.documentai.v1beta3.ReviewDocumentResponse; + +public class SyncReviewDocumentString { + + public static void main(String[] args) throws Exception { + syncReviewDocumentString(); + } + + public static void syncReviewDocumentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentProcessorServiceClient documentProcessorServiceClient = + DocumentProcessorServiceClient.create()) { + String humanReviewConfig = + HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString(); + ReviewDocumentResponse response = + documentProcessorServiceClient.reviewDocumentAsync(humanReviewConfig).get(); + } + } +} +// [END documentai_v1beta3_generated_documentprocessorserviceclient_reviewdocument_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorservicesettings/processdocument/SyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorservicesettings/processdocument/SyncProcessDocument.java new file mode 100644 index 00000000..93d81df1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/documentprocessorservicesettings/processdocument/SyncProcessDocument.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.samples; + +// [START documentai_v1beta3_generated_documentprocessorservicesettings_processdocument_sync] +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceSettings; +import java.time.Duration; + +public class SyncProcessDocument { + + public static void main(String[] args) throws Exception { + syncProcessDocument(); + } + + public static void syncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentProcessorServiceSettings.Builder documentProcessorServiceSettingsBuilder = + DocumentProcessorServiceSettings.newBuilder(); + documentProcessorServiceSettingsBuilder + .processDocumentSettings() + .setRetrySettings( + documentProcessorServiceSettingsBuilder + .processDocumentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentProcessorServiceSettings documentProcessorServiceSettings = + documentProcessorServiceSettingsBuilder.build(); + } +} +// [END documentai_v1beta3_generated_documentprocessorservicesettings_processdocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/documentai/v1beta3/stub/documentprocessorservicestubsettings/processdocument/SyncProcessDocument.java b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/stub/documentprocessorservicestubsettings/processdocument/SyncProcessDocument.java new file mode 100644 index 00000000..f36b505d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/documentai/v1beta3/stub/documentprocessorservicestubsettings/processdocument/SyncProcessDocument.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.documentai.v1beta3.stub.samples; + +// [START documentai_v1beta3_generated_documentprocessorservicestubsettings_processdocument_sync] +import com.google.cloud.documentai.v1beta3.stub.DocumentProcessorServiceStubSettings; +import java.time.Duration; + +public class SyncProcessDocument { + + public static void main(String[] args) throws Exception { + syncProcessDocument(); + } + + public static void syncProcessDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentProcessorServiceStubSettings.Builder documentProcessorServiceSettingsBuilder = + DocumentProcessorServiceStubSettings.newBuilder(); + documentProcessorServiceSettingsBuilder + .processDocumentSettings() + .setRetrySettings( + documentProcessorServiceSettingsBuilder + .processDocumentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentProcessorServiceStubSettings documentProcessorServiceSettings = + documentProcessorServiceSettingsBuilder.build(); + } +} +// [END documentai_v1beta3_generated_documentprocessorservicestubsettings_processdocument_sync] From 375cc7f10f2c4da4be909e6b33c9d21d1c3b764d Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 24 Jun 2022 16:56:35 +0200 Subject: [PATCH 3/7] chore(deps): update dependency com.google.cloud:google-cloud-document-ai to v2.5.2 (#844) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-document-ai](https://togithub.com/googleapis/java-document-ai) | `2.5.1` -> `2.5.2` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-document-ai/2.5.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-document-ai/2.5.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-document-ai/2.5.2/compatibility-slim/2.5.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-document-ai/2.5.2/confidence-slim/2.5.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-document-ai). --- README.md | 4 ++-- samples/install-without-bom/pom.xml | 2 +- samples/snapshot/pom.xml | 2 +- samples/snippets/pom.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ce3e842f..c5d5be17 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud google-cloud-document-ai - 2.5.1 + 2.5.2 ``` @@ -42,7 +42,7 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-document-ai - 2.5.1 + 2.5.2 ``` diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 2f6e8714..8b383f69 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,7 +29,7 @@ com.google.cloud google-cloud-document-ai - 2.5.1 + 2.5.2 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index ee2d853e..03cdede1 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-document-ai - 2.5.1 + 2.5.2 diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 1a5c0253..685bd190 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -41,7 +41,7 @@ com.google.cloud google-cloud-document-ai - 2.5.1 + 2.5.2 From ed0a5c51f2306e9fa250a98f73deb06899f33552 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 19:26:27 +0000 Subject: [PATCH 4/7] chore: update dependencies for regapic (#1467) (#845) * chore: update dependencies for regapic * add more dependencies and trigger comment * update goldens * fix indentation * remove duplicate gax-httpjson dependency * remove duplicated dependencies Source-Link: https://github.com/googleapis/synthtool/commit/fa54eb2a78c6ee48613fd33152e2130e949dcbd9 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:1ec28a46062b19135b11178ceee60231e5f5a92dab454e23ae0aab72cd875906 --- .github/.OwlBot.lock.yaml | 4 ++-- .kokoro/common.sh | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 68f2b159..f0625e4d 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:58ccd4737212f64a7dd4b3063d447447acf71a2b9d409eab19fc7a00b18eadc0 -# created: 2022-06-10T19:20:11.004014696Z + digest: sha256:1ec28a46062b19135b11178ceee60231e5f5a92dab454e23ae0aab72cd875906 +# created: 2022-06-27T15:01:06.405564326Z diff --git a/.kokoro/common.sh b/.kokoro/common.sh index ace89f45..f8f957af 100644 --- a/.kokoro/common.sh +++ b/.kokoro/common.sh @@ -55,4 +55,6 @@ function retry_with_backoff { ## Helper functionss function now() { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n'; } function msg() { println "$*" >&2; } -function println() { printf '%s\n' "$(now) $*"; } \ No newline at end of file +function println() { printf '%s\n' "$(now) $*"; } + +## Helper comment to trigger updated repo dependency release \ No newline at end of file From 74763178e522484bc29aa1d82450de18dc56613c Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 28 Jun 2022 04:18:23 +0000 Subject: [PATCH 5/7] fix: update gapic-generator-java with mock service generation fixes (#846) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 457524730 Source-Link: https://github.com/googleapis/googleapis/commit/917e7f21cb1dc062744c6694437cdd46219f28cb Source-Link: https://github.com/googleapis/googleapis-gen/commit/2497f9a069d3f6b2d6810d5a4e239cda1e7e5a39 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjQ5N2Y5YTA2OWQzZjZiMmQ2ODEwZDVhNGUyMzljZGExZTdlNWEzOSJ9 --- .../cloud/documentai/v1/DocumentProcessorServiceClient.java | 2 ++ .../documentai/v1beta3/DocumentProcessorServiceClient.java | 1 + 2 files changed, 3 insertions(+) diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClient.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClient.java index 3355b300..d0747349 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClient.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClient.java @@ -16,6 +16,7 @@ package com.google.cloud.documentai.v1; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; @@ -188,6 +189,7 @@ public final com.google.longrunning.OperationsClient getOperationsClient() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ + @BetaApi public final OperationsClient getHttpJsonOperationsClient() { return httpJsonOperationsClient; } diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java index e66c4ea0..58a12665 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java @@ -199,6 +199,7 @@ public final com.google.longrunning.OperationsClient getOperationsClient() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ + @BetaApi public final OperationsClient getHttpJsonOperationsClient() { return httpJsonOperationsClient; } From 06972ce95cbc1b17940e180a183e07c7499affdd Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 02:24:23 +0000 Subject: [PATCH 6/7] chore: Disable CLIRR checks on releas (#1474) (#848) Source-Link: https://github.com/googleapis/synthtool/commit/7a220e27993a25ab3cda26510d5619d97b6952a9 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:6d4e3a15c62cfdcb823d60e16da7521e7c6fc00eba07c8ff12e4de9924a57d28 --- .github/.OwlBot.lock.yaml | 4 ++-- .kokoro/release/stage.sh | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index f0625e4d..a454a61e 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:1ec28a46062b19135b11178ceee60231e5f5a92dab454e23ae0aab72cd875906 -# created: 2022-06-27T15:01:06.405564326Z + digest: sha256:6d4e3a15c62cfdcb823d60e16da7521e7c6fc00eba07c8ff12e4de9924a57d28 +# created: 2022-06-29T23:17:33.110417661Z diff --git a/.kokoro/release/stage.sh b/.kokoro/release/stage.sh index 77dc4e8f..1dba8de1 100755 --- a/.kokoro/release/stage.sh +++ b/.kokoro/release/stage.sh @@ -32,6 +32,7 @@ retry_with_backoff 3 10 \ mvn clean deploy -B \ --settings ${MAVEN_SETTINGS_FILE} \ -DskipTests=true \ + -Dclirr.skip=true \ -DperformRelease=true \ -Dgpg.executable=gpg \ -Dgpg.passphrase=${GPG_PASSPHRASE} \ @@ -42,4 +43,4 @@ then mvn nexus-staging:release -B \ -DperformRelease=true \ --settings=settings.xml -fi \ No newline at end of file +fi From e6c71fcb545e9757cf02c64bbbd8cdaf4b3e5bb6 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 1 Jul 2022 17:38:23 +0000 Subject: [PATCH 7/7] chore(main): release 2.6.0 (#843) :robot: I have created a release *beep* *boop* --- ## [2.6.0](https://github.com/googleapis/java-document-ai/compare/v2.5.2...v2.6.0) (2022-06-30) ### Features * Enable REST transport for most of Java and Go clients ([#840](https://github.com/googleapis/java-document-ai/issues/840)) ([59f99a7](https://github.com/googleapis/java-document-ai/commit/59f99a7d47adc63811367dd1225cbbd3139bb430)) ### Bug Fixes * update gapic-generator-java with mock service generation fixes ([#846](https://github.com/googleapis/java-document-ai/issues/846)) ([7476317](https://github.com/googleapis/java-document-ai/commit/74763178e522484bc29aa1d82450de18dc56613c)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 12 +++++++++++ google-cloud-document-ai-bom/pom.xml | 20 +++++++++---------- google-cloud-document-ai/pom.xml | 4 ++-- grpc-google-cloud-document-ai-v1/pom.xml | 4 ++-- grpc-google-cloud-document-ai-v1beta1/pom.xml | 4 ++-- grpc-google-cloud-document-ai-v1beta2/pom.xml | 4 ++-- grpc-google-cloud-document-ai-v1beta3/pom.xml | 4 ++-- pom.xml | 20 +++++++++---------- proto-google-cloud-document-ai-v1/pom.xml | 4 ++-- .../pom.xml | 4 ++-- .../pom.xml | 4 ++-- .../pom.xml | 4 ++-- versions.txt | 18 ++++++++--------- 13 files changed, 59 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 469f4e82..d99fda8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [2.6.0](https://github.com/googleapis/java-document-ai/compare/v2.5.2...v2.6.0) (2022-06-30) + + +### Features + +* Enable REST transport for most of Java and Go clients ([#840](https://github.com/googleapis/java-document-ai/issues/840)) ([59f99a7](https://github.com/googleapis/java-document-ai/commit/59f99a7d47adc63811367dd1225cbbd3139bb430)) + + +### Bug Fixes + +* update gapic-generator-java with mock service generation fixes ([#846](https://github.com/googleapis/java-document-ai/issues/846)) ([7476317](https://github.com/googleapis/java-document-ai/commit/74763178e522484bc29aa1d82450de18dc56613c)) + ## [2.5.2](https://github.com/googleapis/java-document-ai/compare/v2.5.1...v2.5.2) (2022-06-23) diff --git a/google-cloud-document-ai-bom/pom.xml b/google-cloud-document-ai-bom/pom.xml index c1e7119f..df379a6a 100644 --- a/google-cloud-document-ai-bom/pom.xml +++ b/google-cloud-document-ai-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-document-ai-bom - 2.5.3-SNAPSHOT + 2.6.0 pom com.google.cloud @@ -50,47 +50,47 @@ com.google.cloud google-cloud-document-ai - 2.5.3-SNAPSHOT + 2.6.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta1 - 0.17.3-SNAPSHOT + 0.18.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta2 - 0.17.3-SNAPSHOT + 0.18.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta3 - 0.17.3-SNAPSHOT + 0.18.0 com.google.api.grpc grpc-google-cloud-document-ai-v1 - 2.5.3-SNAPSHOT + 2.6.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta1 - 0.17.3-SNAPSHOT + 0.18.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta2 - 0.17.3-SNAPSHOT + 0.18.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta3 - 0.17.3-SNAPSHOT + 0.18.0 com.google.api.grpc proto-google-cloud-document-ai-v1 - 2.5.3-SNAPSHOT + 2.6.0 diff --git a/google-cloud-document-ai/pom.xml b/google-cloud-document-ai/pom.xml index f1337f8f..489b0b74 100644 --- a/google-cloud-document-ai/pom.xml +++ b/google-cloud-document-ai/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-document-ai - 2.5.3-SNAPSHOT + 2.6.0 jar Google Cloud Document AI https://github.com/googleapis/java-document-ai @@ -11,7 +11,7 @@ com.google.cloud google-cloud-document-ai-parent - 2.5.3-SNAPSHOT + 2.6.0 google-cloud-document-ai diff --git a/grpc-google-cloud-document-ai-v1/pom.xml b/grpc-google-cloud-document-ai-v1/pom.xml index 87cbd273..88685fc6 100644 --- a/grpc-google-cloud-document-ai-v1/pom.xml +++ b/grpc-google-cloud-document-ai-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-document-ai-v1 - 2.5.3-SNAPSHOT + 2.6.0 grpc-google-cloud-document-ai-v1 GRPC library for google-cloud-document-ai com.google.cloud google-cloud-document-ai-parent - 2.5.3-SNAPSHOT + 2.6.0 diff --git a/grpc-google-cloud-document-ai-v1beta1/pom.xml b/grpc-google-cloud-document-ai-v1beta1/pom.xml index 9b1d4766..6210af00 100644 --- a/grpc-google-cloud-document-ai-v1beta1/pom.xml +++ b/grpc-google-cloud-document-ai-v1beta1/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta1 - 0.17.3-SNAPSHOT + 0.18.0 grpc-google-cloud-document-ai-v1beta1 GRPC library for grpc-google-cloud-document-ai-v1beta1 com.google.cloud google-cloud-document-ai-parent - 2.5.3-SNAPSHOT + 2.6.0 diff --git a/grpc-google-cloud-document-ai-v1beta2/pom.xml b/grpc-google-cloud-document-ai-v1beta2/pom.xml index faabe869..0e45dd6a 100644 --- a/grpc-google-cloud-document-ai-v1beta2/pom.xml +++ b/grpc-google-cloud-document-ai-v1beta2/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta2 - 0.17.3-SNAPSHOT + 0.18.0 grpc-google-cloud-document-ai-v1beta2 GRPC library for grpc-google-cloud-document-ai-v1beta2 com.google.cloud google-cloud-document-ai-parent - 2.5.3-SNAPSHOT + 2.6.0 diff --git a/grpc-google-cloud-document-ai-v1beta3/pom.xml b/grpc-google-cloud-document-ai-v1beta3/pom.xml index 426d5417..43066550 100644 --- a/grpc-google-cloud-document-ai-v1beta3/pom.xml +++ b/grpc-google-cloud-document-ai-v1beta3/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta3 - 0.17.3-SNAPSHOT + 0.18.0 grpc-google-cloud-document-ai-v1beta3 GRPC library for grpc-google-cloud-document-ai-v1beta3 com.google.cloud google-cloud-document-ai-parent - 2.5.3-SNAPSHOT + 2.6.0 diff --git a/pom.xml b/pom.xml index 19dc2be5..09e718b0 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-document-ai-parent pom - 2.5.3-SNAPSHOT + 2.6.0 Google Cloud Document AI Parent https://github.com/googleapis/java-document-ai @@ -61,47 +61,47 @@ com.google.api.grpc grpc-google-cloud-document-ai-v1beta1 - 0.17.3-SNAPSHOT + 0.18.0 com.google.api.grpc proto-google-cloud-document-ai-v1 - 2.5.3-SNAPSHOT + 2.6.0 com.google.api.grpc grpc-google-cloud-document-ai-v1 - 2.5.3-SNAPSHOT + 2.6.0 com.google.cloud google-cloud-document-ai - 2.5.3-SNAPSHOT + 2.6.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta2 - 0.17.3-SNAPSHOT + 0.18.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta3 - 0.17.3-SNAPSHOT + 0.18.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta1 - 0.17.3-SNAPSHOT + 0.18.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta2 - 0.17.3-SNAPSHOT + 0.18.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta3 - 0.17.3-SNAPSHOT + 0.18.0 diff --git a/proto-google-cloud-document-ai-v1/pom.xml b/proto-google-cloud-document-ai-v1/pom.xml index fb6e9f49..13940e68 100644 --- a/proto-google-cloud-document-ai-v1/pom.xml +++ b/proto-google-cloud-document-ai-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-document-ai-v1 - 2.5.3-SNAPSHOT + 2.6.0 proto-google-cloud-document-ai-v1 Proto library for google-cloud-document-ai com.google.cloud google-cloud-document-ai-parent - 2.5.3-SNAPSHOT + 2.6.0 diff --git a/proto-google-cloud-document-ai-v1beta1/pom.xml b/proto-google-cloud-document-ai-v1beta1/pom.xml index 8e331de9..8e557c42 100644 --- a/proto-google-cloud-document-ai-v1beta1/pom.xml +++ b/proto-google-cloud-document-ai-v1beta1/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta1 - 0.17.3-SNAPSHOT + 0.18.0 proto-google-cloud-document-ai-v1beta1 PROTO library for proto-google-cloud-document-ai-v1beta1 com.google.cloud google-cloud-document-ai-parent - 2.5.3-SNAPSHOT + 2.6.0 diff --git a/proto-google-cloud-document-ai-v1beta2/pom.xml b/proto-google-cloud-document-ai-v1beta2/pom.xml index d6be55e4..17af4cbc 100644 --- a/proto-google-cloud-document-ai-v1beta2/pom.xml +++ b/proto-google-cloud-document-ai-v1beta2/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta2 - 0.17.3-SNAPSHOT + 0.18.0 proto-google-cloud-document-ai-v1beta2 PROTO library for proto-google-cloud-document-ai-v1beta2 com.google.cloud google-cloud-document-ai-parent - 2.5.3-SNAPSHOT + 2.6.0 diff --git a/proto-google-cloud-document-ai-v1beta3/pom.xml b/proto-google-cloud-document-ai-v1beta3/pom.xml index b712b035..74422a1b 100644 --- a/proto-google-cloud-document-ai-v1beta3/pom.xml +++ b/proto-google-cloud-document-ai-v1beta3/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta3 - 0.17.3-SNAPSHOT + 0.18.0 proto-google-cloud-document-ai-v1beta3 PROTO library for proto-google-cloud-document-ai-v1beta3 com.google.cloud google-cloud-document-ai-parent - 2.5.3-SNAPSHOT + 2.6.0 diff --git a/versions.txt b/versions.txt index 1d8fef76..cae1eb8e 100644 --- a/versions.txt +++ b/versions.txt @@ -1,12 +1,12 @@ # Format: # module:released-version:current-version -google-cloud-document-ai:2.5.2:2.5.3-SNAPSHOT -grpc-google-cloud-document-ai-v1beta1:0.17.2:0.17.3-SNAPSHOT -grpc-google-cloud-document-ai-v1beta2:0.17.2:0.17.3-SNAPSHOT -grpc-google-cloud-document-ai-v1beta3:0.17.2:0.17.3-SNAPSHOT -grpc-google-cloud-document-ai-v1:2.5.2:2.5.3-SNAPSHOT -proto-google-cloud-document-ai-v1beta1:0.17.2:0.17.3-SNAPSHOT -proto-google-cloud-document-ai-v1beta2:0.17.2:0.17.3-SNAPSHOT -proto-google-cloud-document-ai-v1beta3:0.17.2:0.17.3-SNAPSHOT -proto-google-cloud-document-ai-v1:2.5.2:2.5.3-SNAPSHOT +google-cloud-document-ai:2.6.0:2.6.0 +grpc-google-cloud-document-ai-v1beta1:0.18.0:0.18.0 +grpc-google-cloud-document-ai-v1beta2:0.18.0:0.18.0 +grpc-google-cloud-document-ai-v1beta3:0.18.0:0.18.0 +grpc-google-cloud-document-ai-v1:2.6.0:2.6.0 +proto-google-cloud-document-ai-v1beta1:0.18.0:0.18.0 +proto-google-cloud-document-ai-v1beta2:0.18.0:0.18.0 +proto-google-cloud-document-ai-v1beta3:0.18.0:0.18.0 +proto-google-cloud-document-ai-v1:2.6.0:2.6.0