Skip to content

Commit 0205042

Browse files
feat!: [documentai] removed id field from Document message (#9642)
* 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: https://github.com/googleapis/googleapis-gen/commit/29f701c9f344e196fbb81a81e65f90ddba5a06f3 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>
1 parent 9caae4d commit 0205042

File tree

140 files changed

+88196
-24067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+88196
-24067
lines changed

java-document-ai/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
2020
<dependency>
2121
<groupId>com.google.cloud</groupId>
2222
<artifactId>libraries-bom</artifactId>
23-
<version>26.17.0</version>
23+
<version>26.19.0</version>
2424
<type>pom</type>
2525
<scope>import</scope>
2626
</dependency>
@@ -195,7 +195,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
195195
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.html
196196
[stability-image]: https://img.shields.io/badge/stability-stable-green
197197
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-document-ai.svg
198-
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-document-ai/2.23.0
198+
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-document-ai/2.25.0
199199
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
200200
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
201201
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles

java-document-ai/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1/DocumentProcessorServiceClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ public final ProcessResponse processDocument(String name) {
306306
* .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
307307
* .setSkipHumanReview(true)
308308
* .setFieldMask(FieldMask.newBuilder().build())
309+
* .setProcessOptions(ProcessOptions.newBuilder().build())
309310
* .build();
310311
* ProcessResponse response = documentProcessorServiceClient.processDocument(request);
311312
* }
@@ -337,6 +338,7 @@ public final ProcessResponse processDocument(ProcessRequest request) {
337338
* .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
338339
* .setSkipHumanReview(true)
339340
* .setFieldMask(FieldMask.newBuilder().build())
341+
* .setProcessOptions(ProcessOptions.newBuilder().build())
340342
* .build();
341343
* ApiFuture<ProcessResponse> future =
342344
* documentProcessorServiceClient.processDocumentCallable().futureCall(request);
@@ -440,6 +442,7 @@ public final UnaryCallable<ProcessRequest, ProcessResponse> processDocumentCalla
440442
* .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build())
441443
* .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
442444
* .setSkipHumanReview(true)
445+
* .setProcessOptions(ProcessOptions.newBuilder().build())
443446
* .build();
444447
* BatchProcessResponse response =
445448
* documentProcessorServiceClient.batchProcessDocumentsAsync(request).get();
@@ -475,6 +478,7 @@ public final UnaryCallable<ProcessRequest, ProcessResponse> processDocumentCalla
475478
* .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build())
476479
* .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
477480
* .setSkipHumanReview(true)
481+
* .setProcessOptions(ProcessOptions.newBuilder().build())
478482
* .build();
479483
* OperationFuture<BatchProcessResponse, BatchProcessMetadata> future =
480484
* documentProcessorServiceClient
@@ -511,6 +515,7 @@ public final UnaryCallable<ProcessRequest, ProcessResponse> processDocumentCalla
511515
* .setInputDocuments(BatchDocumentsInputConfig.newBuilder().build())
512516
* .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
513517
* .setSkipHumanReview(true)
518+
* .setProcessOptions(ProcessOptions.newBuilder().build())
514519
* .build();
515520
* ApiFuture<Operation> future =
516521
* documentProcessorServiceClient.batchProcessDocumentsCallable().futureCall(request);

java-document-ai/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/DocumentUnderstandingServiceClient.java

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,24 @@
1616

1717
package com.google.cloud.documentai.v1beta2;
1818

