diff --git a/.github/readme/synth.metadata/synth.metadata b/.github/readme/synth.metadata/synth.metadata new file mode 100644 index 00000000..ac6597c9 --- /dev/null +++ b/.github/readme/synth.metadata/synth.metadata @@ -0,0 +1,18 @@ +{ + "sources": [ + { + "git": { + "name": ".", + "remote": "https://github.com/googleapis/java-document-ai.git", + "sha": "f0afd0888822e4e9d3e91d9514ba455e910fc5ee" + } + }, + { + "git": { + "name": "synthtool", + "remote": "https://github.com/googleapis/synthtool.git", + "sha": "901ddd44e9ef7887ee681b9183bbdea99437fdcc" + } + } + ] +} \ No newline at end of file diff --git a/.github/snippet-bot.yml b/.github/snippet-bot.yml new file mode 100644 index 00000000..e69de29b diff --git a/.github/workflows/approve-readme.yaml b/.github/workflows/approve-readme.yaml new file mode 100644 index 00000000..e2d841d6 --- /dev/null +++ b/.github/workflows/approve-readme.yaml @@ -0,0 +1,54 @@ +on: + pull_request: +name: auto-merge-readme +jobs: + approve: + runs-on: ubuntu-latest + if: github.repository_owner == 'googleapis' && github.head_ref == 'autosynth-readme' + steps: + - uses: actions/github-script@v3.0.0 + with: + github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} + script: | + // only approve PRs from yoshi-automation + if (context.payload.pull_request.user.login !== "yoshi-automation") { + return; + } + + // only approve PRs like "chore: release " + if (!context.payload.pull_request.title === "chore: regenerate README") { + return; + } + + // only approve PRs with README.md and synth.metadata changes + const files = new Set( + ( + await github.paginate( + github.pulls.listFiles.endpoint({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }) + ) + ).map(file => file.filename) + ); + if (files.size != 2 || !files.has("README.md") || !files.has(".github/readme/synth.metadata/synth.metadata")) { + return; + } + + // approve README regeneration PR + await github.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Rubber stamped PR!', + pull_number: context.payload.pull_request.number, + event: 'APPROVE' + }); + + // attach automerge label + await github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + labels: ['automerge'] + }); diff --git a/.github/workflows/formatting.yaml b/.github/workflows/formatting.yaml new file mode 100644 index 00000000..d4d367cf --- /dev/null +++ b/.github/workflows/formatting.yaml @@ -0,0 +1,25 @@ +on: + pull_request_target: + types: [opened, synchronize] + branches: + - master +name: format +jobs: + format-code: + runs-on: ubuntu-latest + env: + ACCESS_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} + steps: + - uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - uses: actions/setup-java@v1 + with: + java-version: 11 + - run: "mvn com.coveo:fmt-maven-plugin:format" + - uses: googleapis/code-suggester@v1.8.0 + with: + command: review + pull_number: ${{ github.event.pull_request.number }} + git_dir: '.' diff --git a/.kokoro/build.sh b/.kokoro/build.sh index d43e758a..d7cef1bd 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -69,9 +69,16 @@ integration) RETURN_CODE=$? ;; samples) - if [[ -f samples/pom.xml ]] + SAMPLES_DIR=samples + # only run ITs in snapshot/ on presubmit PRs. run ITs in all 3 samples/ subdirectories otherwise. + if [[ ! -z ${KOKORO_GITHUB_PULL_REQUEST_NUMBER} ]] then - pushd samples + SAMPLES_DIR=samples/snapshot + fi + + if [[ -f ${SAMPLES_DIR}/pom.xml ]] + then + pushd {SAMPLES_DIR} mvn -B \ -Penable-samples \ -DtrimStackTrace=false \ diff --git a/.kokoro/readme.sh b/.kokoro/readme.sh old mode 100644 new mode 100755 diff --git a/CHANGELOG.md b/CHANGELOG.md index f574ab1b..b51b6eb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +### [0.3.2](https://www.github.com/googleapis/java-document-ai/compare/v0.3.1...v0.3.2) (2020-10-22) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.12.1 ([#223](https://www.github.com/googleapis/java-document-ai/issues/223)) ([90916aa](https://www.github.com/googleapis/java-document-ai/commit/90916aad15493ce83fd5427f632a756c55213652)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.13.0 ([#227](https://www.github.com/googleapis/java-document-ai/issues/227)) ([a3d8605](https://www.github.com/googleapis/java-document-ai/commit/a3d860512fc9a35737acd939d06518fbf7fd893b)) + +### [0.3.1](https://www.github.com/googleapis/java-document-ai/compare/v0.3.0...v0.3.1) (2020-10-08) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.10.2 ([#203](https://www.github.com/googleapis/java-document-ai/issues/203)) ([053d920](https://www.github.com/googleapis/java-document-ai/commit/053d920b3863f5cf0a7010e1a73edb226c3dbd55)) + ## [0.3.0](https://www.github.com/googleapis/java-document-ai/compare/v0.2.4...v0.3.0) (2020-10-01) diff --git a/README.md b/README.md index 82ce0b76..0d420a2b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud libraries-bom - 10.1.0 + 13.1.0 pom import @@ -31,6 +31,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud google-cloud-document-ai + 0.3.0 ``` @@ -41,13 +42,11 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-document-ai - 0.2.4 + 0.3.0 ``` -[//]: # ({x-version-update-start:google-cloud-document-ai:released}) - If you are using Gradle, add this to your dependencies ```Groovy compile 'com.google.cloud:google-cloud-document-ai:0.3.0' @@ -56,7 +55,6 @@ If you are using SBT, add this to your dependencies ```Scala libraryDependencies += "com.google.cloud" % "google-cloud-document-ai" % "0.3.0" ``` -[//]: # ({x-version-update-end}) ## Authentication @@ -103,6 +101,9 @@ has instructions for running the samples. | Parse With Model Beta | [source code](https://github.com/googleapis/java-document-ai/blob/master/samples/snippets/src/main/java/documentai/v1beta2/ParseWithModelBeta.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-document-ai&page=editor&open_in_editor=samples/snippets/src/main/java/documentai/v1beta2/ParseWithModelBeta.java) | | Quick Start | [source code](https://github.com/googleapis/java-document-ai/blob/master/samples/snippets/src/main/java/documentai/v1beta2/QuickStart.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-document-ai&page=editor&open_in_editor=samples/snippets/src/main/java/documentai/v1beta2/QuickStart.java) | | Set End Point Beta | [source code](https://github.com/googleapis/java-document-ai/blob/master/samples/snippets/src/main/java/documentai/v1beta2/SetEndPointBeta.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-document-ai&page=editor&open_in_editor=samples/snippets/src/main/java/documentai/v1beta2/SetEndPointBeta.java) | +| Batch Process Document Beta | [source code](https://github.com/googleapis/java-document-ai/blob/master/samples/snippets/src/main/java/documentai/v1beta3/BatchProcessDocumentBeta.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-document-ai&page=editor&open_in_editor=samples/snippets/src/main/java/documentai/v1beta3/BatchProcessDocumentBeta.java) | +| Process Document Beta | [source code](https://github.com/googleapis/java-document-ai/blob/master/samples/snippets/src/main/java/documentai/v1beta3/ProcessDocumentBeta.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-document-ai&page=editor&open_in_editor=samples/snippets/src/main/java/documentai/v1beta3/ProcessDocumentBeta.java) | +| Quick Start | [source code](https://github.com/googleapis/java-document-ai/blob/master/samples/snippets/src/main/java/documentai/v1beta3/QuickStart.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-document-ai&page=editor&open_in_editor=samples/snippets/src/main/java/documentai/v1beta3/QuickStart.java) | diff --git a/google-cloud-document-ai-bom/pom.xml b/google-cloud-document-ai-bom/pom.xml index 82a41994..6b191845 100644 --- a/google-cloud-document-ai-bom/pom.xml +++ b/google-cloud-document-ai-bom/pom.xml @@ -3,12 +3,12 @@ 4.0.0 com.google.cloud google-cloud-document-ai-bom - 0.3.0 + 0.3.2 pom com.google.cloud google-cloud-shared-config - 0.9.2 + 0.9.3 Google Cloud Document AI BOM @@ -61,37 +61,37 @@ com.google.api.grpc proto-google-cloud-document-ai-v1beta1 - 0.3.0 + 0.3.2 com.google.api.grpc proto-google-cloud-document-ai-v1beta2 - 0.3.0 + 0.3.2 com.google.api.grpc proto-google-cloud-document-ai-v1beta3 - 0.3.0 + 0.3.2 com.google.api.grpc grpc-google-cloud-document-ai-v1beta1 - 0.3.0 + 0.3.2 com.google.api.grpc grpc-google-cloud-document-ai-v1beta2 - 0.3.0 + 0.3.2 com.google.api.grpc grpc-google-cloud-document-ai-v1beta3 - 0.3.0 + 0.3.2 com.google.cloud google-cloud-document-ai - 0.3.0 + 0.3.2 diff --git a/google-cloud-document-ai/pom.xml b/google-cloud-document-ai/pom.xml index 784dddfb..0ca741ff 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 - 0.3.0 + 0.3.2 jar Google Cloud Document AI https://github.com/googleapis/java-document-ai @@ -11,7 +11,7 @@ com.google.cloud google-cloud-document-ai-parent - 0.3.0 + 0.3.2 google-cloud-document-ai diff --git a/grpc-google-cloud-document-ai-v1beta1/pom.xml b/grpc-google-cloud-document-ai-v1beta1/pom.xml index f9620037..d76763ae 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.3.0 + 0.3.2 grpc-google-cloud-document-ai-v1beta1 GRPC library for grpc-google-cloud-document-ai-v1beta1 com.google.cloud google-cloud-document-ai-parent - 0.3.0 + 0.3.2 diff --git a/grpc-google-cloud-document-ai-v1beta2/pom.xml b/grpc-google-cloud-document-ai-v1beta2/pom.xml index 072a9e09..733265ad 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.3.0 + 0.3.2 grpc-google-cloud-document-ai-v1beta2 GRPC library for grpc-google-cloud-document-ai-v1beta2 com.google.cloud google-cloud-document-ai-parent - 0.3.0 + 0.3.2 diff --git a/grpc-google-cloud-document-ai-v1beta3/pom.xml b/grpc-google-cloud-document-ai-v1beta3/pom.xml index 5ff10c5f..b895cb8f 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.3.0 + 0.3.2 grpc-google-cloud-document-ai-v1beta3 GRPC library for grpc-google-cloud-document-ai-v1beta3 com.google.cloud google-cloud-document-ai-parent - 0.3.0 + 0.3.2 diff --git a/pom.xml b/pom.xml index 128b88dc..e4402035 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-document-ai-parent pom - 0.3.0 + 0.3.2 Google Cloud Document AI Parent https://github.com/googleapis/java-document-ai @@ -14,7 +14,7 @@ com.google.cloud google-cloud-shared-config - 0.9.2 + 0.9.3 @@ -70,38 +70,38 @@ com.google.api.grpc grpc-google-cloud-document-ai-v1beta1 - 0.3.0 + 0.3.2 com.google.api.grpc grpc-google-cloud-document-ai-v1beta2 - 0.3.0 + 0.3.2 com.google.api.grpc grpc-google-cloud-document-ai-v1beta3 - 0.3.0 + 0.3.2 com.google.api.grpc proto-google-cloud-document-ai-v1beta1 - 0.3.0 + 0.3.2 com.google.api.grpc proto-google-cloud-document-ai-v1beta2 - 0.3.0 + 0.3.2 com.google.api.grpc proto-google-cloud-document-ai-v1beta3 - 0.3.0 + 0.3.2 com.google.cloud google-cloud-shared-dependencies - 0.10.0 + 0.13.0 pom import @@ -109,7 +109,7 @@ junit junit - 4.13 + 4.13.1 test diff --git a/proto-google-cloud-document-ai-v1beta1/pom.xml b/proto-google-cloud-document-ai-v1beta1/pom.xml index 1129ac1d..c93a8f2f 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.3.0 + 0.3.2 proto-google-cloud-document-ai-v1beta1 PROTO library for proto-google-cloud-document-ai-v1beta1 com.google.cloud google-cloud-document-ai-parent - 0.3.0 + 0.3.2 diff --git a/proto-google-cloud-document-ai-v1beta2/pom.xml b/proto-google-cloud-document-ai-v1beta2/pom.xml index 43d6898b..88d1fd4a 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.3.0 + 0.3.2 proto-google-cloud-document-ai-v1beta2 PROTO library for proto-google-cloud-document-ai-v1beta2 com.google.cloud google-cloud-document-ai-parent - 0.3.0 + 0.3.2 diff --git a/proto-google-cloud-document-ai-v1beta3/pom.xml b/proto-google-cloud-document-ai-v1beta3/pom.xml index 204d8b6d..b654ff4f 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.3.0 + 0.3.2 proto-google-cloud-document-ai-v1beta3 PROTO library for proto-google-cloud-document-ai-v1beta3 com.google.cloud google-cloud-document-ai-parent - 0.3.0 + 0.3.2 diff --git a/renovate.json b/renovate.json index 58792cef..e25f2b52 100644 --- a/renovate.json +++ b/renovate.json @@ -17,24 +17,6 @@ ], "versionScheme": "docker" }, - { - "packagePatterns": [ - "^com.google.api:gax", - "^com.google.auth:", - "^com.google.cloud:google-cloud-core", - "^io.grpc:", - "^com.google.guava:" - ], - "groupName": "core dependencies" - }, - { - "packagePatterns": [ - "^com.google.http-client:", - "^com.google.oauth-client:", - "^com.google.api-client:" - ], - "groupName": "core transport dependencies" - }, { "packagePatterns": [ "*" @@ -63,6 +45,16 @@ "semanticCommitType": "chore", "semanticCommitScope": "deps" }, + { + "packagePatterns": [ + "^junit:junit", + "^com.google.truth:truth", + "^org.mockito:mockito-core", + "^org.objenesis:objenesis" + ], + "semanticCommitType": "test", + "semanticCommitScope": "deps" + }, { "packagePatterns": [ "^com.google.cloud:google-cloud-" @@ -78,4 +70,4 @@ ], "semanticCommits": true, "masterIssue": true -} \ No newline at end of file +} diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 6e63403e..5d32c863 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -14,7 +14,7 @@ com.google.cloud.samples shared-configuration - 1.0.18 + 1.0.21 @@ -29,7 +29,7 @@ com.google.cloud google-cloud-document-ai - 0.2.4 + 0.3.0 @@ -40,7 +40,7 @@ junit junit - 4.13 + 4.13.1 test diff --git a/samples/install-without-bom/resources/invoice.pdf b/samples/install-without-bom/resources/invoice.pdf new file mode 100644 index 00000000..7722734a Binary files /dev/null and b/samples/install-without-bom/resources/invoice.pdf differ diff --git a/samples/pom.xml b/samples/pom.xml index 75ecfc23..9fe9fd3c 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -18,7 +18,7 @@ com.google.cloud.samples shared-configuration - 1.0.18 + 1.0.21 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 3a8de704..5dd51349 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -14,7 +14,7 @@ com.google.cloud.samples shared-configuration - 1.0.18 + 1.0.21 @@ -28,7 +28,7 @@ com.google.cloud google-cloud-document-ai - 0.2.4 + 0.3.0 @@ -39,7 +39,7 @@ junit junit - 4.13 + 4.13.1 test diff --git a/samples/snapshot/resources/invoice.pdf b/samples/snapshot/resources/invoice.pdf new file mode 100644 index 00000000..7722734a Binary files /dev/null and b/samples/snapshot/resources/invoice.pdf differ diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 079a6d5d..e9b93feb 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -14,7 +14,7 @@ com.google.cloud.samples shared-configuration - 1.0.18 + 1.0.21 @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 11.1.0 + 13.1.0 pom import @@ -41,6 +41,7 @@ com.google.cloud google-cloud-document-ai + 0.3.0 @@ -50,7 +51,7 @@ junit junit - 4.13 + 4.13.1 test diff --git a/samples/snippets/resources/invoice.pdf b/samples/snippets/resources/invoice.pdf new file mode 100644 index 00000000..7722734a Binary files /dev/null and b/samples/snippets/resources/invoice.pdf differ diff --git a/samples/snippets/src/main/java/documentai/v1beta2/BatchParseFormBeta.java b/samples/snippets/src/main/java/documentai/v1beta2/BatchParseFormBeta.java index 916e17ff..ea46ede6 100644 --- a/samples/snippets/src/main/java/documentai/v1beta2/BatchParseFormBeta.java +++ b/samples/snippets/src/main/java/documentai/v1beta2/BatchParseFormBeta.java @@ -24,7 +24,6 @@ import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsResponse; import com.google.cloud.documentai.v1beta2.Document; import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient; -import com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceSettings; import com.google.cloud.documentai.v1beta2.FormExtractionParams; import com.google.cloud.documentai.v1beta2.GcsDestination; import com.google.cloud.documentai.v1beta2.GcsSource; diff --git a/samples/snippets/src/main/java/documentai/v1beta3/BatchProcessDocumentBeta.java b/samples/snippets/src/main/java/documentai/v1beta3/BatchProcessDocumentBeta.java new file mode 100644 index 00000000..dfd615da --- /dev/null +++ b/samples/snippets/src/main/java/documentai/v1beta3/BatchProcessDocumentBeta.java @@ -0,0 +1,170 @@ +/* + * Copyright 2020 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 + * + * http://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 documentai.v1beta3; + +// [START documentai_batch_process_document] + +import com.google.api.gax.longrunning.OperationFuture; +import com.google.api.gax.paging.Page; +import com.google.api.gax.rpc.UnknownException; +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.Document; +import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient; +import com.google.cloud.storage.Blob; +import com.google.cloud.storage.BlobId; +import com.google.cloud.storage.Bucket; +import com.google.cloud.storage.Storage; +import com.google.cloud.storage.StorageOptions; +import com.google.protobuf.util.JsonFormat; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +public class BatchProcessDocumentBeta { + public static void batchProcessDocument() + throws IOException, InterruptedException, TimeoutException, ExecutionException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "your-project-id"; + String location = "your-project-location"; // Format is "us" or "eu". + String processerId = "your-processor-id"; + String outputGcsBucketName = "your-gcs-bucket-name"; + String outputGcsPrefix = "PREFIX"; + String inputGcsUri = "gs://your-gcs-bucket/path/to/input/file.pdf"; + batchProcessDocument( + projectId, location, processerId, inputGcsUri, outputGcsBucketName, outputGcsPrefix); + } + + public static void batchProcessDocument( + String projectId, + String location, + String processorId, + String gcsInputUri, + String gcsOutputBucketName, + String gcsOutputUriPrefix) + throws IOException, InterruptedException, TimeoutException, ExecutionException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (DocumentProcessorServiceClient client = DocumentProcessorServiceClient.create()) { + // The full resource name of the processor, e.g.: + // projects/project-id/locations/location/processor/processor-id + // You must create new processors in the Cloud Console first + String name = + String.format("projects/%s/locations/%s/processors/%s", projectId, location, processorId); + + BatchProcessRequest.BatchInputConfig batchInputConfig = + BatchProcessRequest.BatchInputConfig.newBuilder() + .setGcsSource(gcsInputUri) + .setMimeType("application/pdf") + .build(); + + String fullGcsPath = String.format("gs://%s/%s/", gcsOutputBucketName, gcsOutputUriPrefix); + BatchProcessRequest.BatchOutputConfig outputConfig = + BatchProcessRequest.BatchOutputConfig.newBuilder().setGcsDestination(fullGcsPath).build(); + + // Configure the batch process request. + BatchProcessRequest request = + BatchProcessRequest.newBuilder() + .setName(name) + .addInputConfigs(batchInputConfig) + .setOutputConfig(outputConfig) + .build(); + + OperationFuture future = + client.batchProcessDocumentsAsync(request); + + // Batch process document using a long-running operation. + // You can wait for now, or get results later. + // Note: first request to the service takes longer than subsequent + // requests. + System.out.println("Waiting for operation to complete..."); + future.get(120, TimeUnit.SECONDS); + + System.out.println("Document processing complete."); + + Storage storage = StorageOptions.newBuilder().setProjectId(projectId).build().getService(); + Bucket bucket = storage.get(gcsOutputBucketName); + + // List all of the files in the Storage bucket. + Page blobs = bucket.list(Storage.BlobListOption.prefix(gcsOutputUriPrefix + "/")); + int idx = 0; + for (Blob blob : blobs.iterateAll()) { + if (!blob.isDirectory()) { + System.out.printf("Fetched file #%d\n", ++idx); + // Read the results + + // Download and store json data in a temp file. + File tempFile = File.createTempFile("file", ".json"); + Blob fileInfo = storage.get(BlobId.of(gcsOutputBucketName, blob.getName())); + fileInfo.downloadTo(tempFile.toPath()); + + // Parse json file into Document. + FileReader reader = new FileReader(tempFile); + Document.Builder builder = Document.newBuilder(); + JsonFormat.parser().merge(reader, builder); + + Document document = builder.build(); + + // Get all of the document text as one big string. + String text = document.getText(); + + // Read the text recognition output from the processor + System.out.println("The document contains the following paragraphs:"); + Document.Page page1 = document.getPages(0); + List paragraphList = page1.getParagraphsList(); + for (Document.Page.Paragraph paragraph : paragraphList) { + String paragraphText = getText(paragraph.getLayout().getTextAnchor(), text); + System.out.printf("Paragraph text:%s\n", paragraphText); + } + + // Form parsing provides additional output about + // form-formatted PDFs. You must create a form + // processor in the Cloud Console to see full field details. + System.out.println("The following form key/value pairs were detected:"); + + for (Document.Page.FormField field : page1.getFormFieldsList()) { + String fieldName = getText(field.getFieldName().getTextAnchor(), text); + String fieldValue = getText(field.getFieldValue().getTextAnchor(), text); + + System.out.println("Extracted form fields pair:"); + System.out.printf("\t(%s, %s))", fieldName, fieldValue); + } + + // Clean up temp file. + tempFile.deleteOnExit(); + } + } + } + } + + // Extract shards from the text field + private static String getText(Document.TextAnchor textAnchor, String text) { + if (textAnchor.getTextSegmentsList().size() > 0) { + int startIdx = (int) textAnchor.getTextSegments(0).getStartIndex(); + int endIdx = (int) textAnchor.getTextSegments(0).getEndIndex(); + return text.substring(startIdx, endIdx); + } + return "[NO TEXT]"; + } +} +// [END documentai_batch_process_document] diff --git a/samples/snippets/src/main/java/documentai/v1beta3/ProcessDocumentBeta.java b/samples/snippets/src/main/java/documentai/v1beta3/ProcessDocumentBeta.java new file mode 100644 index 00000000..63b79069 --- /dev/null +++ b/samples/snippets/src/main/java/documentai/v1beta3/ProcessDocumentBeta.java @@ -0,0 +1,112 @@ +/* + * Copyright 2020 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 + * + * http://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 documentai.v1beta3; + +// [START documentai_process_document] + +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.protobuf.ByteString; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +public class ProcessDocumentBeta { + public static void processDocument() + throws IOException, InterruptedException, ExecutionException, TimeoutException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "your-project-id"; + String location = "your-project-location"; // Format is "us" or "eu". + String processerId = "your-processor-id"; + String filePath = "path/to/input/file.pdf"; + processDocument(projectId, location, processerId, filePath); + } + + public static void processDocument( + String projectId, String location, String processorId, String filePath) + throws IOException, InterruptedException, ExecutionException, TimeoutException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (DocumentProcessorServiceClient client = DocumentProcessorServiceClient.create()) { + // The full resource name of the processor, e.g.: + // projects/project-id/locations/location/processor/processor-id + // You must create new processors in the Cloud Console first + String name = + String.format("projects/%s/locations/%s/processors/%s", projectId, location, processorId); + + // Read the file. + byte[] imageFileData = Files.readAllBytes(Paths.get(filePath)); + + // Convert the image data to a Buffer and base64 encode it. + ByteString content = ByteString.copyFrom(imageFileData); + + Document document = + Document.newBuilder().setContent(content).setMimeType("application/pdf").build(); + + // Configure the process request. + ProcessRequest request = + ProcessRequest.newBuilder().setName(name).setDocument(document).build(); + + // Recognizes text entities in the PDF document + ProcessResponse result = client.processDocument(request); + Document documentResponse = result.getDocument(); + + // Get all of the document text as one big string + String text = documentResponse.getText(); + + // Read the text recognition output from the processor + System.out.println("The document contains the following paragraphs:"); + Document.Page firstPage = documentResponse.getPages(0); + List paragraphs = firstPage.getParagraphsList(); + + for (Document.Page.Paragraph paragraph : paragraphs) { + String paragraphText = getText(paragraph.getLayout().getTextAnchor(), text); + System.out.printf("Paragraph text:\n%s\n", paragraphText); + } + + // Form parsing provides additional output about + // form-formatted PDFs. You must create a form + // processor in the Cloud Console to see full field details. + System.out.println("The following form key/value pairs were detected:"); + + for (Document.Page.FormField field : firstPage.getFormFieldsList()) { + String fieldName = getText(field.getFieldName().getTextAnchor(), text); + String fieldValue = getText(field.getFieldValue().getTextAnchor(), text); + + System.out.println("Extracted form fields pair:"); + System.out.printf("\t(%s, %s))\n", fieldName, fieldValue); + } + } + } + + // Extract shards from the text field + private static String getText(Document.TextAnchor textAnchor, String text) { + if (textAnchor.getTextSegmentsList().size() > 0) { + int startIdx = (int) textAnchor.getTextSegments(0).getStartIndex(); + int endIdx = (int) textAnchor.getTextSegments(0).getEndIndex(); + return text.substring(startIdx, endIdx); + } + return "[NO TEXT]"; + } +} +// [END documentai_process_document] diff --git a/samples/snippets/src/main/java/documentai/v1beta3/QuickStart.java b/samples/snippets/src/main/java/documentai/v1beta3/QuickStart.java new file mode 100644 index 00000000..f43d3aa9 --- /dev/null +++ b/samples/snippets/src/main/java/documentai/v1beta3/QuickStart.java @@ -0,0 +1,99 @@ +/* + * Copyright 2020 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 + * + * http://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 documentai.v1beta3; + +// [START documentai_quickstart] + +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.protobuf.ByteString; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +public class QuickStart { + public static void quickStart() + throws IOException, InterruptedException, ExecutionException, TimeoutException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "your-project-id"; + String location = "your-project-location"; // Format is "us" or "eu". + String processerId = "your-processor-id"; + String filePath = "path/to/input/file.pdf"; + quickStart(projectId, location, processerId, filePath); + } + + public static void quickStart( + String projectId, String location, String processorId, String filePath) + throws IOException, InterruptedException, ExecutionException, TimeoutException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (DocumentProcessorServiceClient client = DocumentProcessorServiceClient.create()) { + // The full resource name of the processor, e.g.: + // projects/project-id/locations/location/processor/processor-id + // You must create new processors in the Cloud Console first + String name = + String.format("projects/%s/locations/%s/processors/%s", projectId, location, processorId); + + // Read the file. + byte[] imageFileData = Files.readAllBytes(Paths.get(filePath)); + + // Convert the image data to a Buffer and base64 encode it. + ByteString content = ByteString.copyFrom(imageFileData); + + Document document = + Document.newBuilder().setContent(content).setMimeType("application/pdf").build(); + + // Configure the process request. + ProcessRequest request = + ProcessRequest.newBuilder().setName(name).setDocument(document).build(); + + // Recognizes text entities in the PDF document + ProcessResponse result = client.processDocument(request); + Document documentResponse = result.getDocument(); + + // Get all of the document text as one big string + String text = documentResponse.getText(); + + // Read the text recognition output from the processor + System.out.println("The document contains the following paragraphs:"); + Document.Page firstPage = documentResponse.getPages(0); + List paragraphs = firstPage.getParagraphsList(); + + for (Document.Page.Paragraph paragraph : paragraphs) { + String paragraphText = getText(paragraph.getLayout().getTextAnchor(), text); + System.out.printf("Paragraph text:\n%s\n", paragraphText); + } + } + } + + // Extract shards from the text field + private static String getText(Document.TextAnchor textAnchor, String text) { + if (textAnchor.getTextSegmentsList().size() > 0) { + int startIdx = (int) textAnchor.getTextSegments(0).getStartIndex(); + int endIdx = (int) textAnchor.getTextSegments(0).getEndIndex(); + return text.substring(startIdx, endIdx); + } + return "[NO TEXT]"; + } +} +// [END documentai_quickstart] diff --git a/samples/snippets/src/test/java/documentai/v1beta2/BatchParseTableBetaTest.java b/samples/snippets/src/test/java/documentai/v1beta2/BatchParseTableBetaTest.java index 3e012e9a..25321dbb 100644 --- a/samples/snippets/src/test/java/documentai/v1beta2/BatchParseTableBetaTest.java +++ b/samples/snippets/src/test/java/documentai/v1beta2/BatchParseTableBetaTest.java @@ -31,6 +31,7 @@ import java.util.concurrent.TimeoutException; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; public class BatchParseTableBetaTest { @@ -88,6 +89,8 @@ public void setUp() { } @Test + // https://github.com/googleapis/java-document-ai/issues/207 + @Ignore public void testBatchParseTable() throws InterruptedException, ExecutionException, TimeoutException, IOException { // parse the GCS invoice as a table. diff --git a/samples/snippets/src/test/java/documentai/v1beta2/ParseFormBetaTest.java b/samples/snippets/src/test/java/documentai/v1beta2/ParseFormBetaTest.java index c5d6f0d1..6035188a 100644 --- a/samples/snippets/src/test/java/documentai/v1beta2/ParseFormBetaTest.java +++ b/samples/snippets/src/test/java/documentai/v1beta2/ParseFormBetaTest.java @@ -56,7 +56,7 @@ public void setUp() { @Test public void testParseForm() throws InterruptedException, ExecutionException, IOException { // parse the GCS invoice as a form. - ParseFormBeta.parseForm(PROJECT_ID,"us", INPUT_URI); + ParseFormBeta.parseForm(PROJECT_ID, "us", INPUT_URI); String got = bout.toString(); assertThat(got).contains("Extracted form fields pair:"); diff --git a/samples/snippets/src/test/java/documentai/v1beta2/ParseTableBetaTest.java b/samples/snippets/src/test/java/documentai/v1beta2/ParseTableBetaTest.java index 12cb14f6..cefe288e 100644 --- a/samples/snippets/src/test/java/documentai/v1beta2/ParseTableBetaTest.java +++ b/samples/snippets/src/test/java/documentai/v1beta2/ParseTableBetaTest.java @@ -55,7 +55,7 @@ public void setUp() { @Test public void testParseTable() throws IOException { // parse the GCS invoice as a table. - ParseTableBeta.parseTable(PROJECT_ID,"us", INPUT_URI); + ParseTableBeta.parseTable(PROJECT_ID, "us", INPUT_URI); String got = bout.toString(); assertThat(got).contains("First detected language"); diff --git a/samples/snippets/src/test/java/documentai/v1beta2/QuickStartTest.java b/samples/snippets/src/test/java/documentai/v1beta2/QuickStartTest.java index 4524f70f..302f471d 100644 --- a/samples/snippets/src/test/java/documentai/v1beta2/QuickStartTest.java +++ b/samples/snippets/src/test/java/documentai/v1beta2/QuickStartTest.java @@ -55,7 +55,7 @@ public void setUp() { @Test public void testQuickStart() throws IOException { // parse a PDF document. - QuickStart.quickStart(PROJECT_ID,"us", INPUT_URI); + QuickStart.quickStart(PROJECT_ID, "us", INPUT_URI); String got = bout.toString(); assertThat(got).contains("Entity"); diff --git a/samples/snippets/src/test/java/documentai/v1beta3/BatchProcessDocumentBetaTest.java b/samples/snippets/src/test/java/documentai/v1beta3/BatchProcessDocumentBetaTest.java new file mode 100644 index 00000000..c61a859e --- /dev/null +++ b/samples/snippets/src/test/java/documentai/v1beta3/BatchProcessDocumentBetaTest.java @@ -0,0 +1,116 @@ +/* + * Copyright 2020 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 + * + * http://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 documentai.v1beta3; + +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertNotNull; + +import com.google.api.gax.paging.Page; +import com.google.cloud.storage.Blob; +import com.google.cloud.storage.BucketInfo; +import com.google.cloud.storage.Storage; +import com.google.cloud.storage.StorageOptions; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class BatchProcessDocumentBetaTest { + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String PROCESSOR_ID = "88541adc6eeec481"; + private static final String BUCKET_NAME = + String.format("document-ai-output-test-%s", UUID.randomUUID()); + private static final String INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf"; + private static final String OUTPUT_PREFIX = String.format("%s", UUID.randomUUID()); + private static final String OUTPUT_BUCKET_NAME = PROJECT_ID; + + private ByteArrayOutputStream bout; + private PrintStream out; + private PrintStream originalPrintStream; + + private static void requireEnvVar(String varName) { + assertNotNull( + String.format("Environment variable '%s' must be set to perform these tests.", varName), + System.getenv(varName)); + } + + private static void cleanUpBucket() { + Storage storage = StorageOptions.getDefaultInstance().getService(); + Page blobs = + storage.list( + BUCKET_NAME, + Storage.BlobListOption.currentDirectory(), + Storage.BlobListOption.prefix(OUTPUT_PREFIX)); + + deleteDirectory(storage, blobs); + } + + private static void deleteDirectory(Storage storage, Page blobs) { + for (Blob blob : blobs.iterateAll()) { + if (!blob.delete()) { + Page subBlobs = + storage.list( + BUCKET_NAME, + Storage.BlobListOption.currentDirectory(), + Storage.BlobListOption.prefix(blob.getName())); + + deleteDirectory(storage, subBlobs); + } + } + } + + @Before + public void checkRequirements() { + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + } + + @Before + public void setUp() { + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + originalPrintStream = System.out; + System.setOut(out); + + Storage storage = StorageOptions.getDefaultInstance().getService(); + storage.create(BucketInfo.of(BUCKET_NAME)); + } + + @Test + public void testBatchProcessDocument() + throws InterruptedException, ExecutionException, TimeoutException, IOException { + // parse the GCS invoice as a form. + BatchProcessDocumentBeta.batchProcessDocument( + PROJECT_ID, "us", PROCESSOR_ID, INPUT_URI, OUTPUT_BUCKET_NAME, OUTPUT_PREFIX); + String got = bout.toString(); + + assertThat(got).contains("Paragraph text:"); + assertThat(got).contains("Extracted"); + } + + @After + public void tearDown() { + cleanUpBucket(); + System.out.flush(); + System.setOut(originalPrintStream); + } +} diff --git a/samples/snippets/src/test/java/documentai/v1beta3/ProcessDocumentTest.java b/samples/snippets/src/test/java/documentai/v1beta3/ProcessDocumentTest.java new file mode 100644 index 00000000..c7f65b68 --- /dev/null +++ b/samples/snippets/src/test/java/documentai/v1beta3/ProcessDocumentTest.java @@ -0,0 +1,76 @@ +/* + * Copyright 2020 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 + * + * http://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 documentai.v1beta3; + +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertNotNull; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ProcessDocumentTest { + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String PROCESSOR_ID = "88541adc6eeec481"; + private static final String FILE_PATH = "resources/invoice.pdf"; + + private ByteArrayOutputStream bout; + private PrintStream out; + private PrintStream originalPrintStream; + + private static void requireEnvVar(String varName) { + assertNotNull( + String.format("Environment variable '%s' must be set to perform these tests.", varName), + System.getenv(varName)); + } + + @Before + public void checkRequirements() { + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + } + + @Before + public void setUp() { + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + originalPrintStream = System.out; + System.setOut(out); + } + + @Test + public void testProcessDocument() + throws InterruptedException, ExecutionException, IOException, TimeoutException { + // parse the GCS invoice as a form. + ProcessDocumentBeta.processDocument(PROJECT_ID, "us", PROCESSOR_ID, FILE_PATH); + String got = bout.toString(); + + assertThat(got).contains("Paragraph text:"); + assertThat(got).contains("Extracted"); + } + + @After + public void tearDown() { + System.out.flush(); + System.setOut(originalPrintStream); + } +} diff --git a/samples/snippets/src/test/java/documentai/v1beta3/QuickStartTest.java b/samples/snippets/src/test/java/documentai/v1beta3/QuickStartTest.java new file mode 100644 index 00000000..4451ef32 --- /dev/null +++ b/samples/snippets/src/test/java/documentai/v1beta3/QuickStartTest.java @@ -0,0 +1,75 @@ +/* + * Copyright 2020 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 + * + * http://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 documentai.v1beta3; + +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertNotNull; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class QuickStartTest { + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String PROCESSOR_ID = "88541adc6eeec481"; + private static final String FILE_PATH = "resources/invoice.pdf"; + + private ByteArrayOutputStream bout; + private PrintStream out; + private PrintStream originalPrintStream; + + private static void requireEnvVar(String varName) { + assertNotNull( + String.format("Environment variable '%s' must be set to perform these tests.", varName), + System.getenv(varName)); + } + + @Before + public void checkRequirements() { + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + } + + @Before + public void setUp() { + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + originalPrintStream = System.out; + System.setOut(out); + } + + @Test + public void testQuickStart() + throws InterruptedException, ExecutionException, IOException, TimeoutException { + // parse the GCS invoice as a form. + QuickStart.quickStart(PROJECT_ID, "us", PROCESSOR_ID, FILE_PATH); + String got = bout.toString(); + + assertThat(got).contains("Paragraph text:"); + } + + @After + public void tearDown() { + System.out.flush(); + System.setOut(originalPrintStream); + } +} diff --git a/synth.metadata b/synth.metadata index 1efe3214..0726bc8b 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-document-ai.git", - "sha": "57673c7fd13bc2278ff16c7e59c35a8137d03f91" + "sha": "dfa0fa45e427ac2191c904321b6a326c3acf1fe3" } }, { @@ -35,7 +35,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "8a7a3021fe97aa0a3641db642fe2b767f1c8110f" + "sha": "6abb59097be84599a1d6091fe534a49e5c5cf948" } } ], @@ -76,9 +76,12 @@ ".github/PULL_REQUEST_TEMPLATE.md", ".github/readme/synth.py", ".github/release-please.yml", + ".github/snippet-bot.yml", ".github/trusted-contribution.yml", + ".github/workflows/approve-readme.yaml", ".github/workflows/auto-release.yaml", ".github/workflows/ci.yaml", + ".github/workflows/formatting.yaml", ".github/workflows/samples.yaml", ".kokoro/build.bat", ".kokoro/build.sh", diff --git a/versions.txt b/versions.txt index 34e995fd..53e9bb4f 100644 --- a/versions.txt +++ b/versions.txt @@ -1,7 +1,7 @@ -proto-google-cloud-document-ai-v1beta1:0.3.0:0.3.0 -proto-google-cloud-document-ai-v1beta2:0.3.0:0.3.0 -proto-google-cloud-document-ai-v1beta3:0.3.0:0.3.0 -grpc-google-cloud-document-ai-v1beta1:0.3.0:0.3.0 -grpc-google-cloud-document-ai-v1beta2:0.3.0:0.3.0 -grpc-google-cloud-document-ai-v1beta3:0.3.0:0.3.0 -google-cloud-document-ai:0.3.0:0.3.0 +proto-google-cloud-document-ai-v1beta1:0.3.2:0.3.2 +proto-google-cloud-document-ai-v1beta2:0.3.2:0.3.2 +proto-google-cloud-document-ai-v1beta3:0.3.2:0.3.2 +grpc-google-cloud-document-ai-v1beta1:0.3.2:0.3.2 +grpc-google-cloud-document-ai-v1beta2:0.3.2:0.3.2 +grpc-google-cloud-document-ai-v1beta3:0.3.2:0.3.2 +google-cloud-document-ai:0.3.2:0.3.2