diff --git a/.github/readme/synth.metadata/synth.metadata b/.github/readme/synth.metadata/synth.metadata index 99adbc99..8e623586 100644 --- a/.github/readme/synth.metadata/synth.metadata +++ b/.github/readme/synth.metadata/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-document-ai.git", - "sha": "981da1d86b4cd697278dfd874abf3396d0768288" + "sha": "fc70b1fe2653501f87d34725cd8001bccdb18962" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "a073c873f3928c561bdf87fdfbf1d081d1998984" + "sha": "996775eca5fd934edac3c2ae34b80ff0395b1717" } } ] diff --git a/CHANGELOG.md b/CHANGELOG.md index a5a58623..930666a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### [0.3.7](https://www.github.com/googleapis/java-document-ai/compare/v0.3.6...v0.3.7) (2020-12-14) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.16.1 ([#295](https://www.github.com/googleapis/java-document-ai/issues/295)) ([7564e4d](https://www.github.com/googleapis/java-document-ai/commit/7564e4db794ca7d9fdac0b32fdb2669c87b47621)) + ### [0.3.6](https://www.github.com/googleapis/java-document-ai/compare/v0.3.5...v0.3.6) (2020-12-08) diff --git a/README.md b/README.md index 92d9cedd..10e868af 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud google-cloud-document-ai - 0.3.5 + 0.3.6 ``` @@ -42,18 +42,18 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-document-ai - 0.3.5 + 0.3.6 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.cloud:google-cloud-document-ai:0.3.5' +compile 'com.google.cloud:google-cloud-document-ai:0.3.6' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-document-ai" % "0.3.5" +libraryDependencies += "com.google.cloud" % "google-cloud-document-ai" % "0.3.6" ``` ## Authentication @@ -153,6 +153,8 @@ 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] +Java is a registered trademark of Oracle and/or its affiliates. + [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 diff --git a/google-cloud-document-ai-bom/pom.xml b/google-cloud-document-ai-bom/pom.xml index 19c883c3..a651939c 100644 --- a/google-cloud-document-ai-bom/pom.xml +++ b/google-cloud-document-ai-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-document-ai-bom - 0.3.6 + 0.3.7 pom com.google.cloud @@ -61,37 +61,37 @@ com.google.api.grpc proto-google-cloud-document-ai-v1beta1 - 0.3.6 + 0.3.7 com.google.api.grpc proto-google-cloud-document-ai-v1beta2 - 0.3.6 + 0.3.7 com.google.api.grpc proto-google-cloud-document-ai-v1beta3 - 0.3.6 + 0.3.7 com.google.api.grpc grpc-google-cloud-document-ai-v1beta1 - 0.3.6 + 0.3.7 com.google.api.grpc grpc-google-cloud-document-ai-v1beta2 - 0.3.6 + 0.3.7 com.google.api.grpc grpc-google-cloud-document-ai-v1beta3 - 0.3.6 + 0.3.7 com.google.cloud google-cloud-document-ai - 0.3.6 + 0.3.7 diff --git a/google-cloud-document-ai/pom.xml b/google-cloud-document-ai/pom.xml index f579ab53..89681f3e 100644 --- a/google-cloud-document-ai/pom.xml +++ b/google-cloud-document-ai/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-document-ai - 0.3.6 + 0.3.7 jar Google Cloud Document AI https://github.com/googleapis/java-document-ai @@ -11,7 +11,7 @@ com.google.cloud google-cloud-document-ai-parent - 0.3.6 + 0.3.7 google-cloud-document-ai 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 index 8f63c68f..2dabeae9 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -29,7 +30,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * 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 @@ -38,16 +39,7 @@ *

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: * - *

- * 
- * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
- *   List<ProcessDocumentRequest> requests = new ArrayList<>();
- *   BatchProcessDocumentsResponse response = documentUnderstandingServiceClient.batchProcessDocumentsAsync(requests).get();
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the documentUnderstandingServiceClient object to clean up + *

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(). * @@ -76,30 +68,28 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings =
  *     DocumentUnderstandingServiceSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
  * DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
  *     DocumentUnderstandingServiceClient.create(documentUnderstandingServiceSettings);
- * 
- * 
+ * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings =
  *     DocumentUnderstandingServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
  * DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
  *     DocumentUnderstandingServiceClient.create(documentUnderstandingServiceSettings);
- * 
- * 
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator") public class DocumentUnderstandingServiceClient implements BackgroundResource { private final DocumentUnderstandingServiceSettings settings; private final DocumentUnderstandingServiceStub stub; @@ -122,7 +112,7 @@ public static final DocumentUnderstandingServiceClient create( /** * Constructs an instance of DocumentUnderstandingServiceClient, using the given stub for making - * calls. This is for advanced usage - prefer to use DocumentUnderstandingServiceSettings}. + * calls. This is for advanced usage - prefer using create(DocumentUnderstandingServiceSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final DocumentUnderstandingServiceClient create( @@ -163,30 +153,17 @@ public DocumentUnderstandingServiceStub getStub() { * 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * LRO endpoint to batch process many documents. * - *

Sample code: - * - *


-   * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
-   *   List<ProcessDocumentRequest> requests = new ArrayList<>();
-   *   BatchProcessDocumentsResponse response = documentUnderstandingServiceClient.batchProcessDocumentsAsync(requests).get();
-   * }
-   * 
- * * @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 = @@ -194,74 +171,35 @@ public final OperationsClient getOperationsClient() { return batchProcessDocumentsAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * LRO endpoint to batch process many documents. * - *

Sample code: - * - *


-   * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
-   *   List<ProcessDocumentRequest> requests = new ArrayList<>();
-   *   BatchProcessDocumentsRequest request = BatchProcessDocumentsRequest.newBuilder()
-   *     .addAllRequests(requests)
-   *     .build();
-   *   BatchProcessDocumentsResponse response = documentUnderstandingServiceClient.batchProcessDocumentsAsync(request).get();
-   * }
-   * 
- * * @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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * LRO endpoint to batch process many documents. * *

Sample code: - * - *


-   * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
-   *   List<ProcessDocumentRequest> requests = new ArrayList<>();
-   *   BatchProcessDocumentsRequest request = BatchProcessDocumentsRequest.newBuilder()
-   *     .addAllRequests(requests)
-   *     .build();
-   *   OperationFuture<BatchProcessDocumentsResponse, OperationMetadata> future = documentUnderstandingServiceClient.batchProcessDocumentsOperationCallable().futureCall(request);
-   *   // Do something
-   *   BatchProcessDocumentsResponse response = future.get();
-   * }
-   * 
*/ - @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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * LRO endpoint to batch process many documents. * *

Sample code: - * - *


-   * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
-   *   List<ProcessDocumentRequest> requests = new ArrayList<>();
-   *   BatchProcessDocumentsRequest request = BatchProcessDocumentsRequest.newBuilder()
-   *     .addAllRequests(requests)
-   *     .build();
-   *   ApiFuture<Operation> future = documentUnderstandingServiceClient.batchProcessDocumentsCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
*/ public final UnaryCallable batchProcessDocumentsCallable() { 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 index 87ceed34..3838b99f 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -32,7 +33,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link DocumentUnderstandingServiceClient}. * @@ -47,26 +48,28 @@ *

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: + *

For example, to set the total timeout of batchProcessDocuments to 30 seconds: * - *

- * 
+ * 
{@code
  * DocumentUnderstandingServiceSettings.Builder documentUnderstandingServiceSettingsBuilder =
  *     DocumentUnderstandingServiceSettings.newBuilder();
  * documentUnderstandingServiceSettingsBuilder
  *     .batchProcessDocumentsSettings()
  *     .setRetrySettings(
- *         documentUnderstandingServiceSettingsBuilder.batchProcessDocumentsSettings().getRetrySettings().toBuilder()
+ *         documentUnderstandingServiceSettingsBuilder
+ *             .batchProcessDocumentsSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings = documentUnderstandingServiceSettingsBuilder.build();
- * 
- * 
+ * DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings = + * documentUnderstandingServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") -@BetaApi +@Generated("by gapic-generator-java") public class DocumentUnderstandingServiceSettings extends ClientSettings { + /** Returns the object with the settings used for calls to batchProcessDocuments. */ public UnaryCallSettings batchProcessDocumentsSettings() { @@ -75,8 +78,6 @@ public class DocumentUnderstandingServiceSettings } /** 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() { @@ -145,18 +146,15 @@ protected DocumentUnderstandingServiceSettings(Builder settingsBuilder) throws I /** Builder for DocumentUnderstandingServiceSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + 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()); } @@ -165,11 +163,15 @@ protected Builder(DocumentUnderstandingServiceStubSettings.Builder stubSettings) super(stubSettings); } + private static Builder createDefault() { + return new Builder(DocumentUnderstandingServiceStubSettings.newBuilder()); + } + public DocumentUnderstandingServiceStubSettings.Builder getStubSettingsBuilder() { return ((DocumentUnderstandingServiceStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * @@ -189,8 +191,6 @@ public Builder applyToAllUnaryMethods( } /** 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() { 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 index f7fc4875..0913ae45 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -15,29 +15,17 @@ */ /** - * A client to Cloud Document AI API. + * The interfaces provided are listed below, along with usage samples. * - *

The interfaces provided are listed below, along with usage samples. - * - *

================================== DocumentUnderstandingServiceClient - * ================================== + *

======================= DocumentUnderstandingServiceClient ======================= * *

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: - * - *

- * 
- * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
- *   List<ProcessDocumentRequest> requests = new ArrayList<>();
- *   BatchProcessDocumentsResponse response = documentUnderstandingServiceClient.batchProcessDocumentsAsync(requests);
- * }
- * 
- * 
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") 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 index e121fb0d..6058c17e 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -26,22 +26,19 @@ import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Cloud Document AI API. + * Base stub class for the DocumentUnderstandingService service 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() { 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 index c3becb3d..f0544ae9 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -47,7 +48,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link DocumentUnderstandingServiceStub}. * @@ -62,24 +63,26 @@ *

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: + *

For example, to set the total timeout of batchProcessDocuments to 30 seconds: * - *

- * 
+ * 
{@code
  * DocumentUnderstandingServiceStubSettings.Builder documentUnderstandingServiceSettingsBuilder =
  *     DocumentUnderstandingServiceStubSettings.newBuilder();
  * documentUnderstandingServiceSettingsBuilder
  *     .batchProcessDocumentsSettings()
  *     .setRetrySettings(
- *         documentUnderstandingServiceSettingsBuilder.batchProcessDocumentsSettings().getRetrySettings().toBuilder()
+ *         documentUnderstandingServiceSettingsBuilder
+ *             .batchProcessDocumentsSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * DocumentUnderstandingServiceStubSettings documentUnderstandingServiceSettings = documentUnderstandingServiceSettingsBuilder.build();
- * 
- * 
+ * DocumentUnderstandingServiceStubSettings documentUnderstandingServiceSettings = + * documentUnderstandingServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator-java") public class DocumentUnderstandingServiceStubSettings extends StubSettings { /** The default scopes of the service. */ @@ -99,7 +102,6 @@ public class DocumentUnderstandingServiceStubSettings } /** 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() { @@ -112,10 +114,10 @@ public DocumentUnderstandingServiceStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDocumentUnderstandingServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -185,13 +187,11 @@ protected DocumentUnderstandingServiceStubSettings(Builder settingsBuilder) thro 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; @@ -199,11 +199,10 @@ public static class Builder ImmutableMap.Builder> definitions = ImmutableMap.builder(); definitions.put( - "retry_policy_1_codes", + "retry_policy_0_codes", ImmutableSet.copyOf( Lists.newArrayList( StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -222,51 +221,60 @@ public static class Builder .setMaxRpcTimeout(Duration.ofMillis(60000L)) .setTotalTimeout(Duration.ofMillis(60000L)) .build(); - definitions.put("retry_policy_1_params", settings); - settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); - definitions.put("no_retry_params", settings); + definitions.put("retry_policy_0_params", settings); RETRY_PARAM_DEFINITIONS = definitions.build(); } protected Builder() { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(clientContext); batchProcessDocumentsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - batchProcessDocumentsOperationSettings = OperationCallSettings.newBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of(batchProcessDocumentsSettings); - initDefaults(this); } + protected Builder(DocumentUnderstandingServiceStubSettings settings) { + super(settings); + + batchProcessDocumentsSettings = settings.batchProcessDocumentsSettings.toBuilder(); + batchProcessDocumentsOperationSettings = + settings.batchProcessDocumentsOperationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of(batchProcessDocumentsSettings); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + 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("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + builder .batchProcessDocumentsOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create( @@ -276,30 +284,19 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .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' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * 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 index f66ebe91..4154cc07 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -31,18 +31,19 @@ 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.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Cloud Document AI API. + * gRPC callable factory implementation for the DocumentUnderstandingService service 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, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, 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, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, 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 index 63bc20b3..bdf8d23c 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -37,16 +37,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Cloud Document AI API. + * gRPC stub implementation for the DocumentUnderstandingService service 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") +@Generated("by gapic-generator-java") public class GrpcDocumentUnderstandingServiceStub extends DocumentUnderstandingServiceStub { - private static final MethodDescriptor batchProcessDocumentsMethodDescriptor = MethodDescriptor.newBuilder() @@ -58,15 +56,14 @@ public class GrpcDocumentUnderstandingServiceStub extends DocumentUnderstandingS .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 BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcDocumentUnderstandingServiceStub create( @@ -137,27 +134,26 @@ public Map extract(BatchProcessDocumentsRequest request) { batchProcessDocumentsTransportSettings, settings.batchProcessDocumentsOperationSettings(), clientContext, - this.operationsStub); + operationsStub); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.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 UnaryCallable batchProcessDocumentsCallable() { + return batchProcessDocumentsCallable; + } + public OperationCallable< BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata> batchProcessDocumentsOperationCallable() { return batchProcessDocumentsOperationCallable; } - public UnaryCallable batchProcessDocumentsCallable() { - return batchProcessDocumentsCallable; - } - @Override public final void close() { shutdown(); 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 index 33dc230e..dea9646d 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -29,7 +30,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * 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 @@ -38,19 +39,7 @@ *

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: * - *

- * 
- * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
- *   InputConfig inputConfig = InputConfig.newBuilder().build();
- *   ProcessDocumentRequest request = ProcessDocumentRequest.newBuilder()
- *     .setInputConfig(inputConfig)
- *     .build();
- *   Document response = documentUnderstandingServiceClient.processDocument(request);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the documentUnderstandingServiceClient object to clean up + *

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(). * @@ -79,30 +68,28 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings =
  *     DocumentUnderstandingServiceSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
  * DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
  *     DocumentUnderstandingServiceClient.create(documentUnderstandingServiceSettings);
- * 
- * 
+ * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings =
  *     DocumentUnderstandingServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
  * DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
  *     DocumentUnderstandingServiceClient.create(documentUnderstandingServiceSettings);
- * 
- * 
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator") public class DocumentUnderstandingServiceClient implements BackgroundResource { private final DocumentUnderstandingServiceSettings settings; private final DocumentUnderstandingServiceStub stub; @@ -125,7 +112,7 @@ public static final DocumentUnderstandingServiceClient create( /** * Constructs an instance of DocumentUnderstandingServiceClient, using the given stub for making - * calls. This is for advanced usage - prefer to use DocumentUnderstandingServiceSettings}. + * calls. This is for advanced usage - prefer using create(DocumentUnderstandingServiceSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final DocumentUnderstandingServiceClient create( @@ -166,31 +153,18 @@ public DocumentUnderstandingServiceStub getStub() { * 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 + // 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. * - *

Sample code: - * - *


-   * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
-   *   List<ProcessDocumentRequest> requests = new ArrayList<>();
-   *   BatchProcessDocumentsResponse response = documentUnderstandingServiceClient.batchProcessDocumentsAsync(requests).get();
-   * }
-   * 
- * * @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 = @@ -198,99 +172,48 @@ public final OperationsClient getOperationsClient() { return batchProcessDocumentsAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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. * - *

Sample code: - * - *


-   * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
-   *   List<ProcessDocumentRequest> requests = new ArrayList<>();
-   *   BatchProcessDocumentsRequest request = BatchProcessDocumentsRequest.newBuilder()
-   *     .addAllRequests(requests)
-   *     .build();
-   *   BatchProcessDocumentsResponse response = documentUnderstandingServiceClient.batchProcessDocumentsAsync(request).get();
-   * }
-   * 
- * * @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 + // 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. * *

Sample code: - * - *


-   * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
-   *   List<ProcessDocumentRequest> requests = new ArrayList<>();
-   *   BatchProcessDocumentsRequest request = BatchProcessDocumentsRequest.newBuilder()
-   *     .addAllRequests(requests)
-   *     .build();
-   *   OperationFuture<BatchProcessDocumentsResponse, OperationMetadata> future = documentUnderstandingServiceClient.batchProcessDocumentsOperationCallable().futureCall(request);
-   *   // Do something
-   *   BatchProcessDocumentsResponse response = future.get();
-   * }
-   * 
*/ - @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 + // 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. * *

Sample code: - * - *


-   * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
-   *   List<ProcessDocumentRequest> requests = new ArrayList<>();
-   *   BatchProcessDocumentsRequest request = BatchProcessDocumentsRequest.newBuilder()
-   *     .addAllRequests(requests)
-   *     .build();
-   *   ApiFuture<Operation> future = documentUnderstandingServiceClient.batchProcessDocumentsCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
*/ public final UnaryCallable batchProcessDocumentsCallable() { return stub.batchProcessDocumentsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Processes a single document. * - *

Sample code: - * - *


-   * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
-   *   InputConfig inputConfig = InputConfig.newBuilder().build();
-   *   ProcessDocumentRequest request = ProcessDocumentRequest.newBuilder()
-   *     .setInputConfig(inputConfig)
-   *     .build();
-   *   Document response = documentUnderstandingServiceClient.processDocument(request);
-   * }
-   * 
- * * @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 */ @@ -298,23 +221,11 @@ public final Document processDocument(ProcessDocumentRequest request) { return processDocumentCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Processes a single document. * *

Sample code: - * - *


-   * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
-   *   InputConfig inputConfig = InputConfig.newBuilder().build();
-   *   ProcessDocumentRequest request = ProcessDocumentRequest.newBuilder()
-   *     .setInputConfig(inputConfig)
-   *     .build();
-   *   ApiFuture<Document> future = documentUnderstandingServiceClient.processDocumentCallable().futureCall(request);
-   *   // Do something
-   *   Document response = future.get();
-   * }
-   * 
*/ public final UnaryCallable processDocumentCallable() { return stub.processDocumentCallable(); 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 index fe466b58..ecf9a8ae 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -32,7 +33,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link DocumentUnderstandingServiceClient}. * @@ -49,24 +50,26 @@ * *

For example, to set the total timeout of processDocument to 30 seconds: * - *

- * 
+ * 
{@code
  * DocumentUnderstandingServiceSettings.Builder documentUnderstandingServiceSettingsBuilder =
  *     DocumentUnderstandingServiceSettings.newBuilder();
  * documentUnderstandingServiceSettingsBuilder
  *     .processDocumentSettings()
  *     .setRetrySettings(
- *         documentUnderstandingServiceSettingsBuilder.processDocumentSettings().getRetrySettings().toBuilder()
+ *         documentUnderstandingServiceSettingsBuilder
+ *             .processDocumentSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings = documentUnderstandingServiceSettingsBuilder.build();
- * 
- * 
+ * DocumentUnderstandingServiceSettings documentUnderstandingServiceSettings = + * documentUnderstandingServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") -@BetaApi +@Generated("by gapic-generator-java") public class DocumentUnderstandingServiceSettings extends ClientSettings { + /** Returns the object with the settings used for calls to batchProcessDocuments. */ public UnaryCallSettings batchProcessDocumentsSettings() { @@ -75,8 +78,6 @@ public class DocumentUnderstandingServiceSettings } /** 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() { @@ -150,18 +151,15 @@ protected DocumentUnderstandingServiceSettings(Builder settingsBuilder) throws I /** Builder for DocumentUnderstandingServiceSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + 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()); } @@ -170,11 +168,15 @@ protected Builder(DocumentUnderstandingServiceStubSettings.Builder stubSettings) super(stubSettings); } + private static Builder createDefault() { + return new Builder(DocumentUnderstandingServiceStubSettings.newBuilder()); + } + public DocumentUnderstandingServiceStubSettings.Builder getStubSettingsBuilder() { return ((DocumentUnderstandingServiceStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * @@ -194,8 +196,6 @@ public Builder applyToAllUnaryMethods( } /** 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() { 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 index 07963129..4284f8dc 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -15,32 +15,17 @@ */ /** - * A client to Cloud Document AI API. + * The interfaces provided are listed below, along with usage samples. * - *

The interfaces provided are listed below, along with usage samples. - * - *

================================== DocumentUnderstandingServiceClient - * ================================== + *

======================= DocumentUnderstandingServiceClient ======================= * *

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: - * - *

- * 
- * try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient = DocumentUnderstandingServiceClient.create()) {
- *   InputConfig inputConfig = InputConfig.newBuilder().build();
- *   ProcessDocumentRequest request = ProcessDocumentRequest.newBuilder()
- *     .setInputConfig(inputConfig)
- *     .build();
- *   Document response = documentUnderstandingServiceClient.processDocument(request);
- * }
- * 
- * 
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") 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 index 5d3928b5..8f62eb5a 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -28,22 +28,19 @@ import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Cloud Document AI API. + * Base stub class for the DocumentUnderstandingService service 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() { 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 index 1922073f..ffa878c3 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -49,7 +50,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link DocumentUnderstandingServiceStub}. * @@ -66,22 +67,24 @@ * *

For example, to set the total timeout of processDocument to 30 seconds: * - *

- * 
+ * 
{@code
  * DocumentUnderstandingServiceStubSettings.Builder documentUnderstandingServiceSettingsBuilder =
  *     DocumentUnderstandingServiceStubSettings.newBuilder();
  * documentUnderstandingServiceSettingsBuilder
  *     .processDocumentSettings()
  *     .setRetrySettings(
- *         documentUnderstandingServiceSettingsBuilder.processDocumentSettings().getRetrySettings().toBuilder()
+ *         documentUnderstandingServiceSettingsBuilder
+ *             .processDocumentSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * DocumentUnderstandingServiceStubSettings documentUnderstandingServiceSettings = documentUnderstandingServiceSettingsBuilder.build();
- * 
- * 
+ * DocumentUnderstandingServiceStubSettings documentUnderstandingServiceSettings = + * documentUnderstandingServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator-java") public class DocumentUnderstandingServiceStubSettings extends StubSettings { /** The default scopes of the service. */ @@ -102,7 +105,6 @@ public class DocumentUnderstandingServiceStubSettings } /** 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() { @@ -120,10 +122,10 @@ public DocumentUnderstandingServiceStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDocumentUnderstandingServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -194,7 +196,6 @@ protected DocumentUnderstandingServiceStubSettings(Builder settingsBuilder) thro public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - private final UnaryCallSettings.Builder batchProcessDocumentsSettings; private final OperationCallSettings.Builder< @@ -202,7 +203,6 @@ public static class Builder batchProcessDocumentsOperationSettings; private final UnaryCallSettings.Builder processDocumentSettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -210,11 +210,10 @@ public static class Builder ImmutableMap.Builder> definitions = ImmutableMap.builder(); definitions.put( - "retry_policy_1_codes", + "retry_policy_0_codes", ImmutableSet.copyOf( Lists.newArrayList( StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -233,59 +232,69 @@ public static class Builder .setMaxRpcTimeout(Duration.ofMillis(120000L)) .setTotalTimeout(Duration.ofMillis(120000L)) .build(); - definitions.put("retry_policy_1_params", settings); - settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); - definitions.put("no_retry_params", settings); + definitions.put("retry_policy_0_params", settings); RETRY_PARAM_DEFINITIONS = definitions.build(); } protected Builder() { - this((ClientContext) null); + 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); } + protected Builder(DocumentUnderstandingServiceStubSettings settings) { + super(settings); + + batchProcessDocumentsSettings = settings.batchProcessDocumentsSettings.toBuilder(); + batchProcessDocumentsOperationSettings = + settings.batchProcessDocumentsOperationSettings.toBuilder(); + processDocumentSettings = settings.processDocumentSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + batchProcessDocumentsSettings, processDocumentSettings); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + 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("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); builder .processDocumentSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + builder .batchProcessDocumentsOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create( @@ -295,32 +304,19 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .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' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * 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 index 6ea0b58a..19aa1f5f 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -31,18 +31,19 @@ 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.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Cloud Document AI API. + * gRPC callable factory implementation for the DocumentUnderstandingService service 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, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, 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, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, 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 index 39430b8c..84be5044 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -39,16 +39,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Cloud Document AI API. + * gRPC stub implementation for the DocumentUnderstandingService service 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") +@Generated("by gapic-generator-java") public class GrpcDocumentUnderstandingServiceStub extends DocumentUnderstandingServiceStub { - private static final MethodDescriptor batchProcessDocumentsMethodDescriptor = MethodDescriptor.newBuilder() @@ -59,6 +57,7 @@ public class GrpcDocumentUnderstandingServiceStub extends DocumentUnderstandingS ProtoUtils.marshaller(BatchProcessDocumentsRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor processDocumentMethodDescriptor = MethodDescriptor.newBuilder() @@ -70,9 +69,6 @@ public class GrpcDocumentUnderstandingServiceStub extends DocumentUnderstandingS .setResponseMarshaller(ProtoUtils.marshaller(Document.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final GrpcOperationsStub operationsStub; - private final UnaryCallable batchProcessDocumentsCallable; private final OperationCallable< @@ -80,6 +76,8 @@ public class GrpcDocumentUnderstandingServiceStub extends DocumentUnderstandingS batchProcessDocumentsOperationCallable; private final UnaryCallable processDocumentCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcDocumentUnderstandingServiceStub create( @@ -163,30 +161,29 @@ public Map extract(ProcessDocumentRequest request) { batchProcessDocumentsTransportSettings, settings.batchProcessDocumentsOperationSettings(), clientContext, - this.operationsStub); + operationsStub); this.processDocumentCallable = callableFactory.createUnaryCallable( processDocumentTransportSettings, settings.processDocumentSettings(), clientContext); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.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 UnaryCallable batchProcessDocumentsCallable() { + return batchProcessDocumentsCallable; + } + public OperationCallable< BatchProcessDocumentsRequest, BatchProcessDocumentsResponse, OperationMetadata> batchProcessDocumentsOperationCallable() { return batchProcessDocumentsOperationCallable; } - public UnaryCallable batchProcessDocumentsCallable() { - return batchProcessDocumentsCallable; - } - public UnaryCallable processDocumentCallable() { return processDocumentCallable; } diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java index 5715eb78..b8be53b9 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClient.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.documentai.v1beta3; import com.google.api.core.BetaApi; @@ -28,7 +29,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Service Description: Service to call Cloud DocumentAI to process documents according to the * processor's definition. Processors are built using state-of-the-art Google AI such as natural @@ -38,16 +39,7 @@ *

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: * - *

- * 
- * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
- *   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
- *   ProcessResponse response = documentProcessorServiceClient.processDocument(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the documentProcessorServiceClient object to clean up + *

Note: close() needs to be called on the DocumentProcessorServiceClient object to clean up * resources such as threads. In the example above, try-with-resources is used, which automatically * calls close(). * @@ -76,30 +68,28 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * DocumentProcessorServiceSettings documentProcessorServiceSettings =
  *     DocumentProcessorServiceSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
  * DocumentProcessorServiceClient documentProcessorServiceClient =
  *     DocumentProcessorServiceClient.create(documentProcessorServiceSettings);
- * 
- * 
+ * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * DocumentProcessorServiceSettings documentProcessorServiceSettings =
  *     DocumentProcessorServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
  * DocumentProcessorServiceClient documentProcessorServiceClient =
  *     DocumentProcessorServiceClient.create(documentProcessorServiceSettings);
- * 
- * 
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator") public class DocumentProcessorServiceClient implements BackgroundResource { private final DocumentProcessorServiceSettings settings; private final DocumentProcessorServiceStub stub; @@ -122,7 +112,7 @@ public static final DocumentProcessorServiceClient create( /** * Constructs an instance of DocumentProcessorServiceClient, using the given stub for making - * calls. This is for advanced usage - prefer to use DocumentProcessorServiceSettings}. + * calls. This is for advanced usage - prefer using create(DocumentProcessorServiceSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final DocumentProcessorServiceClient create(DocumentProcessorServiceStub stub) { @@ -161,25 +151,14 @@ public DocumentProcessorServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - @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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Processes a single document. * - *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   ProcessResponse response = documentProcessorServiceClient.processDocument(name);
-   * }
-   * 
- * * @param name Required. The processor resource name. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -189,19 +168,10 @@ public final ProcessResponse processDocument(ProcessorName name) { return processDocument(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Processes a single document. * - *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   ProcessResponse response = documentProcessorServiceClient.processDocument(name.toString());
-   * }
-   * 
- * * @param name Required. The processor resource name. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -210,22 +180,10 @@ public final ProcessResponse processDocument(String name) { return processDocument(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Processes a single document. * - *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   ProcessRequest request = ProcessRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ProcessResponse response = documentProcessorServiceClient.processDocument(request);
-   * }
-   * 
- * * @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 */ @@ -233,47 +191,24 @@ public final ProcessResponse processDocument(ProcessRequest request) { return processDocumentCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Processes a single document. * *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   ProcessRequest request = ProcessRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<ProcessResponse> future = documentProcessorServiceClient.processDocumentCallable().futureCall(request);
-   *   // Do something
-   *   ProcessResponse response = future.get();
-   * }
-   * 
*/ public final UnaryCallable processDocumentCallable() { return stub.processDocumentCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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. * - *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   BatchProcessResponse response = documentProcessorServiceClient.batchProcessDocumentsAsync(name).get();
-   * }
-   * 
- * * @param name Required. The processor resource name. * @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(ProcessorName name) { BatchProcessRequest request = @@ -281,126 +216,65 @@ public final UnaryCallable processDocumentCalla return batchProcessDocumentsAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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. * - *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   BatchProcessResponse response = documentProcessorServiceClient.batchProcessDocumentsAsync(name.toString()).get();
-   * }
-   * 
- * * @param name Required. The processor resource name. * @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(String name) { BatchProcessRequest request = BatchProcessRequest.newBuilder().setName(name).build(); return batchProcessDocumentsAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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. * - *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   BatchProcessRequest request = BatchProcessRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   BatchProcessResponse response = documentProcessorServiceClient.batchProcessDocumentsAsync(request).get();
-   * }
-   * 
- * * @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(BatchProcessRequest request) { return batchProcessDocumentsOperationCallable().futureCall(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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. * *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   BatchProcessRequest request = BatchProcessRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   OperationFuture<BatchProcessResponse, BatchProcessMetadata> future = documentProcessorServiceClient.batchProcessDocumentsOperationCallable().futureCall(request);
-   *   // Do something
-   *   BatchProcessResponse response = future.get();
-   * }
-   * 
*/ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable batchProcessDocumentsOperationCallable() { return stub.batchProcessDocumentsOperationCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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. * *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   BatchProcessRequest request = BatchProcessRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Operation> future = documentProcessorServiceClient.batchProcessDocumentsCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
*/ public final UnaryCallable batchProcessDocumentsCallable() { return stub.batchProcessDocumentsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Send a document for Human Review. The input document should be processed by the specified * processor. * - *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   HumanReviewConfigName humanReviewConfig = HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   ReviewDocumentResponse response = documentProcessorServiceClient.reviewDocumentAsync(humanReviewConfig).get();
-   * }
-   * 
- * * @param humanReviewConfig Required. The resource name of the HumanReviewConfig that the document * will be reviewed with. * @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 reviewDocumentAsync(HumanReviewConfigName humanReviewConfig) { ReviewDocumentRequest request = @@ -410,26 +284,15 @@ public final UnaryCallable batchProcessDocuments return reviewDocumentAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Send a document for Human Review. The input document should be processed by the specified * processor. * - *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   HumanReviewConfigName humanReviewConfig = HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   ReviewDocumentResponse response = documentProcessorServiceClient.reviewDocumentAsync(humanReviewConfig.toString()).get();
-   * }
-   * 
- * * @param humanReviewConfig Required. The resource name of the HumanReviewConfig that the document * will be reviewed with. * @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 reviewDocumentAsync(String humanReviewConfig) { ReviewDocumentRequest request = @@ -437,77 +300,38 @@ public final UnaryCallable batchProcessDocuments return reviewDocumentAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Send a document for Human Review. The input document should be processed by the specified * processor. * - *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   HumanReviewConfigName humanReviewConfig = HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   ReviewDocumentRequest request = ReviewDocumentRequest.newBuilder()
-   *     .setHumanReviewConfig(humanReviewConfig.toString())
-   *     .build();
-   *   ReviewDocumentResponse response = documentProcessorServiceClient.reviewDocumentAsync(request).get();
-   * }
-   * 
- * * @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 reviewDocumentAsync(ReviewDocumentRequest request) { return reviewDocumentOperationCallable().futureCall(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Send a document for Human Review. The input document should be processed by the specified * processor. * *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   HumanReviewConfigName humanReviewConfig = HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   ReviewDocumentRequest request = ReviewDocumentRequest.newBuilder()
-   *     .setHumanReviewConfig(humanReviewConfig.toString())
-   *     .build();
-   *   OperationFuture<ReviewDocumentResponse, ReviewDocumentOperationMetadata> future = documentProcessorServiceClient.reviewDocumentOperationCallable().futureCall(request);
-   *   // Do something
-   *   ReviewDocumentResponse response = future.get();
-   * }
-   * 
*/ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable< ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> reviewDocumentOperationCallable() { return stub.reviewDocumentOperationCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Send a document for Human Review. The input document should be processed by the specified * processor. * *

Sample code: - * - *


-   * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
-   *   HumanReviewConfigName humanReviewConfig = HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
-   *   ReviewDocumentRequest request = ReviewDocumentRequest.newBuilder()
-   *     .setHumanReviewConfig(humanReviewConfig.toString())
-   *     .build();
-   *   ApiFuture<Operation> future = documentProcessorServiceClient.reviewDocumentCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
*/ public final UnaryCallable reviewDocumentCallable() { return stub.reviewDocumentCallable(); diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceSettings.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceSettings.java index 0a65f139..1c5cedf7 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceSettings.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.documentai.v1beta3; import com.google.api.core.ApiFunction; @@ -32,7 +33,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link DocumentProcessorServiceClient}. * @@ -49,24 +50,26 @@ * *

For example, to set the total timeout of processDocument to 30 seconds: * - *

- * 
+ * 
{@code
  * DocumentProcessorServiceSettings.Builder documentProcessorServiceSettingsBuilder =
  *     DocumentProcessorServiceSettings.newBuilder();
  * documentProcessorServiceSettingsBuilder
  *     .processDocumentSettings()
  *     .setRetrySettings(
- *         documentProcessorServiceSettingsBuilder.processDocumentSettings().getRetrySettings().toBuilder()
+ *         documentProcessorServiceSettingsBuilder
+ *             .processDocumentSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * DocumentProcessorServiceSettings documentProcessorServiceSettings = documentProcessorServiceSettingsBuilder.build();
- * 
- * 
+ * DocumentProcessorServiceSettings documentProcessorServiceSettings = + * documentProcessorServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") -@BetaApi +@Generated("by gapic-generator-java") public class DocumentProcessorServiceSettings extends ClientSettings { + /** Returns the object with the settings used for calls to processDocument. */ public UnaryCallSettings processDocumentSettings() { return ((DocumentProcessorServiceStubSettings) getStubSettings()).processDocumentSettings(); @@ -79,8 +82,6 @@ public UnaryCallSettings batchProcessDocumentsSe } /** 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 batchProcessDocumentsOperationSettings() { return ((DocumentProcessorServiceStubSettings) getStubSettings()) @@ -93,8 +94,6 @@ public UnaryCallSettings reviewDocumentSetting } /** Returns the object with the settings used for calls to reviewDocument. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings< ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> reviewDocumentOperationSettings() { @@ -163,18 +162,15 @@ protected DocumentProcessorServiceSettings(Builder settingsBuilder) throws IOExc /** Builder for DocumentProcessorServiceSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(DocumentProcessorServiceStubSettings.newBuilder(clientContext)); } - private static Builder createDefault() { - return new Builder(DocumentProcessorServiceStubSettings.newBuilder()); - } - protected Builder(DocumentProcessorServiceSettings settings) { super(settings.getStubSettings().toBuilder()); } @@ -183,11 +179,15 @@ protected Builder(DocumentProcessorServiceStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(DocumentProcessorServiceStubSettings.newBuilder()); + } + public DocumentProcessorServiceStubSettings.Builder getStubSettingsBuilder() { return ((DocumentProcessorServiceStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * @@ -212,8 +212,6 @@ public UnaryCallSettings.Builder processDocumen } /** 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< BatchProcessRequest, BatchProcessResponse, BatchProcessMetadata> batchProcessDocumentsOperationSettings() { @@ -226,8 +224,6 @@ public UnaryCallSettings.Builder reviewDocumen } /** Returns the builder for the settings used for calls to reviewDocument. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder< ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> reviewDocumentOperationSettings() { diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/package-info.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/package-info.java index 62aab8d1..99ba0a34 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/package-info.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/package-info.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -15,11 +15,9 @@ */ /** - * A client to Cloud Document AI API. + * The interfaces provided are listed below, along with usage samples. * - *

The interfaces provided are listed below, along with usage samples. - * - *

============================== DocumentProcessorServiceClient ============================== + *

======================= DocumentProcessorServiceClient ======================= * *

Service Description: Service to call Cloud DocumentAI to process documents according to the * processor's definition. Processors are built using state-of-the-art Google AI such as natural @@ -27,17 +25,8 @@ * semi-structured documents. * *

Sample for DocumentProcessorServiceClient: - * - *

- * 
- * try (DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.create()) {
- *   ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
- *   ProcessResponse response = documentProcessorServiceClient.processDocument(name);
- * }
- * 
- * 
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") package com.google.cloud.documentai.v1beta3; import javax.annotation.Generated; diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStub.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStub.java index a408e717..dd9423b0 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStub.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.documentai.v1beta3.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; @@ -31,17 +31,15 @@ import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Cloud Document AI API. + * Base stub class for the DocumentProcessorService service 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 DocumentProcessorServiceStub 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()"); } @@ -50,7 +48,6 @@ public UnaryCallable processDocumentCallable() throw new UnsupportedOperationException("Not implemented: processDocumentCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable batchProcessDocumentsOperationCallable() { throw new UnsupportedOperationException( @@ -61,7 +58,6 @@ public UnaryCallable batchProcessDocumentsCallab throw new UnsupportedOperationException("Not implemented: batchProcessDocumentsCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable< ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> reviewDocumentOperationCallable() { diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStubSettings.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStubSettings.java index acab2af4..b7b2814d 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStubSettings.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/DocumentProcessorServiceStubSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.documentai.v1beta3.stub; import com.google.api.core.ApiFunction; @@ -52,7 +53,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link DocumentProcessorServiceStub}. * @@ -69,22 +70,24 @@ * *

For example, to set the total timeout of processDocument to 30 seconds: * - *

- * 
+ * 
{@code
  * DocumentProcessorServiceStubSettings.Builder documentProcessorServiceSettingsBuilder =
  *     DocumentProcessorServiceStubSettings.newBuilder();
  * documentProcessorServiceSettingsBuilder
  *     .processDocumentSettings()
  *     .setRetrySettings(
- *         documentProcessorServiceSettingsBuilder.processDocumentSettings().getRetrySettings().toBuilder()
+ *         documentProcessorServiceSettingsBuilder
+ *             .processDocumentSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * DocumentProcessorServiceStubSettings documentProcessorServiceSettings = documentProcessorServiceSettingsBuilder.build();
- * 
- * 
+ * DocumentProcessorServiceStubSettings documentProcessorServiceSettings = + * documentProcessorServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator-java") public class DocumentProcessorServiceStubSettings extends StubSettings { /** The default scopes of the service. */ @@ -112,7 +115,6 @@ public UnaryCallSettings batchProcessDocumentsSe } /** 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 batchProcessDocumentsOperationSettings() { return batchProcessDocumentsOperationSettings; @@ -124,7 +126,6 @@ public UnaryCallSettings reviewDocumentSetting } /** Returns the object with the settings used for calls to reviewDocument. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings< ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> reviewDocumentOperationSettings() { @@ -137,10 +138,10 @@ public DocumentProcessorServiceStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDocumentProcessorServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -212,7 +213,6 @@ protected DocumentProcessorServiceStubSettings(Builder settingsBuilder) throws I public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - private final UnaryCallSettings.Builder processDocumentSettings; private final UnaryCallSettings.Builder @@ -225,7 +225,6 @@ public static class Builder private final OperationCallSettings.Builder< ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> reviewDocumentOperationSettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -233,11 +232,10 @@ public static class Builder ImmutableMap.Builder> definitions = ImmutableMap.builder(); definitions.put( - "retry_policy_1_codes", + "retry_policy_0_codes", ImmutableSet.copyOf( Lists.newArrayList( StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -256,68 +254,78 @@ public static class Builder .setMaxRpcTimeout(Duration.ofMillis(120000L)) .setTotalTimeout(Duration.ofMillis(120000L)) .build(); - definitions.put("retry_policy_1_params", settings); - settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); - definitions.put("no_retry_params", settings); + definitions.put("retry_policy_0_params", settings); RETRY_PARAM_DEFINITIONS = definitions.build(); } protected Builder() { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(clientContext); processDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - batchProcessDocumentsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - batchProcessDocumentsOperationSettings = OperationCallSettings.newBuilder(); - reviewDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - reviewDocumentOperationSettings = OperationCallSettings.newBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of( processDocumentSettings, batchProcessDocumentsSettings, reviewDocumentSettings); - initDefaults(this); } + protected Builder(DocumentProcessorServiceStubSettings settings) { + super(settings); + + processDocumentSettings = settings.processDocumentSettings.toBuilder(); + batchProcessDocumentsSettings = settings.batchProcessDocumentsSettings.toBuilder(); + batchProcessDocumentsOperationSettings = + settings.batchProcessDocumentsOperationSettings.toBuilder(); + reviewDocumentSettings = settings.reviewDocumentSettings.toBuilder(); + reviewDocumentOperationSettings = settings.reviewDocumentOperationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + processDocumentSettings, batchProcessDocumentsSettings, reviewDocumentSettings); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + 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 .processDocumentSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); builder .batchProcessDocumentsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); builder .reviewDocumentSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + builder .batchProcessDocumentsOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(BatchProcessResponse.class)) @@ -326,21 +334,22 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); + builder .reviewDocumentOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(ReviewDocumentResponse.class)) @@ -350,34 +359,19 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); return builder; } - protected Builder(DocumentProcessorServiceStubSettings settings) { - super(settings); - - processDocumentSettings = settings.processDocumentSettings.toBuilder(); - batchProcessDocumentsSettings = settings.batchProcessDocumentsSettings.toBuilder(); - batchProcessDocumentsOperationSettings = - settings.batchProcessDocumentsOperationSettings.toBuilder(); - reviewDocumentSettings = settings.reviewDocumentSettings.toBuilder(); - reviewDocumentOperationSettings = settings.reviewDocumentOperationSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - processDocumentSettings, batchProcessDocumentsSettings, reviewDocumentSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/GrpcDocumentProcessorServiceCallableFactory.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/GrpcDocumentProcessorServiceCallableFactory.java index 17df0bd9..4ad757da 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/GrpcDocumentProcessorServiceCallableFactory.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/GrpcDocumentProcessorServiceCallableFactory.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.documentai.v1beta3.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -31,18 +31,19 @@ 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.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Cloud Document AI API. + * gRPC callable factory implementation for the DocumentProcessorService service 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 GrpcDocumentProcessorServiceCallableFactory implements GrpcStubCallableFactory { + @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, 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, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/GrpcDocumentProcessorServiceStub.java b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/GrpcDocumentProcessorServiceStub.java index e73f292b..fc5760c7 100644 --- a/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/GrpcDocumentProcessorServiceStub.java +++ b/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta3/stub/GrpcDocumentProcessorServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.documentai.v1beta3.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -42,16 +42,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Cloud Document AI API. + * gRPC stub implementation for the DocumentProcessorService service 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") +@Generated("by gapic-generator-java") public class GrpcDocumentProcessorServiceStub extends DocumentProcessorServiceStub { - private static final MethodDescriptor processDocumentMethodDescriptor = MethodDescriptor.newBuilder() @@ -61,6 +59,7 @@ public class GrpcDocumentProcessorServiceStub extends DocumentProcessorServiceSt .setRequestMarshaller(ProtoUtils.marshaller(ProcessRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(ProcessResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor batchProcessDocumentsMethodDescriptor = MethodDescriptor.newBuilder() @@ -70,6 +69,7 @@ public class GrpcDocumentProcessorServiceStub extends DocumentProcessorServiceSt .setRequestMarshaller(ProtoUtils.marshaller(BatchProcessRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor reviewDocumentMethodDescriptor = MethodDescriptor.newBuilder() @@ -81,9 +81,6 @@ public class GrpcDocumentProcessorServiceStub extends DocumentProcessorServiceSt .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final GrpcOperationsStub operationsStub; - private final UnaryCallable processDocumentCallable; private final UnaryCallable batchProcessDocumentsCallable; private final OperationCallable @@ -93,6 +90,8 @@ public class GrpcDocumentProcessorServiceStub extends DocumentProcessorServiceSt ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> reviewDocumentOperationCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcDocumentProcessorServiceStub create( @@ -190,7 +189,7 @@ public Map extract(ReviewDocumentRequest request) { batchProcessDocumentsTransportSettings, settings.batchProcessDocumentsOperationSettings(), clientContext, - this.operationsStub); + operationsStub); this.reviewDocumentCallable = callableFactory.createUnaryCallable( reviewDocumentTransportSettings, settings.reviewDocumentSettings(), clientContext); @@ -199,12 +198,12 @@ public Map extract(ReviewDocumentRequest request) { reviewDocumentTransportSettings, settings.reviewDocumentOperationSettings(), clientContext, - this.operationsStub); + operationsStub); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.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; } @@ -213,27 +212,25 @@ public UnaryCallable processDocumentCallable() return processDocumentCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public UnaryCallable batchProcessDocumentsCallable() { + return batchProcessDocumentsCallable; + } + public OperationCallable batchProcessDocumentsOperationCallable() { return batchProcessDocumentsOperationCallable; } - public UnaryCallable batchProcessDocumentsCallable() { - return batchProcessDocumentsCallable; + public UnaryCallable reviewDocumentCallable() { + return reviewDocumentCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable< ReviewDocumentRequest, ReviewDocumentResponse, ReviewDocumentOperationMetadata> reviewDocumentOperationCallable() { return reviewDocumentOperationCallable; } - public UnaryCallable reviewDocumentCallable() { - return reviewDocumentCallable; - } - @Override public final void close() { shutdown(); 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 index 0ff114e1..dfbcf46f 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -26,7 +27,6 @@ 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; @@ -34,6 +34,7 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -41,32 +42,32 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class DocumentUnderstandingServiceClientTest { private static MockDocumentUnderstandingService mockDocumentUnderstandingService; - private static MockServiceHelper serviceHelper; + private static MockServiceHelper mockServiceHelper; private DocumentUnderstandingServiceClient client; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { mockDocumentUnderstandingService = new MockDocumentUnderstandingService(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), Arrays.asList(mockDocumentUnderstandingService)); - serviceHelper.start(); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); DocumentUnderstandingServiceSettings settings = DocumentUnderstandingServiceSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -81,10 +82,11 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") public void batchProcessDocumentsTest() throws Exception { BatchProcessDocumentsResponse expectedResponse = - BatchProcessDocumentsResponse.newBuilder().build(); + BatchProcessDocumentsResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); Operation resultOperation = Operation.newBuilder() .setName("batchProcessDocumentsTest") @@ -102,7 +104,7 @@ public void batchProcessDocumentsTest() throws Exception { List actualRequests = mockDocumentUnderstandingService.getRequests(); Assert.assertEquals(1, actualRequests.size()); BatchProcessDocumentsRequest actualRequest = - (BatchProcessDocumentsRequest) actualRequests.get(0); + ((BatchProcessDocumentsRequest) actualRequests.get(0)); Assert.assertEquals(requests, actualRequest.getRequestsList()); Assert.assertTrue( @@ -112,19 +114,17 @@ public void batchProcessDocumentsTest() throws Exception { } @Test - @SuppressWarnings("all") public void batchProcessDocumentsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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(); + 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 index e9856c7d..7fc82f09 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockDocumentUnderstandingService implements MockGrpcService { private final MockDocumentUnderstandingServiceImpl serviceImpl; 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 index a41b118b..47c62133 100644 --- 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 @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -24,9 +25,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockDocumentUnderstandingServiceImpl extends DocumentUnderstandingServiceImplBase { private List requests; private Queue responses; @@ -63,10 +65,10 @@ public void batchProcessDocuments( Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/DocumentUnderstandingServiceClientTest.java b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/DocumentUnderstandingServiceClientTest.java index 3b5b31c2..72a3c617 100644 --- a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/DocumentUnderstandingServiceClientTest.java +++ b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/DocumentUnderstandingServiceClientTest.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.documentai.v1beta2; import com.google.api.gax.core.NoCredentialsProvider; @@ -26,7 +27,7 @@ import com.google.longrunning.Operation; import com.google.protobuf.AbstractMessage; import com.google.protobuf.Any; -import io.grpc.Status; +import com.google.rpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; import java.util.ArrayList; @@ -34,6 +35,7 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -41,32 +43,32 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class DocumentUnderstandingServiceClientTest { private static MockDocumentUnderstandingService mockDocumentUnderstandingService; - private static MockServiceHelper serviceHelper; + private static MockServiceHelper mockServiceHelper; private DocumentUnderstandingServiceClient client; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { mockDocumentUnderstandingService = new MockDocumentUnderstandingService(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), Arrays.asList(mockDocumentUnderstandingService)); - serviceHelper.start(); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); DocumentUnderstandingServiceSettings settings = DocumentUnderstandingServiceSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -81,10 +83,11 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") public void batchProcessDocumentsTest() throws Exception { BatchProcessDocumentsResponse expectedResponse = - BatchProcessDocumentsResponse.newBuilder().build(); + BatchProcessDocumentsResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); Operation resultOperation = Operation.newBuilder() .setName("batchProcessDocumentsTest") @@ -102,7 +105,7 @@ public void batchProcessDocumentsTest() throws Exception { List actualRequests = mockDocumentUnderstandingService.getRequests(); Assert.assertEquals(1, actualRequests.size()); BatchProcessDocumentsRequest actualRequest = - (BatchProcessDocumentsRequest) actualRequests.get(0); + ((BatchProcessDocumentsRequest) actualRequests.get(0)); Assert.assertEquals(requests, actualRequest.getRequestsList()); Assert.assertTrue( @@ -112,45 +115,67 @@ public void batchProcessDocumentsTest() throws Exception { } @Test - @SuppressWarnings("all") public void batchProcessDocumentsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") - public void processDocumentTest() { - String uri = "uri116076"; - String mimeType = "mimeType-196041627"; - String text = "text3556653"; + public void processDocumentTest() throws Exception { Document expectedResponse = - Document.newBuilder().setUri(uri).setMimeType(mimeType).setText(text).build(); + Document.newBuilder() + .setMimeType("mimeType-1392120434") + .setText("text3556653") + .addAllTextStyles(new ArrayList()) + .addAllPages(new ArrayList()) + .addAllEntities(new ArrayList()) + .addAllEntityRelations(new ArrayList()) + .addAllLabels(new ArrayList()) + .setError(Status.newBuilder().build()) + .build(); mockDocumentUnderstandingService.addResponse(expectedResponse); - InputConfig inputConfig = InputConfig.newBuilder().build(); ProcessDocumentRequest request = - ProcessDocumentRequest.newBuilder().setInputConfig(inputConfig).build(); + ProcessDocumentRequest.newBuilder() + .setParent("parent-995424086") + .setInputConfig(InputConfig.newBuilder().build()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .setDocumentType("documentType-1473196299") + .setTableExtractionParams(TableExtractionParams.newBuilder().build()) + .setFormExtractionParams(FormExtractionParams.newBuilder().build()) + .setEntityExtractionParams(EntityExtractionParams.newBuilder().build()) + .setOcrParams(OcrParams.newBuilder().build()) + .setAutomlParams(AutoMlParams.newBuilder().build()) + .build(); Document actualResponse = client.processDocument(request); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockDocumentUnderstandingService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ProcessDocumentRequest actualRequest = (ProcessDocumentRequest) actualRequests.get(0); - - Assert.assertEquals(inputConfig, actualRequest.getInputConfig()); + ProcessDocumentRequest actualRequest = ((ProcessDocumentRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getParent(), actualRequest.getParent()); + Assert.assertEquals(request.getInputConfig(), actualRequest.getInputConfig()); + Assert.assertEquals(request.getOutputConfig(), actualRequest.getOutputConfig()); + Assert.assertEquals(request.getDocumentType(), actualRequest.getDocumentType()); + Assert.assertEquals( + request.getTableExtractionParams(), actualRequest.getTableExtractionParams()); + Assert.assertEquals(request.getFormExtractionParams(), actualRequest.getFormExtractionParams()); + Assert.assertEquals( + request.getEntityExtractionParams(), actualRequest.getEntityExtractionParams()); + Assert.assertEquals(request.getOcrParams(), actualRequest.getOcrParams()); + Assert.assertEquals(request.getAutomlParams(), actualRequest.getAutomlParams()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -158,20 +183,27 @@ public void processDocumentTest() { } @Test - @SuppressWarnings("all") public void processDocumentExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockDocumentUnderstandingService.addException(exception); try { - InputConfig inputConfig = InputConfig.newBuilder().build(); ProcessDocumentRequest request = - ProcessDocumentRequest.newBuilder().setInputConfig(inputConfig).build(); - + ProcessDocumentRequest.newBuilder() + .setParent("parent-995424086") + .setInputConfig(InputConfig.newBuilder().build()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .setDocumentType("documentType-1473196299") + .setTableExtractionParams(TableExtractionParams.newBuilder().build()) + .setFormExtractionParams(FormExtractionParams.newBuilder().build()) + .setEntityExtractionParams(EntityExtractionParams.newBuilder().build()) + .setOcrParams(OcrParams.newBuilder().build()) + .setAutomlParams(AutoMlParams.newBuilder().build()) + .build(); client.processDocument(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } } diff --git a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/MockDocumentUnderstandingService.java b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/MockDocumentUnderstandingService.java index bc62c5ed..0f610d36 100644 --- a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/MockDocumentUnderstandingService.java +++ b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/MockDocumentUnderstandingService.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockDocumentUnderstandingService implements MockGrpcService { private final MockDocumentUnderstandingServiceImpl serviceImpl; diff --git a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/MockDocumentUnderstandingServiceImpl.java b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/MockDocumentUnderstandingServiceImpl.java index bce68ef0..56644a8e 100644 --- a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/MockDocumentUnderstandingServiceImpl.java +++ b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta2/MockDocumentUnderstandingServiceImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -24,9 +25,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockDocumentUnderstandingServiceImpl extends DocumentUnderstandingServiceImplBase { private List requests; private Queue responses; @@ -63,10 +65,10 @@ public void batchProcessDocuments( Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -78,10 +80,10 @@ public void processDocument( Object response = responses.remove(); if (response instanceof Document) { requests.add(request); - responseObserver.onNext((Document) response); + responseObserver.onNext(((Document) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClientTest.java b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClientTest.java index a2cbe5af..a9ea341e 100644 --- a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClientTest.java +++ b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/DocumentProcessorServiceClientTest.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.documentai.v1beta3; import com.google.api.gax.core.NoCredentialsProvider; @@ -26,13 +27,13 @@ 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.Arrays; import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -40,32 +41,32 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class DocumentProcessorServiceClientTest { - private static MockDocumentProcessorService mockDocumentProcessorService; - private static MockServiceHelper serviceHelper; + private static MockServiceHelper mockServiceHelper; private DocumentProcessorServiceClient client; + private static MockDocumentProcessorService mockDocumentProcessorService; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { mockDocumentProcessorService = new MockDocumentProcessorService(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), Arrays.asList(mockDocumentProcessorService)); - serviceHelper.start(); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); DocumentProcessorServiceSettings settings = DocumentProcessorServiceSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -80,11 +81,12 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void processDocumentTest() { - String humanReviewOperation = "humanReviewOperation2074827282"; + public void processDocumentTest() throws Exception { ProcessResponse expectedResponse = - ProcessResponse.newBuilder().setHumanReviewOperation(humanReviewOperation).build(); + ProcessResponse.newBuilder() + .setDocument(Document.newBuilder().build()) + .setHumanReviewOperation("humanReviewOperation1807415298") + .build(); mockDocumentProcessorService.addResponse(expectedResponse); ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); @@ -94,9 +96,9 @@ public void processDocumentTest() { List actualRequests = mockDocumentProcessorService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ProcessRequest actualRequest = (ProcessRequest) actualRequests.get(0); + ProcessRequest actualRequest = ((ProcessRequest) actualRequests.get(0)); - Assert.assertEquals(name, ProcessorName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -104,23 +106,59 @@ public void processDocumentTest() { } @Test - @SuppressWarnings("all") public void processDocumentExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockDocumentProcessorService.addException(exception); try { ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + client.processDocument(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void processDocumentTest2() throws Exception { + ProcessResponse expectedResponse = + ProcessResponse.newBuilder() + .setDocument(Document.newBuilder().build()) + .setHumanReviewOperation("humanReviewOperation1807415298") + .build(); + mockDocumentProcessorService.addResponse(expectedResponse); + + String name = "name3373707"; + + ProcessResponse actualResponse = client.processDocument(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDocumentProcessorService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ProcessRequest actualRequest = ((ProcessRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + @Test + public void processDocumentExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDocumentProcessorService.addException(exception); + + try { + String name = "name3373707"; client.processDocument(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") public void batchProcessDocumentsTest() throws Exception { BatchProcessResponse expectedResponse = BatchProcessResponse.newBuilder().build(); Operation resultOperation = @@ -138,9 +176,9 @@ public void batchProcessDocumentsTest() throws Exception { List actualRequests = mockDocumentProcessorService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - BatchProcessRequest actualRequest = (BatchProcessRequest) actualRequests.get(0); + BatchProcessRequest actualRequest = ((BatchProcessRequest) actualRequests.get(0)); - Assert.assertEquals(name, ProcessorName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -148,29 +186,68 @@ public void batchProcessDocumentsTest() throws Exception { } @Test - @SuppressWarnings("all") public void batchProcessDocumentsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockDocumentProcessorService.addException(exception); try { ProcessorName name = ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + client.batchProcessDocumentsAsync(name).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()); + } + } + @Test + public void batchProcessDocumentsTest2() throws Exception { + BatchProcessResponse expectedResponse = BatchProcessResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchProcessDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockDocumentProcessorService.addResponse(resultOperation); + + String name = "name3373707"; + + BatchProcessResponse actualResponse = client.batchProcessDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDocumentProcessorService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BatchProcessRequest actualRequest = ((BatchProcessRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void batchProcessDocumentsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDocumentProcessorService.addException(exception); + + try { + String name = "name3373707"; client.batchProcessDocumentsAsync(name).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") public void reviewDocumentTest() throws Exception { - String gcsDestination = "gcsDestination714819302"; ReviewDocumentResponse expectedResponse = - ReviewDocumentResponse.newBuilder().setGcsDestination(gcsDestination).build(); + ReviewDocumentResponse.newBuilder().setGcsDestination("gcsDestination-1612392329").build(); Operation resultOperation = Operation.newBuilder() .setName("reviewDocumentTest") @@ -187,10 +264,9 @@ public void reviewDocumentTest() throws Exception { List actualRequests = mockDocumentProcessorService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ReviewDocumentRequest actualRequest = (ReviewDocumentRequest) actualRequests.get(0); + ReviewDocumentRequest actualRequest = ((ReviewDocumentRequest) actualRequests.get(0)); - Assert.assertEquals( - humanReviewConfig, HumanReviewConfigName.parse(actualRequest.getHumanReviewConfig())); + Assert.assertEquals(humanReviewConfig.toString(), actualRequest.getHumanReviewConfig()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -198,20 +274,62 @@ public void reviewDocumentTest() throws Exception { } @Test - @SuppressWarnings("all") public void reviewDocumentExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockDocumentProcessorService.addException(exception); try { HumanReviewConfigName humanReviewConfig = HumanReviewConfigName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]"); + client.reviewDocumentAsync(humanReviewConfig).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()); + } + } + @Test + public void reviewDocumentTest2() throws Exception { + ReviewDocumentResponse expectedResponse = + ReviewDocumentResponse.newBuilder().setGcsDestination("gcsDestination-1612392329").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("reviewDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockDocumentProcessorService.addResponse(resultOperation); + + String humanReviewConfig = "humanReviewConfig-620962169"; + + ReviewDocumentResponse actualResponse = client.reviewDocumentAsync(humanReviewConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDocumentProcessorService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ReviewDocumentRequest actualRequest = ((ReviewDocumentRequest) actualRequests.get(0)); + + Assert.assertEquals(humanReviewConfig, actualRequest.getHumanReviewConfig()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void reviewDocumentExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDocumentProcessorService.addException(exception); + + try { + String humanReviewConfig = "humanReviewConfig-620962169"; client.reviewDocumentAsync(humanReviewConfig).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + 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/v1beta3/MockDocumentProcessorService.java b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/MockDocumentProcessorService.java index c6290b63..b11365ca 100644 --- a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/MockDocumentProcessorService.java +++ b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/MockDocumentProcessorService.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.documentai.v1beta3; import com.google.api.core.BetaApi; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockDocumentProcessorService implements MockGrpcService { private final MockDocumentProcessorServiceImpl serviceImpl; diff --git a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/MockDocumentProcessorServiceImpl.java b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/MockDocumentProcessorServiceImpl.java index 1fd3177d..3b7fcb99 100644 --- a/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/MockDocumentProcessorServiceImpl.java +++ b/google-cloud-document-ai/src/test/java/com/google/cloud/documentai/v1beta3/MockDocumentProcessorServiceImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.documentai.v1beta3; import com.google.api.core.BetaApi; @@ -24,9 +25,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockDocumentProcessorServiceImpl extends DocumentProcessorServiceImplBase { private List requests; private Queue responses; @@ -63,10 +65,10 @@ public void processDocument( Object response = responses.remove(); if (response instanceof ProcessResponse) { requests.add(request); - responseObserver.onNext((ProcessResponse) response); + responseObserver.onNext(((ProcessResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -78,10 +80,10 @@ public void batchProcessDocuments( Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -93,10 +95,10 @@ public void reviewDocument( Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/grpc-google-cloud-document-ai-v1beta1/pom.xml b/grpc-google-cloud-document-ai-v1beta1/pom.xml index 84cf8080..4df27cbd 100644 --- a/grpc-google-cloud-document-ai-v1beta1/pom.xml +++ b/grpc-google-cloud-document-ai-v1beta1/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta1 - 0.3.6 + 0.3.7 grpc-google-cloud-document-ai-v1beta1 GRPC library for grpc-google-cloud-document-ai-v1beta1 com.google.cloud google-cloud-document-ai-parent - 0.3.6 + 0.3.7 diff --git a/grpc-google-cloud-document-ai-v1beta2/pom.xml b/grpc-google-cloud-document-ai-v1beta2/pom.xml index cb4e24eb..e4a7ffe0 100644 --- a/grpc-google-cloud-document-ai-v1beta2/pom.xml +++ b/grpc-google-cloud-document-ai-v1beta2/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta2 - 0.3.6 + 0.3.7 grpc-google-cloud-document-ai-v1beta2 GRPC library for grpc-google-cloud-document-ai-v1beta2 com.google.cloud google-cloud-document-ai-parent - 0.3.6 + 0.3.7 diff --git a/grpc-google-cloud-document-ai-v1beta3/pom.xml b/grpc-google-cloud-document-ai-v1beta3/pom.xml index b4572361..48ffa638 100644 --- a/grpc-google-cloud-document-ai-v1beta3/pom.xml +++ b/grpc-google-cloud-document-ai-v1beta3/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-document-ai-v1beta3 - 0.3.6 + 0.3.7 grpc-google-cloud-document-ai-v1beta3 GRPC library for grpc-google-cloud-document-ai-v1beta3 com.google.cloud google-cloud-document-ai-parent - 0.3.6 + 0.3.7 diff --git a/pom.xml b/pom.xml index 28898bbc..e9e5d941 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-document-ai-parent pom - 0.3.6 + 0.3.7 Google Cloud Document AI Parent https://github.com/googleapis/java-document-ai @@ -70,38 +70,38 @@ com.google.api.grpc grpc-google-cloud-document-ai-v1beta1 - 0.3.6 + 0.3.7 com.google.api.grpc grpc-google-cloud-document-ai-v1beta2 - 0.3.6 + 0.3.7 com.google.api.grpc grpc-google-cloud-document-ai-v1beta3 - 0.3.6 + 0.3.7 com.google.api.grpc proto-google-cloud-document-ai-v1beta1 - 0.3.6 + 0.3.7 com.google.api.grpc proto-google-cloud-document-ai-v1beta2 - 0.3.6 + 0.3.7 com.google.api.grpc proto-google-cloud-document-ai-v1beta3 - 0.3.6 + 0.3.7 com.google.cloud google-cloud-shared-dependencies - 0.16.0 + 0.16.1 pom import diff --git a/proto-google-cloud-document-ai-v1beta1/pom.xml b/proto-google-cloud-document-ai-v1beta1/pom.xml index a0f640d0..3ddcf902 100644 --- a/proto-google-cloud-document-ai-v1beta1/pom.xml +++ b/proto-google-cloud-document-ai-v1beta1/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta1 - 0.3.6 + 0.3.7 proto-google-cloud-document-ai-v1beta1 PROTO library for proto-google-cloud-document-ai-v1beta1 com.google.cloud google-cloud-document-ai-parent - 0.3.6 + 0.3.7 diff --git a/proto-google-cloud-document-ai-v1beta2/pom.xml b/proto-google-cloud-document-ai-v1beta2/pom.xml index 9772c0e2..67142aa3 100644 --- a/proto-google-cloud-document-ai-v1beta2/pom.xml +++ b/proto-google-cloud-document-ai-v1beta2/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta2 - 0.3.6 + 0.3.7 proto-google-cloud-document-ai-v1beta2 PROTO library for proto-google-cloud-document-ai-v1beta2 com.google.cloud google-cloud-document-ai-parent - 0.3.6 + 0.3.7 diff --git a/proto-google-cloud-document-ai-v1beta3/pom.xml b/proto-google-cloud-document-ai-v1beta3/pom.xml index 41f6d873..67b3f4a6 100644 --- a/proto-google-cloud-document-ai-v1beta3/pom.xml +++ b/proto-google-cloud-document-ai-v1beta3/pom.xml @@ -3,13 +3,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-document-ai-v1beta3 - 0.3.6 + 0.3.7 proto-google-cloud-document-ai-v1beta3 PROTO library for proto-google-cloud-document-ai-v1beta3 com.google.cloud google-cloud-document-ai-parent - 0.3.6 + 0.3.7 diff --git a/proto-google-cloud-document-ai-v1beta3/src/main/java/com/google/cloud/documentai/v1beta3/HumanReviewConfigName.java b/proto-google-cloud-document-ai-v1beta3/src/main/java/com/google/cloud/documentai/v1beta3/HumanReviewConfigName.java index 3f1b301e..3aec9a33 100644 --- a/proto-google-cloud-document-ai-v1beta3/src/main/java/com/google/cloud/documentai/v1beta3/HumanReviewConfigName.java +++ b/proto-google-cloud-document-ai-v1beta3/src/main/java/com/google/cloud/documentai/v1beta3/HumanReviewConfigName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -23,21 +23,33 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class HumanReviewConfigName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_LOCATION_PROCESSOR = PathTemplate.createWithoutUrlEncoding( "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig"); - private volatile Map fieldValuesMap; - private final String project; private final String location; private final String processor; + @Deprecated + protected HumanReviewConfigName() { + project = null; + location = null; + processor = null; + } + + private HumanReviewConfigName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + processor = Preconditions.checkNotNull(builder.getProcessor()); + } + public String getProject() { return project; } @@ -58,12 +70,6 @@ public Builder toBuilder() { return new Builder(this); } - private HumanReviewConfigName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - processor = Preconditions.checkNotNull(builder.getProcessor()); - } - public static HumanReviewConfigName of(String project, String location, String processor) { return newBuilder().setProject(project).setLocation(location).setProcessor(processor).build(); } @@ -82,7 +88,7 @@ public static HumanReviewConfigName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_LOCATION_PROCESSOR.validatedMatch( formattedString, "HumanReviewConfigName.parse: formattedString not in valid format"); return of(matchMap.get("project"), matchMap.get("location"), matchMap.get("processor")); } @@ -96,7 +102,7 @@ public static List parseList(List formattedString } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (HumanReviewConfigName value : values) { if (value == null) { list.add(""); @@ -108,17 +114,24 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_LOCATION_PROCESSOR.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("location", location); - fieldMapBuilder.put("processor", processor); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + if (processor != null) { + fieldMapBuilder.put("processor", processor); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -132,17 +145,46 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate( + return PROJECT_LOCATION_PROCESSOR.instantiate( "project", project, "location", location, "processor", processor); } - /** Builder for HumanReviewConfigName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + HumanReviewConfigName that = ((HumanReviewConfigName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location) + && Objects.equals(this.processor, that.processor); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + h *= 1000003; + h ^= Objects.hashCode(processor); + return h; + } + + /** + * Builder for projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig. + */ + public static class Builder { private String project; private String location; private String processor; + protected Builder() {} + public String getProject() { return project; } @@ -170,8 +212,6 @@ public Builder setProcessor(String processor) { return this; } - private Builder() {} - private Builder(HumanReviewConfigName humanReviewConfigName) { project = humanReviewConfigName.project; location = humanReviewConfigName.location; @@ -182,30 +222,4 @@ public HumanReviewConfigName build() { return new HumanReviewConfigName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HumanReviewConfigName) { - HumanReviewConfigName that = (HumanReviewConfigName) o; - return (this.project.equals(that.project)) - && (this.location.equals(that.location)) - && (this.processor.equals(that.processor)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= location.hashCode(); - h *= 1000003; - h ^= processor.hashCode(); - return h; - } } diff --git a/proto-google-cloud-document-ai-v1beta3/src/main/java/com/google/cloud/documentai/v1beta3/ProcessorName.java b/proto-google-cloud-document-ai-v1beta3/src/main/java/com/google/cloud/documentai/v1beta3/ProcessorName.java index cfa99f4e..80e15109 100644 --- a/proto-google-cloud-document-ai-v1beta3/src/main/java/com/google/cloud/documentai/v1beta3/ProcessorName.java +++ b/proto-google-cloud-document-ai-v1beta3/src/main/java/com/google/cloud/documentai/v1beta3/ProcessorName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -23,21 +23,33 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class ProcessorName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_LOCATION_PROCESSOR = PathTemplate.createWithoutUrlEncoding( "projects/{project}/locations/{location}/processors/{processor}"); - private volatile Map fieldValuesMap; - private final String project; private final String location; private final String processor; + @Deprecated + protected ProcessorName() { + project = null; + location = null; + processor = null; + } + + private ProcessorName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + processor = Preconditions.checkNotNull(builder.getProcessor()); + } + public String getProject() { return project; } @@ -58,12 +70,6 @@ public Builder toBuilder() { return new Builder(this); } - private ProcessorName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - processor = Preconditions.checkNotNull(builder.getProcessor()); - } - public static ProcessorName of(String project, String location, String processor) { return newBuilder().setProject(project).setLocation(location).setProcessor(processor).build(); } @@ -82,7 +88,7 @@ public static ProcessorName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_LOCATION_PROCESSOR.validatedMatch( formattedString, "ProcessorName.parse: formattedString not in valid format"); return of(matchMap.get("project"), matchMap.get("location"), matchMap.get("processor")); } @@ -96,7 +102,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (ProcessorName value : values) { if (value == null) { list.add(""); @@ -108,17 +114,24 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_LOCATION_PROCESSOR.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("location", location); - fieldMapBuilder.put("processor", processor); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + if (processor != null) { + fieldMapBuilder.put("processor", processor); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -132,17 +145,44 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate( + return PROJECT_LOCATION_PROCESSOR.instantiate( "project", project, "location", location, "processor", processor); } - /** Builder for ProcessorName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + ProcessorName that = ((ProcessorName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location) + && Objects.equals(this.processor, that.processor); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + h *= 1000003; + h ^= Objects.hashCode(processor); + return h; + } + + /** Builder for projects/{project}/locations/{location}/processors/{processor}. */ + public static class Builder { private String project; private String location; private String processor; + protected Builder() {} + public String getProject() { return project; } @@ -170,8 +210,6 @@ public Builder setProcessor(String processor) { return this; } - private Builder() {} - private Builder(ProcessorName processorName) { project = processorName.project; location = processorName.location; @@ -182,30 +220,4 @@ public ProcessorName build() { return new ProcessorName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ProcessorName) { - ProcessorName that = (ProcessorName) o; - return (this.project.equals(that.project)) - && (this.location.equals(that.location)) - && (this.processor.equals(that.processor)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= location.hashCode(); - h *= 1000003; - h ^= processor.hashCode(); - return h; - } } diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index d7fbba19..90a077a2 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,13 +29,13 @@ com.google.cloud google-cloud-document-ai - 0.3.5 + 0.3.6 com.google.cloud google-cloud-storage - 1.113.3 + 1.113.5 junit diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index d65178ec..7f9e8a1f 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,13 +28,13 @@ com.google.cloud google-cloud-document-ai - 0.3.5 + 0.3.6 com.google.cloud google-cloud-storage - 1.113.3 + 1.113.5 junit diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index c81ca2e3..f7f7a542 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -41,7 +41,7 @@ com.google.cloud google-cloud-document-ai - 0.3.5 + 0.3.6 diff --git a/synth.metadata b/synth.metadata index 6a49f35f..c1b03ace 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,31 +4,31 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-document-ai.git", - "sha": "590fe47a98d7cdd12e4819a0942ab807b94332df" + "sha": "fb2e9af60eef934ae7aaf16087ae27000c88d32b" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "709aaa0bf92147ff67de52e1b7371bc596603842", - "internalRef": "340710837" + "sha": "857f70daef9f4c38f042fb3dfb7b8423ae18fd19", + "internalRef": "346372957" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "709aaa0bf92147ff67de52e1b7371bc596603842", - "internalRef": "340710837" + "sha": "857f70daef9f4c38f042fb3dfb7b8423ae18fd19", + "internalRef": "346372957" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "709aaa0bf92147ff67de52e1b7371bc596603842", - "internalRef": "340710837" + "sha": "857f70daef9f4c38f042fb3dfb7b8423ae18fd19", + "internalRef": "346372957" } }, { diff --git a/versions.txt b/versions.txt index 59f6be21..689524cb 100644 --- a/versions.txt +++ b/versions.txt @@ -1,7 +1,7 @@ -proto-google-cloud-document-ai-v1beta1:0.3.6:0.3.6 -proto-google-cloud-document-ai-v1beta2:0.3.6:0.3.6 -proto-google-cloud-document-ai-v1beta3:0.3.6:0.3.6 -grpc-google-cloud-document-ai-v1beta1:0.3.6:0.3.6 -grpc-google-cloud-document-ai-v1beta2:0.3.6:0.3.6 -grpc-google-cloud-document-ai-v1beta3:0.3.6:0.3.6 -google-cloud-document-ai:0.3.6:0.3.6 +proto-google-cloud-document-ai-v1beta1:0.3.7:0.3.7 +proto-google-cloud-document-ai-v1beta2:0.3.7:0.3.7 +proto-google-cloud-document-ai-v1beta3:0.3.7:0.3.7 +grpc-google-cloud-document-ai-v1beta1:0.3.7:0.3.7 +grpc-google-cloud-document-ai-v1beta2:0.3.7:0.3.7 +grpc-google-cloud-document-ai-v1beta3:0.3.7:0.3.7 +google-cloud-document-ai:0.3.7:0.3.7