19+
import com.google.api.core.ApiFuture;
20+
import com.google.api.core.ApiFutures;
1921
import com.google.api.core.BetaApi;
2022
import com.google.api.gax.core.BackgroundResource;
2123
import com.google.api.gax.longrunning.OperationFuture;
24+
import com.google.api.gax.paging.AbstractFixedSizeCollection;
25+
import com.google.api.gax.paging.AbstractPage;
26+
import com.google.api.gax.paging.AbstractPagedListResponse;
2227
import com.google.api.gax.rpc.OperationCallable;
28+
import com.google.api.gax.rpc.PageContext;
2329
import com.google.api.gax.rpc.UnaryCallable;
2430
import com.google.cloud.documentai.v1beta2.stub.DocumentUnderstandingServiceStub;
2531
import com.google.cloud.documentai.v1beta2.stub.DocumentUnderstandingServiceStubSettings;
32+
import com.google.cloud.location.GetLocationRequest;
33+
import com.google.cloud.location.ListLocationsRequest;
34+
import com.google.cloud.location.ListLocationsResponse;
35+
import com.google.cloud.location.Location;
36+
import com.google.common.util.concurrent.MoreExecutors;
2637
import com.google.longrunning.Operation;
2738
import com.google.longrunning.OperationsClient;
2839
import java.io.IOException;
@@ -393,6 +404,169 @@ public final UnaryCallable<ProcessDocumentRequest, Document> processDocumentCall
393404
return stub.processDocumentCallable();
394405
}
395406

