diff --git a/.github/release-please.yml b/.github/release-please.yml
index 82744682..dce2c845 100644
--- a/.github/release-please.yml
+++ b/.github/release-please.yml
@@ -1 +1,2 @@
releaseType: java-yoshi
+bumpMinorPreMajor: true
\ No newline at end of file
diff --git a/.github/trusted-contribution.yml b/.github/trusted-contribution.yml
new file mode 100644
index 00000000..f247d5c7
--- /dev/null
+++ b/.github/trusted-contribution.yml
@@ -0,0 +1,2 @@
+trustedContributors:
+- renovate-bot
\ No newline at end of file
diff --git a/.kokoro/build.sh b/.kokoro/build.sh
index fa132f41..e62d0321 100755
--- a/.kokoro/build.sh
+++ b/.kokoro/build.sh
@@ -27,6 +27,7 @@ echo ${JOB_TYPE}
mvn install -B -V \
-DskipTests=true \
-Dclirr.skip=true \
+ -Denforcer.skip=true \
-Dmaven.javadoc.skip=true \
-Dgcloud.download.skip=true \
-T 1C
@@ -36,25 +37,72 @@ if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTI
export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_ROOT}/src/${GOOGLE_APPLICATION_CREDENTIALS})
fi
+RETURN_CODE=0
+set +e
+
case ${JOB_TYPE} in
test)
- mvn test -B -Dclirr.skip=true
- bash ${KOKORO_GFILE_DIR}/codecov.sh
- bash .kokoro/coerce_logs.sh
+ mvn test -B -Dclirr.skip=true -Denforcer.skip=true
+ RETURN_CODE=$?
;;
lint)
- mvn com.coveo:fmt-maven-plugin:check
+ mvn \
+ -Penable-samples \
+ com.coveo:fmt-maven-plugin:check
+ RETURN_CODE=$?
;;
javadoc)
mvn javadoc:javadoc javadoc:test-javadoc
+ RETURN_CODE=$?
;;
integration)
- mvn -B ${INTEGRATION_TEST_ARGS} -DtrimStackTrace=false -Dclirr.skip=true -fae verify
- bash .kokoro/coerce_logs.sh
+ mvn -B ${INTEGRATION_TEST_ARGS} \
+ -Penable-integration-tests \
+ -DtrimStackTrace=false \
+ -Dclirr.skip=true \
+ -Denforcer.skip=true \
+ -fae \
+ verify
+ RETURN_CODE=$?
+ ;;
+samples)
+ if [[ -f samples/pom.xml ]]
+ then
+ pushd samples
+ mvn -B \
+ -Penable-samples \
+ -DtrimStackTrace=false \
+ -Dclirr.skip=true \
+ -Denforcer.skip=true \
+ -fae \
+ verify
+ RETURN_CODE=$?
+ popd
+ else
+ echo "no sample pom.xml found - skipping sample tests"
+ fi
;;
clirr)
- mvn -B clirr:check
+ mvn -B -Denforcer.skip=true clirr:check
+ RETURN_CODE=$?
;;
*)
;;
-esac
\ No newline at end of file
+esac
+
+if [ "${REPORT_COVERAGE}" == "true" ]
+then
+ bash ${KOKORO_GFILE_DIR}/codecov.sh
+fi
+
+# fix output location of logs
+bash .kokoro/coerce_logs.sh
+
+if [[ "${ENABLE_BUILD_COP}" == "true" ]]
+then
+ chmod +x ${KOKORO_GFILE_DIR}/linux_amd64/buildcop
+ ${KOKORO_GFILE_DIR}/linux_amd64/buildcop -repo=googleapis/java-document-ai
+fi
+
+echo "exiting with ${RETURN_CODE}"
+exit ${RETURN_CODE}
diff --git a/.kokoro/continuous/java8.cfg b/.kokoro/continuous/java8.cfg
index 3b017fc8..495cc7ba 100644
--- a/.kokoro/continuous/java8.cfg
+++ b/.kokoro/continuous/java8.cfg
@@ -5,3 +5,8 @@ env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
}
+
+env_vars: {
+ key: "REPORT_COVERAGE"
+ value: "true"
+}
diff --git a/.kokoro/continuous/samples.cfg b/.kokoro/continuous/samples.cfg
new file mode 100644
index 00000000..fa7b493d
--- /dev/null
+++ b/.kokoro/continuous/samples.cfg
@@ -0,0 +1,31 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/java8"
+}
+
+env_vars: {
+ key: "JOB_TYPE"
+ value: "samples"
+}
+
+env_vars: {
+ key: "GCLOUD_PROJECT"
+ value: "gcloud-devel"
+}
+
+env_vars: {
+ key: "GOOGLE_APPLICATION_CREDENTIALS"
+ value: "keystore/73713_java_it_service_account"
+}
+
+before_action {
+ fetch_keystore {
+ keystore_resource {
+ keystore_config_id: 73713
+ keyname: "java_it_service_account"
+ }
+ }
+}
diff --git a/.kokoro/dependencies.sh b/.kokoro/dependencies.sh
index 9470b9c1..f326e3cd 100755
--- a/.kokoro/dependencies.sh
+++ b/.kokoro/dependencies.sh
@@ -23,5 +23,9 @@ echo $JOB_TYPE
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"
-mvn install -DskipTests=true -B -V
+# this should run maven enforcer
+mvn install -B -V \
+ -DskipTests=true \
+ -Dclirr.skip=true
+
mvn -B dependency:analyze -DfailOnWarning=true
diff --git a/.kokoro/linkage-monitor.sh b/.kokoro/linkage-monitor.sh
index 7c94f33e..34e98e92 100755
--- a/.kokoro/linkage-monitor.sh
+++ b/.kokoro/linkage-monitor.sh
@@ -23,7 +23,12 @@ cd github/java-document-ai/
java -version
echo ${JOB_TYPE}
-mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V
+mvn install -B -V \
+ -DskipTests=true \
+ -Dclirr.skip=true \
+ -Denforcer.skip=true \
+ -Dmaven.javadoc.skip=true \
+ -Dgcloud.download.skip=true
# Kokoro job cloud-opensource-java/ubuntu/linkage-monitor-gcs creates this JAR
JAR=linkage-monitor-latest-all-deps.jar
diff --git a/.kokoro/nightly/integration.cfg b/.kokoro/nightly/integration.cfg
index 3b017fc8..8bf59c02 100644
--- a/.kokoro/nightly/integration.cfg
+++ b/.kokoro/nightly/integration.cfg
@@ -5,3 +5,17 @@ env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
}
+
+env_vars: {
+ key: "ENABLE_BUILD_COP"
+ value: "true"
+}
+
+before_action {
+ fetch_keystore {
+ keystore_resource {
+ keystore_config_id: 73713
+ keyname: "java_it_service_account"
+ }
+ }
+}
diff --git a/.kokoro/nightly/java8.cfg b/.kokoro/nightly/java8.cfg
index 3b017fc8..495cc7ba 100644
--- a/.kokoro/nightly/java8.cfg
+++ b/.kokoro/nightly/java8.cfg
@@ -5,3 +5,8 @@ env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
}
+
+env_vars: {
+ key: "REPORT_COVERAGE"
+ value: "true"
+}
diff --git a/.kokoro/nightly/samples.cfg b/.kokoro/nightly/samples.cfg
new file mode 100644
index 00000000..b4b051cd
--- /dev/null
+++ b/.kokoro/nightly/samples.cfg
@@ -0,0 +1,36 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/java8"
+}
+
+env_vars: {
+ key: "JOB_TYPE"
+ value: "samples"
+}
+
+env_vars: {
+ key: "GCLOUD_PROJECT"
+ value: "gcloud-devel"
+}
+
+env_vars: {
+ key: "GOOGLE_APPLICATION_CREDENTIALS"
+ value: "keystore/73713_java_it_service_account"
+}
+
+env_vars: {
+ key: "ENABLE_BUILD_COP"
+ value: "true"
+}
+
+before_action {
+ fetch_keystore {
+ keystore_resource {
+ keystore_config_id: 73713
+ keyname: "java_it_service_account"
+ }
+ }
+}
diff --git a/.kokoro/presubmit/java8.cfg b/.kokoro/presubmit/java8.cfg
index 3b017fc8..495cc7ba 100644
--- a/.kokoro/presubmit/java8.cfg
+++ b/.kokoro/presubmit/java8.cfg
@@ -5,3 +5,8 @@ env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
}
+
+env_vars: {
+ key: "REPORT_COVERAGE"
+ value: "true"
+}
diff --git a/.kokoro/presubmit/samples.cfg b/.kokoro/presubmit/samples.cfg
new file mode 100644
index 00000000..fa7b493d
--- /dev/null
+++ b/.kokoro/presubmit/samples.cfg
@@ -0,0 +1,31 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/java8"
+}
+
+env_vars: {
+ key: "JOB_TYPE"
+ value: "samples"
+}
+
+env_vars: {
+ key: "GCLOUD_PROJECT"
+ value: "gcloud-devel"
+}
+
+env_vars: {
+ key: "GOOGLE_APPLICATION_CREDENTIALS"
+ value: "keystore/73713_java_it_service_account"
+}
+
+before_action {
+ fetch_keystore {
+ keystore_resource {
+ keystore_config_id: 73713
+ keyname: "java_it_service_account"
+ }
+ }
+}
diff --git a/.kokoro/release/drop.cfg b/.kokoro/release/drop.cfg
index fda0dbbe..54e9e333 100644
--- a/.kokoro/release/drop.cfg
+++ b/.kokoro/release/drop.cfg
@@ -4,6 +4,3 @@ env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/java-document-ai/.kokoro/release/drop.sh"
}
-
-# Download staging properties file.
-gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/java/releases/java-document-ai"
\ No newline at end of file
diff --git a/.kokoro/release/promote.cfg b/.kokoro/release/promote.cfg
index c0da0fec..19079acd 100644
--- a/.kokoro/release/promote.cfg
+++ b/.kokoro/release/promote.cfg
@@ -4,7 +4,3 @@ env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/java-document-ai/.kokoro/release/promote.sh"
}
-
-# Download staging properties file.
-gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/java/releases/java-document-ai"
-
diff --git a/.kokoro/release/publish_javadoc.sh b/.kokoro/release/publish_javadoc.sh
index a2aaf7c2..1aa0f820 100755
--- a/.kokoro/release/publish_javadoc.sh
+++ b/.kokoro/release/publish_javadoc.sh
@@ -33,7 +33,7 @@ python3 -m pip install gcp-docuploader
# compile all packages
mvn clean install -B -DskipTests=true
-NAME=documentai
+NAME=google-cloud-document-ai
VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3)
# build the docs
diff --git a/.repo-metadata.json b/.repo-metadata.json
index 0dd1f0ae..9297f92f 100644
--- a/.repo-metadata.json
+++ b/.repo-metadata.json
@@ -1,13 +1,16 @@
{
"name": "documentai",
- "name_pretty": "Google Cloud OS Login",
+ "name_pretty": "Document AI",
"product_documentation": "https://cloud.google.com/compute/docs/documentai/",
- "client_documentation": "https://googleapis.dev/java/google-cloud-clients/latest/index.html?com/google/cloud/documentai/v1/package-summary.html",
+ "client_documentation": "https://googleapis.dev/java/google-cloud-document-ai/latest/index.html",
+ "api_description": "allows developers to unlock insights from your documents with machine learning.",
"issue_tracker": "https://issuetracker.google.com/savedsearches/559755",
"release_level": "alpha",
"language": "java",
"repo": "googleapis/java-document-ai",
"repo_short": "java-document-ai",
- "distribution_name": "com.google.cloud:google-cloud-documentai",
- "api_id": "documentai.googleapis.com"
+ "distribution_name": "com.google.cloud:google-cloud-document-ai",
+ "api_id": "documentai.googleapis.com",
+ "transport": "grpc",
+ "requires_billing": true
}
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ebbb59e5..085021dd 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -25,4 +25,106 @@ information on using pull requests.
## Community Guidelines
This project follows
-[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
\ No newline at end of file
+[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
+
+## Building the project
+
+To build, package, and run all unit tests run the command
+
+```
+mvn clean verify
+```
+
+### Running Integration tests
+
+To include integration tests when building the project, you need access to
+a GCP Project with a valid service account.
+
+For instructions on how to generate a service account and corresponding
+credentials JSON see: [Creating a Service Account][1].
+
+Then run the following to build, package, run all unit tests and run all
+integration tests.
+
+```bash
+export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json
+mvn -Penable-integration-tests clean verify
+```
+
+## Code Samples
+
+Code Samples must be bundled in separate Maven modules, and guarded by a
+Maven profile with the name `enable-samples`.
+
+The samples must be separate from the primary project for a few reasons:
+1. Primary projects have a minimum Java version of Java 7 whereas samples have
+ a minimum Java version of Java 8. Due to this we need the ability to
+ selectively exclude samples from a build run.
+2. Many code samples depend on external GCP services and need
+ credentials to access the service.
+3. Code samples are not released as Maven artifacts and must be excluded from
+ release builds.
+
+### Building
+
+```bash
+mvn -Penable-samples clean verify
+```
+
+Some samples require access to GCP services and require a service account:
+
+```bash
+export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json
+mvn -Penable-samples clean verify
+```
+
+### Profile Config
+
+1. To add samples in a profile to your Maven project, add the following to your
+`pom.xml`
+
+ ```xml
+
+ [...]
+
+
+ enable-samples
+
+ sample
+
+
+
+ [...]
+
+ ```
+
+2. [Activate](#profile-activation) the profile.
+3. Define your samples in a normal Maven project in the `samples/` directory
+
+### Profile Activation
+
+To include code samples when building and testing the project, enable the
+`enable-samples` Maven profile.
+
+#### Command line
+
+To activate the Maven profile on the command line add `-Penable-samples` to your
+Maven command.
+
+#### Maven `settings.xml`
+
+To activate the Maven profile in your `~/.m2/settings.xml` add an entry of
+`enable-samples` following the instructions in [Active Profiles][2].
+
+This method has the benefit of applying to all projects you build (and is
+respected by IntelliJ IDEA) and is recommended if you are going to be
+contributing samples to several projects.
+
+#### IntelliJ IDEA
+
+To activate the Maven Profile inside IntelliJ IDEA, follow the instructions in
+[Activate Maven profiles][3] to activate `enable-samples`.
+
+[1]: https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account
+[2]: https://maven.apache.org/settings.html#Active_Profiles
+[3]: https://www.jetbrains.com/help/idea/work-with-maven-profiles.html#activate_maven_profiles
diff --git a/README.md b/README.md
index 1a43ef17..bf7783f5 100644
--- a/README.md
+++ b/README.md
@@ -1,113 +1,163 @@
-Google Cloud Java Client for Cloud Document AI
-==============================================
+# Google Document AI Client for Java
-Java idiomatic client for Document AI.
+Java idiomatic client for [Document AI][product-docs].
-[![Kokoro CI](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/master.svg)](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/master.html)
-[![Maven](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-documentai.svg)](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-documentai.svg)
-[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/google-cloud-java)
+[![Maven][maven-version-image]][maven-version-link]
+![Stability][stability-image]
+- [Product Documentation][product-docs]
+- [Client Library Documentation][javadocs]
> Note: This client is a work-in-progress, and may occasionally
> make backwards-incompatible changes.
-Quickstart
-----------
-If you are using Maven with Bom, Add this to your pom.xml file.
+## Quickstart
+
+If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file
```xml
-
+
+
+ com.google.cloud
+ libraries-bom
+ 4.2.0
+ pom
+ import
+
+
+
+com.google.cloud
- libraries-bom
- 2.8.0
- pom
- import
-
-
-
-
-
- com.google.cloud
- google-cloud-documentai
-
+ google-cloud-document-ai
+
+
```
-[//]: # ({x-version-update-start:google-cloud-documentai:released})
-If you are using Maven without Bom, Add this to your dependencies.
+
+[//]: # ({x-version-update-start:google-cloud-document-ai:released})
+
+If you are using Maven without BOM, add this to your dependencies:
+
```xml
com.google.cloud
- google-cloud-documentai
- 0.1.0
+ google-cloud-document-ai
+ 0.0.0
```
+
If you are using Gradle, add this to your dependencies
```Groovy
-compile 'com.google.cloud:google-cloud-documentai:0.1.0'
+compile 'com.google.cloud:google-cloud-document-ai:0.0.0'
```
If you are using SBT, add this to your dependencies
```Scala
-libraryDependencies += "com.google.cloud" % "google-cloud-documentai" % "0.1.0"
+libraryDependencies += "com.google.cloud" % "google-cloud-document-ai" % "0.0.0"
```
[//]: # ({x-version-update-end})
-Authentication
---------------
+## Authentication
-See the [Authentication](https://github.com/googleapis/google-cloud-java#authentication) section in the base directory's README.
+See the [Authentication][authentication] section in the base directory's README.
-About Google Cloud Cloud Document AI
-------------------------------------
+## Getting Started
+### Prerequisites
-See the Cloud Document AI client library docs to learn how to use this Document AI API Client Library.
+You will need a [Google Cloud Platform Console][developer-console] project with the Document AI [API enabled][enable-api].
+You will need to [enable billing][enable-billing] to use Google Document AI.
+[Follow these instructions][create-project] to get your project set up. You will also need to set up the local development environment by
+[installing the Google Cloud SDK][cloud-sdk] and running the following commands in command line:
+`gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`.
-Getting Started
----------------
-#### Prerequisites
-You will need a [Google Developers Console](https://console.developers.google.com/) project with the Cloud Document AI API enabled. [Follow these instructions](https://cloud.google.com/resource-manager/docs/creating-managing-projects) to get your project set up. You will also need to set up the local development environment by [installing the Google Cloud SDK](https://cloud.google.com/sdk/) and running the following commands in command line: `gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`.
+### Installation and setup
-#### Installation and setup
-You'll need to obtain the `google-cloud-documentai` library. See the [Quickstart](#quickstart) section to add `google-cloud-documentai` as a dependency in your code.
+You'll need to obtain the `google-cloud-document-ai` library. See the [Quickstart](#quickstart) section
+to add `google-cloud-document-ai` as a dependency in your code.
-Troubleshooting
----------------
+## About Document AI
-To get help, follow the instructions in the [shared Troubleshooting document](https://github.com/googleapis/google-cloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
-Transport
----------
-Cloud Document AI uses gRPC for the transport layer.
+[Document AI][product-docs] allows developers to unlock insights from your documents with machine learning.
-Java Versions
--------------
+See the [Document AI client library docs][javadocs] to learn how to
+use this Document AI Client Library.
-Java 7 or above is required for using this client.
-Versioning
-----------
-This library follows [Semantic Versioning](http://semver.org/).
-It is currently in major version zero (``0.y.z``), which means that anything may change at any time and the public API should not be considered stable.
-Contributing
-------------
-Contributions to this library are always welcome and highly encouraged.
+## Troubleshooting
+
+To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting].
+
+## Transport
+
+Document AI uses gRPC for the transport layer.
+
+## Java Versions
+
+Java 7 or above is required for using this client.
+
+## Versioning
+
+This library follows [Semantic Versioning](http://semver.org/).
+
-See `google-cloud`'s [CONTRIBUTING] documentation and the [shared documentation](https://github.com/googleapis/google-cloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
+It is currently in major version zero (``0.y.z``), which means that anything may change at any time
+and the public API should not be considered stable.
-Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
-License
--------
+## Contributing
-Apache 2.0 - See [LICENSE] for more information.
+Contributions to this library are always welcome and highly encouraged.
-[CONTRIBUTING]:https://github.com/googleapis/java-documentai/blob/master/CONTRIBUTING.md
-[code-of-conduct]:https://github.com/googleapis/java-documentai/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct
-[LICENSE]: https://github.com/googleapis/java-documentai/blob/master/LICENSE
-[cloud-platform]: https://cloud.google.com/
-[client-lib-docs]: https://googleapis.dev/java/google-cloud-clients/latest/index.html?com/google/cloud/documentai/v2/package-summary.html
\ No newline at end of file
+See [CONTRIBUTING][contributing] for more information how to get started.
+
+Please note that this project is released with a Contributor Code of Conduct. By participating in
+this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more
+information.
+
+## License
+
+Apache 2.0 - See [LICENSE][license] for more information.
+
+## CI Status
+
+Java Version | Status
+------------ | ------
+Java 7 | [![Kokoro CI][kokoro-badge-image-1]][kokoro-badge-link-1]
+Java 8 | [![Kokoro CI][kokoro-badge-image-2]][kokoro-badge-link-2]
+Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3]
+Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4]
+Java 11 | [![Kokoro CI][kokoro-badge-image-5]][kokoro-badge-link-5]
+
+[product-docs]: https://cloud.google.com/compute/docs/documentai/
+[javadocs]: https://googleapis.dev/java/google-cloud-document-ai/latest/index.html
+[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-document-ai/java7.svg
+[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-document-ai/java7.html
+[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-document-ai/java8.svg
+[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-document-ai/java8.html
+[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-document-ai/java8-osx.svg
+[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-document-ai/java8-osx.html
+[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-document-ai/java8-win.svg
+[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-document-ai/java8-win.html
+[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-document-ai/java11.svg
+[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-document-ai/java11.html
+[stability-image]: https://img.shields.io/badge/stability-alpha-orange
+[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-document-ai.svg
+[maven-version-link]: https://search.maven.org/search?q=g:com.google.cloud%20AND%20a:google-cloud-document-ai&core=gav
+[authentication]: https://github.com/googleapis/google-cloud-java#authentication
+[developer-console]: https://console.developers.google.com/
+[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects
+[cloud-sdk]: https://cloud.google.com/sdk/
+[troubleshooting]: https://github.com/googleapis/google-cloud-common/blob/master/troubleshooting/readme.md#troubleshooting
+[contributing]: https://github.com/googleapis/java-document-ai/blob/master/CONTRIBUTING.md
+[code-of-conduct]: https://github.com/googleapis/java-document-ai/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct
+[license]: https://github.com/googleapis/java-document-ai/blob/master/LICENSE
+[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing
+[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=documentai.googleapis.com
+[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM
+[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
diff --git a/google-cloud-documentai-bom/pom.xml b/google-cloud-document-ai-bom/pom.xml
similarity index 71%
rename from google-cloud-documentai-bom/pom.xml
rename to google-cloud-document-ai-bom/pom.xml
index bf378df5..8fccdff7 100644
--- a/google-cloud-documentai-bom/pom.xml
+++ b/google-cloud-document-ai-bom/pom.xml
@@ -2,8 +2,8 @@
4.0.0com.google.cloud
- google-cloud-documentai-bom
- 0.1.0-SNAPSHOT
+ google-cloud-document-ai-bom
+ 0.1.0-SNAPSHOTpomcom.google.cloud
@@ -13,9 +13,7 @@
Google Cloud Document AI BOMhttps://github.com/googleapis/java-documentai
-
- BOM for Google Cloud Document AI
-
+ BOM for Google Cloud Document AIGoogle LLC
@@ -62,18 +60,28 @@
com.google.api.grpc
- proto-google-cloud-documentai-v1beta1
- 0.1.0-SNAPSHOT
+ proto-google-cloud-document-ai-v1beta1
+ 0.1.0-SNAPSHOTcom.google.api.grpc
- grpc-google-cloud-documentai-v1beta1
- 0.1.0-SNAPSHOT
+ proto-google-cloud-document-ai-v1beta2
+ 0.1.0-SNAPSHOT
+
+
+ com.google.api.grpc
+ grpc-google-cloud-document-ai-v1beta1
+ 0.1.0-SNAPSHOT
+
+
+ com.google.api.grpc
+ grpc-google-cloud-document-ai-v1beta2
+ 0.1.0-SNAPSHOTcom.google.cloud
- google-cloud-documentai
- 0.1.0-SNAPSHOT
+ google-cloud-document-ai
+ 0.1.0-SNAPSHOT
diff --git a/google-cloud-documentai/pom.xml b/google-cloud-document-ai/pom.xml
similarity index 80%
rename from google-cloud-documentai/pom.xml
rename to google-cloud-document-ai/pom.xml
index fb0c87ed..497aeb25 100644
--- a/google-cloud-documentai/pom.xml
+++ b/google-cloud-document-ai/pom.xml
@@ -2,19 +2,19 @@
4.0.0com.google.cloud
- google-cloud-documentai
- 0.1.0-SNAPSHOT
+ google-cloud-document-ai
+ 0.1.0-SNAPSHOTjarGoogle Cloud Document AIhttps://github.com/googleapis/java-documentaiJava idiomatic client for Google Cloud Document AIcom.google.cloud
- google-cloud-documentai-parent
- 0.1.0-SNAPSHOT
+ google-cloud-document-ai-parent
+ 0.1.0-SNAPSHOT
- google-cloud-documentai
+ google-cloud-document-ai
@@ -44,7 +44,11 @@
com.google.api.grpc
- proto-google-cloud-documentai-v1beta1
+ proto-google-cloud-document-ai-v1beta1
+
+
+ com.google.api.grpc
+ proto-google-cloud-document-ai-v1beta2com.google.guava
@@ -71,7 +75,12 @@
com.google.api.grpc
- grpc-google-cloud-documentai-v1beta1
+ grpc-google-cloud-document-ai-v1beta1
+ test
+
+
+ com.google.api.grpc
+ grpc-google-cloud-document-ai-v1beta2test
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/DocumentUnderstandingServiceClient.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/DocumentUnderstandingServiceClient.java
new file mode 100644
index 00000000..8f63c68f
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/DocumentUnderstandingServiceClient.java
@@ -0,0 +1,300 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+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.v1beta1.stub.DocumentUnderstandingServiceStub;
+import com.google.cloud.documentai.v1beta1.stub.DocumentUnderstandingServiceStubSettings;
+import com.google.longrunning.Operation;
+import com.google.longrunning.OperationsClient;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND SERVICE
+/**
+ * Service Description: Service to parse structured information from unstructured or semi-structured
+ * documents using state-of-the-art Google AI such as natural language, computer vision, and
+ * translation.
+ *
+ *
This class provides the ability to make remote calls to the backing service through method
+ * calls that map to API methods. Sample code to get started:
+ *
+ *
Note: close() needs to be called on the documentUnderstandingServiceClient object to clean up
+ * resources such as threads. In the example above, try-with-resources is used, which automatically
+ * calls close().
+ *
+ *
The surface of this class includes several types of Java methods for each of the API's
+ * methods:
+ *
+ *
+ *
A "flattened" method. With this type of method, the fields of the request type have been
+ * converted into function parameters. It may be the case that not all fields are available as
+ * parameters, and not every API method will have a flattened method entry point.
+ *
A "request object" method. This type of method only takes one parameter, a request object,
+ * which must be constructed before the call. Not every API method will have a request object
+ * method.
+ *
A "callable" method. This type of method takes no parameters and returns an immutable API
+ * callable object, which can be used to initiate calls to the service.
+ *
+ *
+ *
See the individual methods for example code.
+ *
+ *
Many parameters require resource names to be formatted in a particular way. To assist with
+ * these names, this class includes a format method for each type of name, and additionally a parse
+ * method to extract the individual identifiers contained within names that are returned.
+ *
+ *
This class can be customized by passing in a custom instance of
+ * DocumentUnderstandingServiceSettings to create(). For example:
+ *
+ *
+ */
+@Generated("by gapic-generator")
+@BetaApi
+public class DocumentUnderstandingServiceClient implements BackgroundResource {
+ private final DocumentUnderstandingServiceSettings settings;
+ private final DocumentUnderstandingServiceStub stub;
+ private final OperationsClient operationsClient;
+
+ /** Constructs an instance of DocumentUnderstandingServiceClient with default settings. */
+ public static final DocumentUnderstandingServiceClient create() throws IOException {
+ return create(DocumentUnderstandingServiceSettings.newBuilder().build());
+ }
+
+ /**
+ * Constructs an instance of DocumentUnderstandingServiceClient, using the given settings. The
+ * channels are created based on the settings passed in, or defaults for any settings that are not
+ * set.
+ */
+ public static final DocumentUnderstandingServiceClient create(
+ DocumentUnderstandingServiceSettings settings) throws IOException {
+ return new DocumentUnderstandingServiceClient(settings);
+ }
+
+ /**
+ * Constructs an instance of DocumentUnderstandingServiceClient, using the given stub for making
+ * calls. This is for advanced usage - prefer to use DocumentUnderstandingServiceSettings}.
+ */
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public static final DocumentUnderstandingServiceClient create(
+ DocumentUnderstandingServiceStub stub) {
+ return new DocumentUnderstandingServiceClient(stub);
+ }
+
+ /**
+ * Constructs an instance of DocumentUnderstandingServiceClient, 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 DocumentUnderstandingServiceClient(DocumentUnderstandingServiceSettings settings)
+ throws IOException {
+ this.settings = settings;
+ this.stub =
+ ((DocumentUnderstandingServiceStubSettings) settings.getStubSettings()).createStub();
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ protected DocumentUnderstandingServiceClient(DocumentUnderstandingServiceStub stub) {
+ this.settings = null;
+ this.stub = stub;
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ public final DocumentUnderstandingServiceSettings getSettings() {
+ return settings;
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public DocumentUnderstandingServiceStub getStub() {
+ return stub;
+ }
+
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationsClient getOperationsClient() {
+ return operationsClient;
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * LRO endpoint to batch process many documents.
+ *
+ *
+ *
+ * @param requests Required. Individual requests for each document.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationFuture
+ batchProcessDocumentsAsync(List requests) {
+ BatchProcessDocumentsRequest request =
+ BatchProcessDocumentsRequest.newBuilder().addAllRequests(requests).build();
+ return batchProcessDocumentsAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * LRO endpoint to batch process many documents.
+ *
+ *
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationFuture
+ batchProcessDocumentsAsync(BatchProcessDocumentsRequest request) {
+ return batchProcessDocumentsOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * LRO endpoint to batch process many documents.
+ *
+ *
+ */
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public final OperationCallable<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationCallable() {
+ return stub.batchProcessDocumentsOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * LRO endpoint to batch process many documents.
+ *
+ *
+ */
+ public final UnaryCallable
+ batchProcessDocumentsCallable() {
+ return stub.batchProcessDocumentsCallable();
+ }
+
+ @Override
+ public final void close() {
+ stub.close();
+ }
+
+ @Override
+ public void shutdown() {
+ stub.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return stub.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return stub.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ stub.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return stub.awaitTermination(duration, unit);
+ }
+}
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/DocumentUnderstandingServiceSettings.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/DocumentUnderstandingServiceSettings.java
new file mode 100644
index 00000000..87ceed34
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/DocumentUnderstandingServiceSettings.java
@@ -0,0 +1,205 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.BetaApi;
+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.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientSettings;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.cloud.documentai.v1beta1.stub.DocumentUnderstandingServiceStubSettings;
+import com.google.longrunning.Operation;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * Settings class to configure an instance of {@link DocumentUnderstandingServiceClient}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (documentai.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ *
For example, to set the total timeout of batchProcessDocumentsAsync to 30 seconds:
+ *
+ *
+ */
+@Generated("by gapic-generator")
+@BetaApi
+public class DocumentUnderstandingServiceSettings
+ extends ClientSettings {
+ /** Returns the object with the settings used for calls to batchProcessDocuments. */
+ public UnaryCallSettings
+ batchProcessDocumentsSettings() {
+ return ((DocumentUnderstandingServiceStubSettings) getStubSettings())
+ .batchProcessDocumentsSettings();
+ }
+
+ /** Returns the object with the settings used for calls to batchProcessDocuments. */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public OperationCallSettings<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings() {
+ return ((DocumentUnderstandingServiceStubSettings) getStubSettings())
+ .batchProcessDocumentsOperationSettings();
+ }
+
+ public static final DocumentUnderstandingServiceSettings create(
+ DocumentUnderstandingServiceStubSettings stub) throws IOException {
+ return new DocumentUnderstandingServiceSettings.Builder(stub.toBuilder()).build();
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return DocumentUnderstandingServiceStubSettings.defaultExecutorProviderBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return DocumentUnderstandingServiceStubSettings.getDefaultEndpoint();
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return DocumentUnderstandingServiceStubSettings.getDefaultServiceScopes();
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return DocumentUnderstandingServiceStubSettings.defaultCredentialsProviderBuilder();
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return DocumentUnderstandingServiceStubSettings.defaultGrpcTransportProviderBuilder();
+ }
+
+ public static TransportChannelProvider defaultTransportChannelProvider() {
+ return DocumentUnderstandingServiceStubSettings.defaultTransportChannelProvider();
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return DocumentUnderstandingServiceStubSettings.defaultApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected DocumentUnderstandingServiceSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+ }
+
+ /** Builder for DocumentUnderstandingServiceSettings. */
+ public static class Builder
+ extends ClientSettings.Builder {
+ protected Builder() throws IOException {
+ this((ClientContext) null);
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(DocumentUnderstandingServiceStubSettings.newBuilder(clientContext));
+ }
+
+ private static Builder createDefault() {
+ return new Builder(DocumentUnderstandingServiceStubSettings.newBuilder());
+ }
+
+ protected Builder(DocumentUnderstandingServiceSettings settings) {
+ super(settings.getStubSettings().toBuilder());
+ }
+
+ protected Builder(DocumentUnderstandingServiceStubSettings.Builder stubSettings) {
+ super(stubSettings);
+ }
+
+ public DocumentUnderstandingServiceStubSettings.Builder getStubSettingsBuilder() {
+ return ((DocumentUnderstandingServiceStubSettings.Builder) getStubSettings());
+ }
+
+ // NEXT_MAJOR_VER: remove 'throws Exception'
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) throws Exception {
+ super.applyToAllUnaryMethods(
+ getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
+ return this;
+ }
+
+ /** Returns the builder for the settings used for calls to batchProcessDocuments. */
+ public UnaryCallSettings.Builder
+ batchProcessDocumentsSettings() {
+ return getStubSettingsBuilder().batchProcessDocumentsSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to batchProcessDocuments. */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings() {
+ return getStubSettingsBuilder().batchProcessDocumentsOperationSettings();
+ }
+
+ @Override
+ public DocumentUnderstandingServiceSettings build() throws IOException {
+ return new DocumentUnderstandingServiceSettings(this);
+ }
+ }
+}
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/package-info.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/package-info.java
new file mode 100644
index 00000000..f7fc4875
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/package-info.java
@@ -0,0 +1,43 @@
+/*
+ * 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
+ *
+ * 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.
+ */
+
+/**
+ * A client to Cloud Document AI API.
+ *
+ *
The interfaces provided are listed below, along with usage samples.
+ *
+ *
Service Description: Service to parse structured information from unstructured or
+ * semi-structured documents using state-of-the-art Google AI such as natural language, computer
+ * vision, and translation.
+ *
+ *
Sample for DocumentUnderstandingServiceClient:
+ *
+ *
+ */
+@Generated("by gapic-generator")
+package com.google.cloud.documentai.v1beta1;
+
+import javax.annotation.Generated;
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/DocumentUnderstandingServiceStub.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/DocumentUnderstandingServiceStub.java
new file mode 100644
index 00000000..e121fb0d
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/DocumentUnderstandingServiceStub.java
@@ -0,0 +1,58 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest;
+import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsResponse;
+import com.google.cloud.documentai.v1beta1.OperationMetadata;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * Base stub class for Cloud Document AI API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator")
+@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+public abstract class DocumentUnderstandingServiceStub implements BackgroundResource {
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationsStub getOperationsStub() {
+ throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallable<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationCallable() {
+ throw new UnsupportedOperationException(
+ "Not implemented: batchProcessDocumentsOperationCallable()");
+ }
+
+ public UnaryCallable batchProcessDocumentsCallable() {
+ throw new UnsupportedOperationException("Not implemented: batchProcessDocumentsCallable()");
+ }
+
+ @Override
+ public abstract void close();
+}
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/DocumentUnderstandingServiceStubSettings.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/DocumentUnderstandingServiceStubSettings.java
new file mode 100644
index 00000000..1441128e
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/DocumentUnderstandingServiceStubSettings.java
@@ -0,0 +1,336 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.GaxProperties;
+import com.google.api.gax.core.GoogleCredentialsProvider;
+import com.google.api.gax.core.InstantiatingExecutorProvider;
+import com.google.api.gax.grpc.GaxGrpcProperties;
+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.longrunning.OperationSnapshot;
+import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
+import com.google.api.gax.retrying.RetrySettings;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.api.gax.rpc.StubSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest;
+import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsResponse;
+import com.google.cloud.documentai.v1beta1.OperationMetadata;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.longrunning.Operation;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+import org.threeten.bp.Duration;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * Settings class to configure an instance of {@link DocumentUnderstandingServiceStub}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (documentai.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ *
For example, to set the total timeout of batchProcessDocumentsAsync to 30 seconds:
+ *
+ *
+ */
+@Generated("by gapic-generator")
+@BetaApi
+public class DocumentUnderstandingServiceStubSettings
+ extends StubSettings {
+ /** The default scopes of the service. */
+ private static final ImmutableList DEFAULT_SERVICE_SCOPES =
+ ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build();
+
+ private final UnaryCallSettings
+ batchProcessDocumentsSettings;
+ private final OperationCallSettings<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings;
+
+ /** Returns the object with the settings used for calls to batchProcessDocuments. */
+ public UnaryCallSettings
+ batchProcessDocumentsSettings() {
+ return batchProcessDocumentsSettings;
+ }
+
+ /** Returns the object with the settings used for calls to batchProcessDocuments. */
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings() {
+ return batchProcessDocumentsOperationSettings;
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public DocumentUnderstandingServiceStub createStub() throws IOException {
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(GrpcTransportChannel.getGrpcTransportName())) {
+ return GrpcDocumentUnderstandingServiceStub.create(this);
+ } else {
+ throw new UnsupportedOperationException(
+ "Transport not supported: " + getTransportChannelProvider().getTransportName());
+ }
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return InstantiatingExecutorProvider.newBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return "documentai.googleapis.com:443";
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return DEFAULT_SERVICE_SCOPES;
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return InstantiatingGrpcChannelProvider.newBuilder()
+ .setMaxInboundMessageSize(Integer.MAX_VALUE);
+ }
+
+ 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() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken(
+ "gapic",
+ GaxProperties.getLibraryVersion(DocumentUnderstandingServiceStubSettings.class))
+ .setTransportToken(
+ GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected DocumentUnderstandingServiceStubSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+
+ batchProcessDocumentsSettings = settingsBuilder.batchProcessDocumentsSettings().build();
+ batchProcessDocumentsOperationSettings =
+ settingsBuilder.batchProcessDocumentsOperationSettings().build();
+ }
+
+ /** Builder for DocumentUnderstandingServiceStubSettings. */
+ public static class Builder
+ extends StubSettings.Builder {
+ private final ImmutableList> unaryMethodSettingsBuilders;
+
+ private final UnaryCallSettings.Builder
+ batchProcessDocumentsSettings;
+ private final OperationCallSettings.Builder<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings;
+
+ private static final ImmutableMap>
+ RETRYABLE_CODE_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder> definitions =
+ ImmutableMap.builder();
+ definitions.put(
+ "idempotent",
+ ImmutableSet.copyOf(
+ Lists.newArrayList(
+ StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
+ definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList()));
+ RETRYABLE_CODE_DEFINITIONS = definitions.build();
+ }
+
+ private static final ImmutableMap RETRY_PARAM_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder definitions = ImmutableMap.builder();
+ RetrySettings settings = null;
+ settings =
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(100L))
+ .setRetryDelayMultiplier(1.3)
+ .setMaxRetryDelay(Duration.ofMillis(60000L))
+ .setInitialRpcTimeout(Duration.ofMillis(20000L))
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ofMillis(20000L))
+ .setTotalTimeout(Duration.ofMillis(600000L))
+ .build();
+ definitions.put("default", settings);
+ RETRY_PARAM_DEFINITIONS = definitions.build();
+ }
+
+ protected Builder() {
+ this((ClientContext) null);
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(clientContext);
+
+ batchProcessDocumentsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ batchProcessDocumentsOperationSettings = OperationCallSettings.newBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(batchProcessDocumentsSettings);
+
+ initDefaults(this);
+ }
+
+ private static Builder createDefault() {
+ Builder builder = new Builder((ClientContext) null);
+ builder.setTransportChannelProvider(defaultTransportChannelProvider());
+ builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+ builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
+ builder.setEndpoint(getDefaultEndpoint());
+ return initDefaults(builder);
+ }
+
+ private static Builder initDefaults(Builder builder) {
+
+ builder
+ .batchProcessDocumentsSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+ builder
+ .batchProcessDocumentsOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings
+ .newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(
+ BatchProcessDocumentsResponse.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(20000L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(45000L))
+ .setInitialRpcTimeout(Duration.ZERO) // ignored
+ .setRpcTimeoutMultiplier(1.0) // ignored
+ .setMaxRpcTimeout(Duration.ZERO) // ignored
+ .setTotalTimeout(Duration.ofMillis(86400000L))
+ .build()));
+
+ return builder;
+ }
+
+ protected Builder(DocumentUnderstandingServiceStubSettings settings) {
+ super(settings);
+
+ batchProcessDocumentsSettings = settings.batchProcessDocumentsSettings.toBuilder();
+ batchProcessDocumentsOperationSettings =
+ settings.batchProcessDocumentsOperationSettings.toBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(batchProcessDocumentsSettings);
+ }
+
+ // NEXT_MAJOR_VER: remove 'throws Exception'
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) throws Exception {
+ super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
+ return this;
+ }
+
+ public ImmutableList> unaryMethodSettingsBuilders() {
+ return unaryMethodSettingsBuilders;
+ }
+
+ /** Returns the builder for the settings used for calls to batchProcessDocuments. */
+ public UnaryCallSettings.Builder
+ batchProcessDocumentsSettings() {
+ return batchProcessDocumentsSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to batchProcessDocuments. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings() {
+ return batchProcessDocumentsOperationSettings;
+ }
+
+ @Override
+ public DocumentUnderstandingServiceStubSettings build() throws IOException {
+ return new DocumentUnderstandingServiceStubSettings(this);
+ }
+ }
+}
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/GrpcDocumentUnderstandingServiceCallableFactory.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/GrpcDocumentUnderstandingServiceCallableFactory.java
new file mode 100644
index 00000000..f66ebe91
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/GrpcDocumentUnderstandingServiceCallableFactory.java
@@ -0,0 +1,115 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+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.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * gRPC callable factory implementation for Cloud Document AI API.
+ *
+ *
This class is for advanced usage.
+ */
+@Generated("by gapic-generator")
+@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+public class GrpcDocumentUnderstandingServiceCallableFactory implements GrpcStubCallableFactory {
+ @Override
+ public UnaryCallable createUnaryCallable(
+ GrpcCallSettings grpcCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ GrpcCallSettings grpcCallSettings,
+ PagedCallSettings pagedCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createPagedCallable(
+ grpcCallSettings, pagedCallSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ GrpcCallSettings grpcCallSettings,
+ BatchingCallSettings batchingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBatchingCallable(
+ grpcCallSettings, batchingCallSettings, clientContext);
+ }
+
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ GrpcCallSettings grpcCallSettings,
+ OperationCallSettings operationCallSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ return GrpcCallableFactory.createOperationCallable(
+ grpcCallSettings, operationCallSettings, clientContext, operationsStub);
+ }
+
+ @Override
+ public
+ BidiStreamingCallable createBidiStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBidiStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ ServerStreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createServerStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ClientStreamingCallable createClientStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createClientStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+}
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/GrpcDocumentUnderstandingServiceStub.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/GrpcDocumentUnderstandingServiceStub.java
new file mode 100644
index 00000000..63bc20b3
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta1/stub/GrpcDocumentUnderstandingServiceStub.java
@@ -0,0 +1,190 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.RequestParamsExtractor;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest;
+import com.google.cloud.documentai.v1beta1.BatchProcessDocumentsResponse;
+import com.google.cloud.documentai.v1beta1.OperationMetadata;
+import com.google.common.collect.ImmutableMap;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.GrpcOperationsStub;
+import io.grpc.MethodDescriptor;
+import io.grpc.protobuf.ProtoUtils;
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * gRPC stub implementation for Cloud Document AI API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator")
+@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+public class GrpcDocumentUnderstandingServiceStub extends DocumentUnderstandingServiceStub {
+
+ private static final MethodDescriptor
+ batchProcessDocumentsMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(
+ "google.cloud.documentai.v1beta1.DocumentUnderstandingService/BatchProcessDocuments")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(BatchProcessDocumentsRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private final BackgroundResource backgroundResources;
+ private final GrpcOperationsStub operationsStub;
+
+ private final UnaryCallable
+ batchProcessDocumentsCallable;
+ private final OperationCallable<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationCallable;
+
+ private final GrpcStubCallableFactory callableFactory;
+
+ public static final GrpcDocumentUnderstandingServiceStub create(
+ DocumentUnderstandingServiceStubSettings settings) throws IOException {
+ return new GrpcDocumentUnderstandingServiceStub(settings, ClientContext.create(settings));
+ }
+
+ public static final GrpcDocumentUnderstandingServiceStub create(ClientContext clientContext)
+ throws IOException {
+ return new GrpcDocumentUnderstandingServiceStub(
+ DocumentUnderstandingServiceStubSettings.newBuilder().build(), clientContext);
+ }
+
+ public static final GrpcDocumentUnderstandingServiceStub create(
+ ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
+ return new GrpcDocumentUnderstandingServiceStub(
+ DocumentUnderstandingServiceStubSettings.newBuilder().build(),
+ clientContext,
+ callableFactory);
+ }
+
+ /**
+ * Constructs an instance of GrpcDocumentUnderstandingServiceStub, 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 GrpcDocumentUnderstandingServiceStub(
+ DocumentUnderstandingServiceStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new GrpcDocumentUnderstandingServiceCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of GrpcDocumentUnderstandingServiceStub, 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 GrpcDocumentUnderstandingServiceStub(
+ DocumentUnderstandingServiceStubSettings settings,
+ ClientContext clientContext,
+ GrpcStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
+
+ GrpcCallSettings
+ batchProcessDocumentsTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(batchProcessDocumentsMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(BatchProcessDocumentsRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
+ .build();
+
+ this.batchProcessDocumentsCallable =
+ callableFactory.createUnaryCallable(
+ batchProcessDocumentsTransportSettings,
+ settings.batchProcessDocumentsSettings(),
+ clientContext);
+ this.batchProcessDocumentsOperationCallable =
+ callableFactory.createOperationCallable(
+ batchProcessDocumentsTransportSettings,
+ settings.batchProcessDocumentsOperationSettings(),
+ clientContext,
+ this.operationsStub);
+
+ backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public GrpcOperationsStub getOperationsStub() {
+ return operationsStub;
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallable<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationCallable() {
+ return batchProcessDocumentsOperationCallable;
+ }
+
+ public UnaryCallable batchProcessDocumentsCallable() {
+ return batchProcessDocumentsCallable;
+ }
+
+ @Override
+ public final void close() {
+ shutdown();
+ }
+
+ @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/v1beta2/DocumentUnderstandingServiceClient.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/DocumentUnderstandingServiceClient.java
new file mode 100644
index 00000000..a3111385
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/DocumentUnderstandingServiceClient.java
@@ -0,0 +1,343 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+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.v1beta2.stub.DocumentUnderstandingServiceStub;
+import com.google.cloud.documentai.v1beta2.stub.DocumentUnderstandingServiceStubSettings;
+import com.google.longrunning.Operation;
+import com.google.longrunning.OperationsClient;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND SERVICE
+/**
+ * Service Description: Service to parse structured information from unstructured or semi-structured
+ * documents using state-of-the-art Google AI such as natural language, computer vision, and
+ * translation.
+ *
+ *
This class provides the ability to make remote calls to the backing service through method
+ * calls that map to API methods. Sample code to get started:
+ *
+ *
Note: close() needs to be called on the documentUnderstandingServiceClient object to clean up
+ * resources such as threads. In the example above, try-with-resources is used, which automatically
+ * calls close().
+ *
+ *
The surface of this class includes several types of Java methods for each of the API's
+ * methods:
+ *
+ *
+ *
A "flattened" method. With this type of method, the fields of the request type have been
+ * converted into function parameters. It may be the case that not all fields are available as
+ * parameters, and not every API method will have a flattened method entry point.
+ *
A "request object" method. This type of method only takes one parameter, a request object,
+ * which must be constructed before the call. Not every API method will have a request object
+ * method.
+ *
A "callable" method. This type of method takes no parameters and returns an immutable API
+ * callable object, which can be used to initiate calls to the service.
+ *
+ *
+ *
See the individual methods for example code.
+ *
+ *
Many parameters require resource names to be formatted in a particular way. To assist with
+ * these names, this class includes a format method for each type of name, and additionally a parse
+ * method to extract the individual identifiers contained within names that are returned.
+ *
+ *
This class can be customized by passing in a custom instance of
+ * DocumentUnderstandingServiceSettings to create(). For example:
+ *
+ *
+ */
+@Generated("by gapic-generator")
+@BetaApi
+public class DocumentUnderstandingServiceClient implements BackgroundResource {
+ private final DocumentUnderstandingServiceSettings settings;
+ private final DocumentUnderstandingServiceStub stub;
+ private final OperationsClient operationsClient;
+
+ /** Constructs an instance of DocumentUnderstandingServiceClient with default settings. */
+ public static final DocumentUnderstandingServiceClient create() throws IOException {
+ return create(DocumentUnderstandingServiceSettings.newBuilder().build());
+ }
+
+ /**
+ * Constructs an instance of DocumentUnderstandingServiceClient, using the given settings. The
+ * channels are created based on the settings passed in, or defaults for any settings that are not
+ * set.
+ */
+ public static final DocumentUnderstandingServiceClient create(
+ DocumentUnderstandingServiceSettings settings) throws IOException {
+ return new DocumentUnderstandingServiceClient(settings);
+ }
+
+ /**
+ * Constructs an instance of DocumentUnderstandingServiceClient, using the given stub for making
+ * calls. This is for advanced usage - prefer to use DocumentUnderstandingServiceSettings}.
+ */
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public static final DocumentUnderstandingServiceClient create(
+ DocumentUnderstandingServiceStub stub) {
+ return new DocumentUnderstandingServiceClient(stub);
+ }
+
+ /**
+ * Constructs an instance of DocumentUnderstandingServiceClient, 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 DocumentUnderstandingServiceClient(DocumentUnderstandingServiceSettings settings)
+ throws IOException {
+ this.settings = settings;
+ this.stub =
+ ((DocumentUnderstandingServiceStubSettings) settings.getStubSettings()).createStub();
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ protected DocumentUnderstandingServiceClient(DocumentUnderstandingServiceStub stub) {
+ this.settings = null;
+ this.stub = stub;
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ public final DocumentUnderstandingServiceSettings getSettings() {
+ return settings;
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public DocumentUnderstandingServiceStub getStub() {
+ return stub;
+ }
+
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationsClient getOperationsClient() {
+ return operationsClient;
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in
+ * the [Document] format.
+ *
+ *
+ *
+ * @param requests Required. Individual requests for each document.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationFuture
+ batchProcessDocumentsAsync(List requests) {
+ BatchProcessDocumentsRequest request =
+ BatchProcessDocumentsRequest.newBuilder().addAllRequests(requests).build();
+ return batchProcessDocumentsAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in
+ * the [Document] format.
+ *
+ *
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationFuture
+ batchProcessDocumentsAsync(BatchProcessDocumentsRequest request) {
+ return batchProcessDocumentsOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in
+ * the [Document] format.
+ *
+ *
+ */
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public final OperationCallable<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationCallable() {
+ return stub.batchProcessDocumentsOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in
+ * the [Document] format.
+ *
+ *
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final Document processDocument(ProcessDocumentRequest request) {
+ return processDocumentCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Processes a single document.
+ *
+ *
+ */
+ public final UnaryCallable processDocumentCallable() {
+ return stub.processDocumentCallable();
+ }
+
+ @Override
+ public final void close() {
+ stub.close();
+ }
+
+ @Override
+ public void shutdown() {
+ stub.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return stub.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return stub.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ stub.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return stub.awaitTermination(duration, unit);
+ }
+}
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/DocumentUnderstandingServiceSettings.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/DocumentUnderstandingServiceSettings.java
new file mode 100644
index 00000000..db7606aa
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/DocumentUnderstandingServiceSettings.java
@@ -0,0 +1,215 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.BetaApi;
+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.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientSettings;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.cloud.documentai.v1beta2.stub.DocumentUnderstandingServiceStubSettings;
+import com.google.longrunning.Operation;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * Settings class to configure an instance of {@link DocumentUnderstandingServiceClient}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (documentai.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ *
For example, to set the total timeout of processDocument to 30 seconds:
+ *
+ *
+ */
+@Generated("by gapic-generator")
+@BetaApi
+public class DocumentUnderstandingServiceSettings
+ extends ClientSettings {
+ /** Returns the object with the settings used for calls to batchProcessDocuments. */
+ public UnaryCallSettings
+ batchProcessDocumentsSettings() {
+ return ((DocumentUnderstandingServiceStubSettings) getStubSettings())
+ .batchProcessDocumentsSettings();
+ }
+
+ /** Returns the object with the settings used for calls to batchProcessDocuments. */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public OperationCallSettings<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings() {
+ return ((DocumentUnderstandingServiceStubSettings) getStubSettings())
+ .batchProcessDocumentsOperationSettings();
+ }
+
+ /** Returns the object with the settings used for calls to processDocument. */
+ public UnaryCallSettings processDocumentSettings() {
+ return ((DocumentUnderstandingServiceStubSettings) getStubSettings()).processDocumentSettings();
+ }
+
+ public static final DocumentUnderstandingServiceSettings create(
+ DocumentUnderstandingServiceStubSettings stub) throws IOException {
+ return new DocumentUnderstandingServiceSettings.Builder(stub.toBuilder()).build();
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return DocumentUnderstandingServiceStubSettings.defaultExecutorProviderBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return DocumentUnderstandingServiceStubSettings.getDefaultEndpoint();
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return DocumentUnderstandingServiceStubSettings.getDefaultServiceScopes();
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return DocumentUnderstandingServiceStubSettings.defaultCredentialsProviderBuilder();
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return DocumentUnderstandingServiceStubSettings.defaultGrpcTransportProviderBuilder();
+ }
+
+ public static TransportChannelProvider defaultTransportChannelProvider() {
+ return DocumentUnderstandingServiceStubSettings.defaultTransportChannelProvider();
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return DocumentUnderstandingServiceStubSettings.defaultApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected DocumentUnderstandingServiceSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+ }
+
+ /** Builder for DocumentUnderstandingServiceSettings. */
+ public static class Builder
+ extends ClientSettings.Builder {
+ protected Builder() throws IOException {
+ this((ClientContext) null);
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(DocumentUnderstandingServiceStubSettings.newBuilder(clientContext));
+ }
+
+ private static Builder createDefault() {
+ return new Builder(DocumentUnderstandingServiceStubSettings.newBuilder());
+ }
+
+ protected Builder(DocumentUnderstandingServiceSettings settings) {
+ super(settings.getStubSettings().toBuilder());
+ }
+
+ protected Builder(DocumentUnderstandingServiceStubSettings.Builder stubSettings) {
+ super(stubSettings);
+ }
+
+ public DocumentUnderstandingServiceStubSettings.Builder getStubSettingsBuilder() {
+ return ((DocumentUnderstandingServiceStubSettings.Builder) getStubSettings());
+ }
+
+ // NEXT_MAJOR_VER: remove 'throws Exception'
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) throws Exception {
+ super.applyToAllUnaryMethods(
+ getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
+ return this;
+ }
+
+ /** Returns the builder for the settings used for calls to batchProcessDocuments. */
+ public UnaryCallSettings.Builder
+ batchProcessDocumentsSettings() {
+ return getStubSettingsBuilder().batchProcessDocumentsSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to batchProcessDocuments. */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings() {
+ return getStubSettingsBuilder().batchProcessDocumentsOperationSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to processDocument. */
+ public UnaryCallSettings.Builder processDocumentSettings() {
+ return getStubSettingsBuilder().processDocumentSettings();
+ }
+
+ @Override
+ public DocumentUnderstandingServiceSettings build() throws IOException {
+ return new DocumentUnderstandingServiceSettings(this);
+ }
+ }
+}
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/package-info.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/package-info.java
new file mode 100644
index 00000000..62a42566
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/package-info.java
@@ -0,0 +1,43 @@
+/*
+ * 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
+ *
+ * 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.
+ */
+
+/**
+ * A client to Cloud Document AI API.
+ *
+ *
The interfaces provided are listed below, along with usage samples.
+ *
+ *
Service Description: Service to parse structured information from unstructured or
+ * semi-structured documents using state-of-the-art Google AI such as natural language, computer
+ * vision, and translation.
+ *
+ *
Sample for DocumentUnderstandingServiceClient:
+ *
+ *
+ */
+@Generated("by gapic-generator")
+package com.google.cloud.documentai.v1beta2;
+
+import javax.annotation.Generated;
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/DocumentUnderstandingServiceStub.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/DocumentUnderstandingServiceStub.java
new file mode 100644
index 00000000..5d3928b5
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/DocumentUnderstandingServiceStub.java
@@ -0,0 +1,64 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest;
+import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsResponse;
+import com.google.cloud.documentai.v1beta2.Document;
+import com.google.cloud.documentai.v1beta2.OperationMetadata;
+import com.google.cloud.documentai.v1beta2.ProcessDocumentRequest;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * Base stub class for Cloud Document AI API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator")
+@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+public abstract class DocumentUnderstandingServiceStub implements BackgroundResource {
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationsStub getOperationsStub() {
+ throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallable<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationCallable() {
+ throw new UnsupportedOperationException(
+ "Not implemented: batchProcessDocumentsOperationCallable()");
+ }
+
+ public UnaryCallable batchProcessDocumentsCallable() {
+ throw new UnsupportedOperationException("Not implemented: batchProcessDocumentsCallable()");
+ }
+
+ public UnaryCallable processDocumentCallable() {
+ throw new UnsupportedOperationException("Not implemented: processDocumentCallable()");
+ }
+
+ @Override
+ public abstract void close();
+}
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/DocumentUnderstandingServiceStubSettings.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/DocumentUnderstandingServiceStubSettings.java
new file mode 100644
index 00000000..d74b5e80
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/DocumentUnderstandingServiceStubSettings.java
@@ -0,0 +1,362 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.GaxProperties;
+import com.google.api.gax.core.GoogleCredentialsProvider;
+import com.google.api.gax.core.InstantiatingExecutorProvider;
+import com.google.api.gax.grpc.GaxGrpcProperties;
+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.longrunning.OperationSnapshot;
+import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
+import com.google.api.gax.retrying.RetrySettings;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.api.gax.rpc.StubSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest;
+import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsResponse;
+import com.google.cloud.documentai.v1beta2.Document;
+import com.google.cloud.documentai.v1beta2.OperationMetadata;
+import com.google.cloud.documentai.v1beta2.ProcessDocumentRequest;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.longrunning.Operation;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+import org.threeten.bp.Duration;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * Settings class to configure an instance of {@link DocumentUnderstandingServiceStub}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (documentai.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ *
For example, to set the total timeout of processDocument to 30 seconds:
+ *
+ *
+ */
+@Generated("by gapic-generator")
+@BetaApi
+public class DocumentUnderstandingServiceStubSettings
+ extends StubSettings {
+ /** The default scopes of the service. */
+ private static final ImmutableList DEFAULT_SERVICE_SCOPES =
+ ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build();
+
+ private final UnaryCallSettings
+ batchProcessDocumentsSettings;
+ private final OperationCallSettings<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings;
+ private final UnaryCallSettings processDocumentSettings;
+
+ /** Returns the object with the settings used for calls to batchProcessDocuments. */
+ public UnaryCallSettings
+ batchProcessDocumentsSettings() {
+ return batchProcessDocumentsSettings;
+ }
+
+ /** Returns the object with the settings used for calls to batchProcessDocuments. */
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings() {
+ return batchProcessDocumentsOperationSettings;
+ }
+
+ /** Returns the object with the settings used for calls to processDocument. */
+ public UnaryCallSettings processDocumentSettings() {
+ return processDocumentSettings;
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public DocumentUnderstandingServiceStub createStub() throws IOException {
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(GrpcTransportChannel.getGrpcTransportName())) {
+ return GrpcDocumentUnderstandingServiceStub.create(this);
+ } else {
+ throw new UnsupportedOperationException(
+ "Transport not supported: " + getTransportChannelProvider().getTransportName());
+ }
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return InstantiatingExecutorProvider.newBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return "documentai.googleapis.com:443";
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return DEFAULT_SERVICE_SCOPES;
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return InstantiatingGrpcChannelProvider.newBuilder()
+ .setMaxInboundMessageSize(Integer.MAX_VALUE);
+ }
+
+ 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() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken(
+ "gapic",
+ GaxProperties.getLibraryVersion(DocumentUnderstandingServiceStubSettings.class))
+ .setTransportToken(
+ GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected DocumentUnderstandingServiceStubSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+
+ batchProcessDocumentsSettings = settingsBuilder.batchProcessDocumentsSettings().build();
+ batchProcessDocumentsOperationSettings =
+ settingsBuilder.batchProcessDocumentsOperationSettings().build();
+ processDocumentSettings = settingsBuilder.processDocumentSettings().build();
+ }
+
+ /** Builder for DocumentUnderstandingServiceStubSettings. */
+ public static class Builder
+ extends StubSettings.Builder {
+ private final ImmutableList> unaryMethodSettingsBuilders;
+
+ private final UnaryCallSettings.Builder
+ batchProcessDocumentsSettings;
+ private final OperationCallSettings.Builder<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings;
+ private final UnaryCallSettings.Builder
+ processDocumentSettings;
+
+ private static final ImmutableMap>
+ RETRYABLE_CODE_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder> definitions =
+ ImmutableMap.builder();
+ definitions.put(
+ "idempotent",
+ ImmutableSet.copyOf(
+ Lists.newArrayList(
+ StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
+ definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList()));
+ RETRYABLE_CODE_DEFINITIONS = definitions.build();
+ }
+
+ private static final ImmutableMap RETRY_PARAM_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder definitions = ImmutableMap.builder();
+ RetrySettings settings = null;
+ settings =
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(100L))
+ .setRetryDelayMultiplier(1.3)
+ .setMaxRetryDelay(Duration.ofMillis(60000L))
+ .setInitialRpcTimeout(Duration.ofMillis(20000L))
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ofMillis(20000L))
+ .setTotalTimeout(Duration.ofMillis(600000L))
+ .build();
+ definitions.put("default", settings);
+ RETRY_PARAM_DEFINITIONS = definitions.build();
+ }
+
+ protected Builder() {
+ this((ClientContext) null);
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(clientContext);
+
+ batchProcessDocumentsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ batchProcessDocumentsOperationSettings = OperationCallSettings.newBuilder();
+
+ processDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ batchProcessDocumentsSettings, processDocumentSettings);
+
+ initDefaults(this);
+ }
+
+ private static Builder createDefault() {
+ Builder builder = new Builder((ClientContext) null);
+ builder.setTransportChannelProvider(defaultTransportChannelProvider());
+ builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+ builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
+ builder.setEndpoint(getDefaultEndpoint());
+ return initDefaults(builder);
+ }
+
+ private static Builder initDefaults(Builder builder) {
+
+ builder
+ .batchProcessDocumentsSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+
+ builder
+ .processDocumentSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+ builder
+ .batchProcessDocumentsOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings
+ .newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(
+ BatchProcessDocumentsResponse.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(20000L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(45000L))
+ .setInitialRpcTimeout(Duration.ZERO) // ignored
+ .setRpcTimeoutMultiplier(1.0) // ignored
+ .setMaxRpcTimeout(Duration.ZERO) // ignored
+ .setTotalTimeout(Duration.ofMillis(86400000L))
+ .build()));
+
+ return builder;
+ }
+
+ protected Builder(DocumentUnderstandingServiceStubSettings settings) {
+ super(settings);
+
+ batchProcessDocumentsSettings = settings.batchProcessDocumentsSettings.toBuilder();
+ batchProcessDocumentsOperationSettings =
+ settings.batchProcessDocumentsOperationSettings.toBuilder();
+ processDocumentSettings = settings.processDocumentSettings.toBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ batchProcessDocumentsSettings, processDocumentSettings);
+ }
+
+ // NEXT_MAJOR_VER: remove 'throws Exception'
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) throws Exception {
+ super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
+ return this;
+ }
+
+ public ImmutableList> unaryMethodSettingsBuilders() {
+ return unaryMethodSettingsBuilders;
+ }
+
+ /** Returns the builder for the settings used for calls to batchProcessDocuments. */
+ public UnaryCallSettings.Builder
+ batchProcessDocumentsSettings() {
+ return batchProcessDocumentsSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to batchProcessDocuments. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationSettings() {
+ return batchProcessDocumentsOperationSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to processDocument. */
+ public UnaryCallSettings.Builder processDocumentSettings() {
+ return processDocumentSettings;
+ }
+
+ @Override
+ public DocumentUnderstandingServiceStubSettings build() throws IOException {
+ return new DocumentUnderstandingServiceStubSettings(this);
+ }
+ }
+}
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/GrpcDocumentUnderstandingServiceCallableFactory.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/GrpcDocumentUnderstandingServiceCallableFactory.java
new file mode 100644
index 00000000..6ea0b58a
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/GrpcDocumentUnderstandingServiceCallableFactory.java
@@ -0,0 +1,115 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+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.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * gRPC callable factory implementation for Cloud Document AI API.
+ *
+ *
This class is for advanced usage.
+ */
+@Generated("by gapic-generator")
+@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+public class GrpcDocumentUnderstandingServiceCallableFactory implements GrpcStubCallableFactory {
+ @Override
+ public UnaryCallable createUnaryCallable(
+ GrpcCallSettings grpcCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ GrpcCallSettings grpcCallSettings,
+ PagedCallSettings pagedCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createPagedCallable(
+ grpcCallSettings, pagedCallSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ GrpcCallSettings grpcCallSettings,
+ BatchingCallSettings batchingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBatchingCallable(
+ grpcCallSettings, batchingCallSettings, clientContext);
+ }
+
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ GrpcCallSettings grpcCallSettings,
+ OperationCallSettings operationCallSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ return GrpcCallableFactory.createOperationCallable(
+ grpcCallSettings, operationCallSettings, clientContext, operationsStub);
+ }
+
+ @Override
+ public
+ BidiStreamingCallable createBidiStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBidiStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ ServerStreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createServerStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ClientStreamingCallable createClientStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createClientStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+}
diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/GrpcDocumentUnderstandingServiceStub.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/GrpcDocumentUnderstandingServiceStub.java
new file mode 100644
index 00000000..39430b8c
--- /dev/null
+++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/stub/GrpcDocumentUnderstandingServiceStub.java
@@ -0,0 +1,223 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.RequestParamsExtractor;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest;
+import com.google.cloud.documentai.v1beta2.BatchProcessDocumentsResponse;
+import com.google.cloud.documentai.v1beta2.Document;
+import com.google.cloud.documentai.v1beta2.OperationMetadata;
+import com.google.cloud.documentai.v1beta2.ProcessDocumentRequest;
+import com.google.common.collect.ImmutableMap;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.GrpcOperationsStub;
+import io.grpc.MethodDescriptor;
+import io.grpc.protobuf.ProtoUtils;
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * gRPC stub implementation for Cloud Document AI API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator")
+@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+public class GrpcDocumentUnderstandingServiceStub extends DocumentUnderstandingServiceStub {
+
+ private static final MethodDescriptor
+ batchProcessDocumentsMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(
+ "google.cloud.documentai.v1beta2.DocumentUnderstandingService/BatchProcessDocuments")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(BatchProcessDocumentsRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+ private static final MethodDescriptor
+ processDocumentMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(
+ "google.cloud.documentai.v1beta2.DocumentUnderstandingService/ProcessDocument")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(ProcessDocumentRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Document.getDefaultInstance()))
+ .build();
+
+ private final BackgroundResource backgroundResources;
+ private final GrpcOperationsStub operationsStub;
+
+ private final UnaryCallable
+ batchProcessDocumentsCallable;
+ private final OperationCallable<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationCallable;
+ private final UnaryCallable processDocumentCallable;
+
+ private final GrpcStubCallableFactory callableFactory;
+
+ public static final GrpcDocumentUnderstandingServiceStub create(
+ DocumentUnderstandingServiceStubSettings settings) throws IOException {
+ return new GrpcDocumentUnderstandingServiceStub(settings, ClientContext.create(settings));
+ }
+
+ public static final GrpcDocumentUnderstandingServiceStub create(ClientContext clientContext)
+ throws IOException {
+ return new GrpcDocumentUnderstandingServiceStub(
+ DocumentUnderstandingServiceStubSettings.newBuilder().build(), clientContext);
+ }
+
+ public static final GrpcDocumentUnderstandingServiceStub create(
+ ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
+ return new GrpcDocumentUnderstandingServiceStub(
+ DocumentUnderstandingServiceStubSettings.newBuilder().build(),
+ clientContext,
+ callableFactory);
+ }
+
+ /**
+ * Constructs an instance of GrpcDocumentUnderstandingServiceStub, 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 GrpcDocumentUnderstandingServiceStub(
+ DocumentUnderstandingServiceStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new GrpcDocumentUnderstandingServiceCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of GrpcDocumentUnderstandingServiceStub, 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 GrpcDocumentUnderstandingServiceStub(
+ DocumentUnderstandingServiceStubSettings settings,
+ ClientContext clientContext,
+ GrpcStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
+
+ GrpcCallSettings
+ batchProcessDocumentsTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(batchProcessDocumentsMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(BatchProcessDocumentsRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
+ .build();
+ GrpcCallSettings processDocumentTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(processDocumentMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(ProcessDocumentRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
+ .build();
+
+ this.batchProcessDocumentsCallable =
+ callableFactory.createUnaryCallable(
+ batchProcessDocumentsTransportSettings,
+ settings.batchProcessDocumentsSettings(),
+ clientContext);
+ this.batchProcessDocumentsOperationCallable =
+ callableFactory.createOperationCallable(
+ batchProcessDocumentsTransportSettings,
+ settings.batchProcessDocumentsOperationSettings(),
+ clientContext,
+ this.operationsStub);
+ this.processDocumentCallable =
+ callableFactory.createUnaryCallable(
+ processDocumentTransportSettings, settings.processDocumentSettings(), clientContext);
+
+ backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public GrpcOperationsStub getOperationsStub() {
+ return operationsStub;
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallable<
+ BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata>
+ batchProcessDocumentsOperationCallable() {
+ return batchProcessDocumentsOperationCallable;
+ }
+
+ public UnaryCallable batchProcessDocumentsCallable() {
+ return batchProcessDocumentsCallable;
+ }
+
+ public UnaryCallable processDocumentCallable() {
+ return processDocumentCallable;
+ }
+
+ @Override
+ public final void close() {
+ shutdown();
+ }
+
+ @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/v1beta1/DocumentUnderstandingServiceClientTest.java b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta1/DocumentUnderstandingServiceClientTest.java
new file mode 100644
index 00000000..0ff114e1
--- /dev/null
+++ b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta1/DocumentUnderstandingServiceClientTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.gax.core.NoCredentialsProvider;
+import com.google.api.gax.grpc.GaxGrpcProperties;
+import com.google.api.gax.grpc.testing.LocalChannelProvider;
+import com.google.api.gax.grpc.testing.MockGrpcService;
+import com.google.api.gax.grpc.testing.MockServiceHelper;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.InvalidArgumentException;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.longrunning.Operation;
+import com.google.protobuf.AbstractMessage;
+import com.google.protobuf.Any;
+import io.grpc.Status;
+import io.grpc.StatusRuntimeException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@javax.annotation.Generated("by GAPIC")
+public class DocumentUnderstandingServiceClientTest {
+ private static MockDocumentUnderstandingService mockDocumentUnderstandingService;
+ private static MockServiceHelper serviceHelper;
+ private DocumentUnderstandingServiceClient client;
+ private LocalChannelProvider channelProvider;
+
+ @BeforeClass
+ public static void startStaticServer() {
+ mockDocumentUnderstandingService = new MockDocumentUnderstandingService();
+ serviceHelper =
+ new MockServiceHelper(
+ UUID.randomUUID().toString(),
+ Arrays.asList(mockDocumentUnderstandingService));
+ serviceHelper.start();
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ serviceHelper.stop();
+ }
+
+ @Before
+ public void setUp() throws IOException {
+ serviceHelper.reset();
+ channelProvider = serviceHelper.createChannelProvider();
+ DocumentUnderstandingServiceSettings settings =
+ DocumentUnderstandingServiceSettings.newBuilder()
+ .setTransportChannelProvider(channelProvider)
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = DocumentUnderstandingServiceClient.create(settings);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ client.close();
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void batchProcessDocumentsTest() throws Exception {
+ BatchProcessDocumentsResponse expectedResponse =
+ BatchProcessDocumentsResponse.newBuilder().build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("batchProcessDocumentsTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockDocumentUnderstandingService.addResponse(resultOperation);
+
+ List requests = new ArrayList<>();
+
+ BatchProcessDocumentsResponse actualResponse =
+ client.batchProcessDocumentsAsync(requests).get();
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockDocumentUnderstandingService.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ BatchProcessDocumentsRequest actualRequest =
+ (BatchProcessDocumentsRequest) actualRequests.get(0);
+
+ Assert.assertEquals(requests, actualRequest.getRequestsList());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void batchProcessDocumentsExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
+ mockDocumentUnderstandingService.addException(exception);
+
+ try {
+ List requests = new ArrayList<>();
+
+ client.batchProcessDocumentsAsync(requests).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
+ InvalidArgumentException apiException = (InvalidArgumentException) e.getCause();
+ Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
+ }
+ }
+}
diff --git a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta1/MockDocumentUnderstandingService.java b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta1/MockDocumentUnderstandingService.java
new file mode 100644
index 00000000..e9856c7d
--- /dev/null
+++ b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta1/MockDocumentUnderstandingService.java
@@ -0,0 +1,57 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.testing.MockGrpcService;
+import com.google.protobuf.AbstractMessage;
+import io.grpc.ServerServiceDefinition;
+import java.util.List;
+
+@javax.annotation.Generated("by GAPIC")
+@BetaApi
+public class MockDocumentUnderstandingService implements MockGrpcService {
+ private final MockDocumentUnderstandingServiceImpl serviceImpl;
+
+ public MockDocumentUnderstandingService() {
+ serviceImpl = new MockDocumentUnderstandingServiceImpl();
+ }
+
+ @Override
+ public List getRequests() {
+ return serviceImpl.getRequests();
+ }
+
+ @Override
+ public void addResponse(AbstractMessage response) {
+ serviceImpl.addResponse(response);
+ }
+
+ @Override
+ public void addException(Exception exception) {
+ serviceImpl.addException(exception);
+ }
+
+ @Override
+ public ServerServiceDefinition getServiceDefinition() {
+ return serviceImpl.bindService();
+ }
+
+ @Override
+ public void reset() {
+ serviceImpl.reset();
+ }
+}
diff --git a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta1/MockDocumentUnderstandingServiceImpl.java b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta1/MockDocumentUnderstandingServiceImpl.java
new file mode 100644
index 00000000..a41b118b
--- /dev/null
+++ b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta1/MockDocumentUnderstandingServiceImpl.java
@@ -0,0 +1,74 @@
+/*
+ * 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
+ *
+ * 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;
+
+import com.google.api.core.BetaApi;
+import com.google.cloud.documentai.v1beta1.DocumentUnderstandingServiceGrpc.DocumentUnderstandingServiceImplBase;
+import com.google.longrunning.Operation;
+import com.google.protobuf.AbstractMessage;
+import io.grpc.stub.StreamObserver;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+
+@javax.annotation.Generated("by GAPIC")
+@BetaApi
+public class MockDocumentUnderstandingServiceImpl extends DocumentUnderstandingServiceImplBase {
+ private List requests;
+ private Queue