Skip to content

Commit

Permalink
feat!: [documentai] removed id field from Document message (#9642)
Browse files Browse the repository at this point in the history
* feat!: removed id field from Document message
feat: added http configuration and document publishing for v1beta2
feat: added ImportDocuments, GetDocument and BatchDeleteDocuments RPCs for v1beta3

PiperOrigin-RevId: 548236986

Source-Link: googleapis/googleapis@237b3c1

Source-Link: googleapis/googleapis-gen@29f701c
Copy-Tag: eyJwIjoiamF2YS1kb2N1bWVudC1haS8uT3dsQm90LnlhbWwiLCJoIjoiMjlmNzAxYzlmMzQ0ZTE5NmZiYjgxYTgxZTY1ZjkwZGRiYTVhMDZmMyJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Jul 20, 2023
1 parent 9caae4d commit 0205042
Show file tree
Hide file tree
Showing 140 changed files with 88,196 additions and 24,067 deletions.
4 changes: 2 additions & 2 deletions java-document-ai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.17.0</version>
<version>26.19.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -195,7 +195,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-document-ai.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-document-ai/2.23.0
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-document-ai/2.25.0
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public final ProcessResponse processDocument(String name) {
* .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
* .setSkipHumanReview(true)
* .setFieldMask(FieldMask.newBuilder().build())
* .setProcessOptions(ProcessOptions.newBuilder().build())
* .build();
* ProcessResponse response = documentProcessorServiceClient.processDocument(request);
* }
Expand Down Expand Up @@ -337,6 +338,7 @@ public final ProcessResponse processDocument(ProcessRequest request) {
* .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
* .setSkipHumanReview(true)
* .setFieldMask(FieldMask.newBuilder().build())
* .setProcessOptions(ProcessOptions.newBuilder().build())
* .build();
* ApiFuture<ProcessResponse> future =
* documentProcessorServiceClient.processDocumentCallable().futureCall(request);
Expand Down Expand Up @@ -440,6 +442,7 @@ public final UnaryCallable<ProcessRequest, ProcessResponse> processDocumentCalla
* .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build())
* .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
* .setSkipHumanReview(true)
* .setProcessOptions(ProcessOptions.newBuilder().build())
* .build();
* BatchProcessResponse response =
* documentProcessorServiceClient.batchProcessDocumentsAsync(request).get();
Expand Down Expand Up @@ -475,6 +478,7 @@ public final UnaryCallable<ProcessRequest, ProcessResponse> processDocumentCalla
* .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build())
* .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
* .setSkipHumanReview(true)
* .setProcessOptions(ProcessOptions.newBuilder().build())
* .build();
* OperationFuture<BatchProcessResponse, BatchProcessMetadata> future =
* documentProcessorServiceClient
Expand Down Expand Up @@ -511,6 +515,7 @@ public final UnaryCallable<ProcessRequest, ProcessResponse> processDocumentCalla
* .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build())
* .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
* .setSkipHumanReview(true)
* .setProcessOptions(ProcessOptions.newBuilder().build())
* .build();
* ApiFuture<Operation> future =
* documentProcessorServiceClient.batchProcessDocumentsCallable().futureCall(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@

package com.google.cloud.documentai.v1beta2;

import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.documentai.v1beta2.stub.DocumentUnderstandingServiceStub;
import com.google.cloud.documentai.v1beta2.stub.DocumentUnderstandingServiceStubSettings;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.longrunning.Operation;
import com.google.longrunning.OperationsClient;
import java.io.IOException;
Expand Down Expand Up @@ -393,6 +404,169 @@ public final UnaryCallable<ProcessDocumentRequest, Document> processDocumentCall
return stub.processDocumentCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
* DocumentUnderstandingServiceClient.create()) {
* ListLocationsRequest request =
* ListLocationsRequest.newBuilder()
* .setName("name3373707")
* .setFilter("filter-1274492040")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* for (Location element :
* documentUnderstandingServiceClient.listLocations(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
return listLocationsPagedCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
* DocumentUnderstandingServiceClient.create()) {
* ListLocationsRequest request =
* ListLocationsRequest.newBuilder()
* .setName("name3373707")
* .setFilter("filter-1274492040")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* ApiFuture<Location> future =
* documentUnderstandingServiceClient.listLocationsPagedCallable().futureCall(request);
* // Do something.
* for (Location element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*/
public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable() {
return stub.listLocationsPagedCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
* DocumentUnderstandingServiceClient.create()) {
* ListLocationsRequest request =
* ListLocationsRequest.newBuilder()
* .setName("name3373707")
* .setFilter("filter-1274492040")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* while (true) {
* ListLocationsResponse response =
* documentUnderstandingServiceClient.listLocationsCallable().call(request);
* for (Location element : response.getLocationsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }</pre>
*/
public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
return stub.listLocationsCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets information about a location.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
* DocumentUnderstandingServiceClient.create()) {
* GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
* Location response = documentUnderstandingServiceClient.getLocation(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Location getLocation(GetLocationRequest request) {
return getLocationCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets information about a location.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
* DocumentUnderstandingServiceClient.create()) {
* GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
* ApiFuture<Location> future =
* documentUnderstandingServiceClient.getLocationCallable().futureCall(request);
* // Do something.
* Location response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() {
return stub.getLocationCallable();
}

@Override
public final void close() {
stub.close();
Expand Down Expand Up @@ -422,4 +596,80 @@ public void shutdownNow() {
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}

public static class ListLocationsPagedResponse
extends AbstractPagedListResponse<
ListLocationsRequest,
ListLocationsResponse,
Location,
ListLocationsPage,
ListLocationsFixedSizeCollection> {

public static ApiFuture<ListLocationsPagedResponse> createAsync(
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
ApiFuture<ListLocationsResponse> futureResponse) {
ApiFuture<ListLocationsPage> futurePage =
ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListLocationsPagedResponse(input),
MoreExecutors.directExecutor());
}

private ListLocationsPagedResponse(ListLocationsPage page) {
super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
}
}

public static class ListLocationsPage
extends AbstractPage<
ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {

private ListLocationsPage(
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
ListLocationsResponse response) {
super(context, response);
}

private static ListLocationsPage createEmptyPage() {
return new ListLocationsPage(null, null);
}

@Override
protected ListLocationsPage createPage(
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
ListLocationsResponse response) {
return new ListLocationsPage(context, response);
}

@Override
public ApiFuture<ListLocationsPage> createPageAsync(
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
ApiFuture<ListLocationsResponse> futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}

public static class ListLocationsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListLocationsRequest,
ListLocationsResponse,
Location,
ListLocationsPage,
ListLocationsFixedSizeCollection> {

private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
super(pages, collectionSize);
}

private static ListLocationsFixedSizeCollection createEmptyCollection() {
return new ListLocationsFixedSizeCollection(null, 0);
}

@Override
protected ListLocationsFixedSizeCollection createCollection(
List<ListLocationsPage> pages, int collectionSize) {
return new ListLocationsFixedSizeCollection(pages, collectionSize);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.google.cloud.documentai.v1beta2;

import static com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient.ListLocationsPagedResponse;

import com.google.api.core.ApiFunction;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.GoogleCredentialsProvider;
Expand All @@ -25,9 +27,14 @@
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.OperationCallSettings;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.cloud.documentai.v1beta2.stub.DocumentUnderstandingServiceStubSettings;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
import com.google.longrunning.Operation;
import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -96,6 +103,17 @@ public UnaryCallSettings<ProcessDocumentRequest, Document> processDocumentSettin
return ((DocumentUnderstandingServiceStubSettings) getStubSettings()).processDocumentSettings();
}

/** Returns the object with the settings used for calls to listLocations. */
public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
listLocationsSettings() {
return ((DocumentUnderstandingServiceStubSettings) getStubSettings()).listLocationsSettings();
}

/** Returns the object with the settings used for calls to getLocation. */
public UnaryCallSettings<GetLocationRequest, Location> getLocationSettings() {
return ((DocumentUnderstandingServiceStubSettings) getStubSettings()).getLocationSettings();
}

public static final DocumentUnderstandingServiceSettings create(
DocumentUnderstandingServiceStubSettings stub) throws IOException {
return new DocumentUnderstandingServiceSettings.Builder(stub.toBuilder()).build();
Expand Down Expand Up @@ -212,6 +230,18 @@ public UnaryCallSettings.Builder<ProcessDocumentRequest, Document> processDocume
return getStubSettingsBuilder().processDocumentSettings();
}

/** Returns the builder for the settings used for calls to listLocations. */
public PagedCallSettings.Builder<
ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
listLocationsSettings() {
return getStubSettingsBuilder().listLocationsSettings();
}

/** Returns the builder for the settings used for calls to getLocation. */
public UnaryCallSettings.Builder<GetLocationRequest, Location> getLocationSettings() {
return getStubSettingsBuilder().getLocationSettings();
}

@Override
public DocumentUnderstandingServiceSettings build() throws IOException {
return new DocumentUnderstandingServiceSettings(this);
Expand Down
Loading

0 comments on commit 0205042

Please sign in to comment.