407+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
408+
/**
409+
* Lists information about the supported locations for this service.
410+
*
411+
* <p>Sample code:
412+
*
413+
* <pre>{@code
414+
* // This snippet has been automatically generated and should be regarded as a code template only.
415+
* // It will require modifications to work:
416+
* // - It may require correct/in-range values for request initialization.
417+
* // - It may require specifying regional endpoints when creating the service client as shown in
418+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
419+
* try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
420+
* DocumentUnderstandingServiceClient.create()) {
421+
* ListLocationsRequest request =
422+
* ListLocationsRequest.newBuilder()
423+
* .setName("name3373707")
424+
* .setFilter("filter-1274492040")
425+
* .setPageSize(883849137)
426+
* .setPageToken("pageToken873572522")
427+
* .build();
428+
* for (Location element :
429+
* documentUnderstandingServiceClient.listLocations(request).iterateAll()) {
430+
* // doThingsWith(element);
431+
* }
432+
* }
433+
* }</pre>
434+
*
435+
* @param request The request object containing all of the parameters for the API call.
436+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
437+
*/
438+
public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
439+
return listLocationsPagedCallable().call(request);
440+
}
441+
442+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
443+
/**
444+
* Lists information about the supported locations for this service.
445+
*
446+
* <p>Sample code:
447+
*
448+
* <pre>{@code
449+
* // This snippet has been automatically generated and should be regarded as a code template only.
450+
* // It will require modifications to work:
451+
* // - It may require correct/in-range values for request initialization.
452+
* // - It may require specifying regional endpoints when creating the service client as shown in
453+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
454+
* try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
455+
* DocumentUnderstandingServiceClient.create()) {
456+
* ListLocationsRequest request =
457+
* ListLocationsRequest.newBuilder()
458+
* .setName("name3373707")
459+
* .setFilter("filter-1274492040")
460+
* .setPageSize(883849137)
461+
* .setPageToken("pageToken873572522")
462+
* .build();
463+
* ApiFuture<Location> future =
464+
* documentUnderstandingServiceClient.listLocationsPagedCallable().futureCall(request);
465+
* // Do something.
466+
* for (Location element : future.get().iterateAll()) {
467+
* // doThingsWith(element);
468+
* }
469+
* }
470+
* }</pre>
471+
*/
472+
public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
473+
listLocationsPagedCallable() {
474+
return stub.listLocationsPagedCallable();
475+
}
476+
477+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
478+
/**
479+
* Lists information about the supported locations for this service.
480+
*
481+
* <p>Sample code:
482+
*
483+
* <pre>{@code
484+
* // This snippet has been automatically generated and should be regarded as a code template only.
485+
* // It will require modifications to work:
486+
* // - It may require correct/in-range values for request initialization.
487+
* // - It may require specifying regional endpoints when creating the service client as shown in
488+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
489+
* try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
490+
* DocumentUnderstandingServiceClient.create()) {
491+
* ListLocationsRequest request =
492+
* ListLocationsRequest.newBuilder()
493+
* .setName("name3373707")
494+
* .setFilter("filter-1274492040")
495+
* .setPageSize(883849137)
496+
* .setPageToken("pageToken873572522")
497+
* .build();
498+
* while (true) {
499+
* ListLocationsResponse response =
500+
* documentUnderstandingServiceClient.listLocationsCallable().call(request);
501+
* for (Location element : response.getLocationsList()) {
502+
* // doThingsWith(element);
503+
* }
504+
* String nextPageToken = response.getNextPageToken();
505+
* if (!Strings.isNullOrEmpty(nextPageToken)) {
506+
* request = request.toBuilder().setPageToken(nextPageToken).build();
507+
* } else {
508+
* break;
509+
* }
510+
* }
511+
* }
512+
* }</pre>
513+
*/
514+
public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
515+
return stub.listLocationsCallable();
516+
}
517+
518+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
519+
/**
520+
* Gets information about a location.
521+
*
522+
* <p>Sample code:
523+
*
524+
* <pre>{@code
525+
* // This snippet has been automatically generated and should be regarded as a code template only.
526+
* // It will require modifications to work:
527+
* // - It may require correct/in-range values for request initialization.
528+
* // - It may require specifying regional endpoints when creating the service client as shown in
529+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
530+
* try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
531+
* DocumentUnderstandingServiceClient.create()) {
532+
* GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
533+
* Location response = documentUnderstandingServiceClient.getLocation(request);
534+
* }
535+
* }</pre>
536+
*
537+
* @param request The request object containing all of the parameters for the API call.
538+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
539+
*/
540+
public final Location getLocation(GetLocationRequest request) {
541+
return getLocationCallable().call(request);
542+
}
543+
544+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
545+
/**
546+
* Gets information about a location.
547+
*
548+
* <p>Sample code:
549+
*
550+
* <pre>{@code
551+
* // This snippet has been automatically generated and should be regarded as a code template only.
552+
* // It will require modifications to work:
553+
* // - It may require correct/in-range values for request initialization.
554+
* // - It may require specifying regional endpoints when creating the service client as shown in
555+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
556+
* try (DocumentUnderstandingServiceClient documentUnderstandingServiceClient =
557+
* DocumentUnderstandingServiceClient.create()) {
558+
* GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
559+
* ApiFuture<Location> future =
560+
* documentUnderstandingServiceClient.getLocationCallable().futureCall(request);
561+
* // Do something.
562+
* Location response = future.get();
563+
* }
564+
* }</pre>
565+
*/
566+
public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() {
567+
return stub.getLocationCallable();
568+
}
569+
396570
@Override
397571
public final void close() {
398572
stub.close();
@@ -422,4 +596,80 @@ public void shutdownNow() {
422596
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
423597
return stub.awaitTermination(duration, unit);
424598
}
599+
600+
public static class ListLocationsPagedResponse
601+
extends AbstractPagedListResponse<
602+
ListLocationsRequest,
603+
ListLocationsResponse,
604+
Location,
605+
ListLocationsPage,
606+
ListLocationsFixedSizeCollection> {
607+
608+
public static ApiFuture<ListLocationsPagedResponse> createAsync(
609+
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
610+
ApiFuture<ListLocationsResponse> futureResponse) {
611+
ApiFuture<ListLocationsPage> futurePage =
612+
ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
613+
return ApiFutures.transform(
614+
futurePage,
615+
input -> new ListLocationsPagedResponse(input),
616+
MoreExecutors.directExecutor());
617+
}
618+
619+
private ListLocationsPagedResponse(ListLocationsPage page) {
620+
super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
621+
}
622+
}
623+
624+
public static class ListLocationsPage
625+
extends AbstractPage<
626+
ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
627+
628+
private ListLocationsPage(
629+
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
630+
ListLocationsResponse response) {
631+
super(context, response);
632+
}
633+
634+
private static ListLocationsPage createEmptyPage() {
635+
return new ListLocationsPage(null, null);
636+
}
637+
638+
@Override
639+
protected ListLocationsPage createPage(
640+
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
641+
ListLocationsResponse response) {
642+
return new ListLocationsPage(context, response);
643+
}
644+
645+
@Override
646+
public ApiFuture<ListLocationsPage> createPageAsync(
647+
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
648+
ApiFuture<ListLocationsResponse> futureResponse) {
649+
return super.createPageAsync(context, futureResponse);
650+
}
651+
}
652+
653+
public static class ListLocationsFixedSizeCollection
654+
extends AbstractFixedSizeCollection<
655+
ListLocationsRequest,
656+
ListLocationsResponse,
657+
Location,
658+
ListLocationsPage,
659+
ListLocationsFixedSizeCollection> {
660+
661+
private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
662+
super(pages, collectionSize);
663+
}
664+
665+
private static ListLocationsFixedSizeCollection createEmptyCollection() {
666+
return new ListLocationsFixedSizeCollection(null, 0);
667+
}
668+
669+
@Override
670+
protected ListLocationsFixedSizeCollection createCollection(
671+
List<ListLocationsPage> pages, int collectionSize) {
672+
return new ListLocationsFixedSizeCollection(pages, collectionSize);
673+
}
674+
}
425675
}

java-document-ai/google-cloud-document-ai/src/main/java/com/google/cloud/documentai/v1beta2/DocumentUnderstandingServiceSettings.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.cloud.documentai.v1beta2;
1818

19+
import static com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient.ListLocationsPagedResponse;
20+
1921
import com.google.api.core.ApiFunction;
2022
import com.google.api.core.BetaApi;
2123
import com.google.api.gax.core.GoogleCredentialsProvider;
@@ -25,9 +27,14 @@
2527
import com.google.api.gax.rpc.ClientContext;
2628
import com.google.api.gax.rpc.ClientSettings;
2729
import com.google.api.gax.rpc.OperationCallSettings;
30+
import com.google.api.gax.rpc.PagedCallSettings;
2831
import com.google.api.gax.rpc.TransportChannelProvider;
2932
import com.google.api.gax.rpc.UnaryCallSettings;
3033
import com.google.cloud.documentai.v1beta2.stub.DocumentUnderstandingServiceStubSettings;
34+
import com.google.cloud.location.GetLocationRequest;
35+
import com.google.cloud.location.ListLocationsRequest;
36+
import com.google.cloud.location.ListLocationsResponse;
37+
import com.google.cloud.location.Location;
3138
import com.google.longrunning.Operation;
3239
import java.io.IOException;
3340
import java.util.List;
@@ -96,6 +103,17 @@ public UnaryCallSettings<ProcessDocumentRequest, Document> processDocumentSettin
96103
return ((DocumentUnderstandingServiceStubSettings) getStubSettings()).processDocumentSettings();
97104
}
98105

106+
/** Returns the object with the settings used for calls to listLocations. */
107+
public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
108+
listLocationsSettings() {
109+
return ((DocumentUnderstandingServiceStubSettings) getStubSettings()).listLocationsSettings();
110+
}
111+
112+
/** Returns the object with the settings used for calls to getLocation. */
113+
public UnaryCallSettings<GetLocationRequest, Location> getLocationSettings() {
114+
return ((DocumentUnderstandingServiceStubSettings) getStubSettings()).getLocationSettings();
115+
}
116+
99117
public static final DocumentUnderstandingServiceSettings create(
100118
DocumentUnderstandingServiceStubSettings stub) throws IOException {
101119
return new DocumentUnderstandingServiceSettings.Builder(stub.toBuilder()).build();
@@ -212,6 +230,18 @@ public UnaryCallSettings.Builder<ProcessDocumentRequest, Document> processDocume
212230
return getStubSettingsBuilder().processDocumentSettings();
213231
}
214232

233+
/** Returns the builder for the settings used for calls to listLocations. */
234+
public PagedCallSettings.Builder<
235+
ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
236+
listLocationsSettings() {
237+
return getStubSettingsBuilder().listLocationsSettings();
238+
}
239+
240+
/** Returns the builder for the settings used for calls to getLocation. */
241+
public UnaryCallSettings.Builder<GetLocationRequest, Location> getLocationSettings() {
242+
return getStubSettingsBuilder().getLocationSettings();
243+
}
244+
215245
@Override
216246
public DocumentUnderstandingServiceSettings build() throws IOException {
217247
return new DocumentUnderstandingServiceSettings(this);

0 commit comments

Comments
 (0)