diff --git a/google-cloud-vision/pom.xml b/google-cloud-vision/pom.xml index 60dc1a2ea..a93803617 100644 --- a/google-cloud-vision/pom.xml +++ b/google-cloud-vision/pom.xml @@ -74,6 +74,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -128,12 +132,24 @@ + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorClient.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorClient.java index f87d11fae..d3cf2a5f5 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorClient.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorClient.java @@ -18,13 +18,13 @@ import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.vision.v1.stub.ImageAnnotatorStub; import com.google.cloud.vision.v1.stub.ImageAnnotatorStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -96,13 +96,28 @@ * ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ImageAnnotatorSettings imageAnnotatorSettings =
+ *     ImageAnnotatorSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ImageAnnotatorClient implements BackgroundResource { private final ImageAnnotatorSettings settings; private final ImageAnnotatorStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ImageAnnotatorClient with default settings. */ public static final ImageAnnotatorClient create() throws IOException { @@ -122,7 +137,6 @@ public static final ImageAnnotatorClient create(ImageAnnotatorSettings settings) * Constructs an instance of ImageAnnotatorClient, using the given stub for making calls. This is * for advanced usage - prefer using create(ImageAnnotatorSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ImageAnnotatorClient create(ImageAnnotatorStub stub) { return new ImageAnnotatorClient(stub); } @@ -135,21 +149,23 @@ public static final ImageAnnotatorClient create(ImageAnnotatorStub stub) { protected ImageAnnotatorClient(ImageAnnotatorSettings settings) throws IOException { this.settings = settings; this.stub = ((ImageAnnotatorStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ImageAnnotatorClient(ImageAnnotatorStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ImageAnnotatorSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ImageAnnotatorStub getStub() { return stub; } @@ -158,10 +174,19 @@ public ImageAnnotatorStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Run image detection and annotation for a batch of images. diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorSettings.java index 145c8b864..e70991ac9 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -135,11 +136,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ImageAnnotatorStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ImageAnnotatorStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ImageAnnotatorStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ImageAnnotatorStubSettings.defaultTransportChannelProvider(); } @@ -149,11 +157,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ImageAnnotatorStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -191,6 +205,11 @@ private static Builder createDefault() { return new Builder(ImageAnnotatorStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ImageAnnotatorStubSettings.newHttpJsonBuilder()); + } + public ImageAnnotatorStubSettings.Builder getStubSettingsBuilder() { return ((ImageAnnotatorStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ProductSearchClient.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ProductSearchClient.java index 5d709a259..2eb7f81a8 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ProductSearchClient.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ProductSearchClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -27,12 +28,10 @@ import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; -import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.vision.v1.stub.ProductSearchStub; import com.google.cloud.vision.v1.stub.ProductSearchStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -120,208 +119,28 @@ * ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ProductSearchSettings productSearchSettings =
+ *     ProductSearchSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ProductSearchSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ProductSearchClient implements BackgroundResource { private final ProductSearchSettings settings; private final ProductSearchStub stub; - private final OperationsClient operationsClient; - - private static final PathTemplate LOCATION_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); - - private static final PathTemplate PRODUCT_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/locations/{location}/products/{product}"); - - private static final PathTemplate PRODUCT_SET_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/locations/{location}/productSets/{product_set}"); - - private static final PathTemplate REFERENCE_IMAGE_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}"); - - /** - * Formats a string containing the fully-qualified path to represent a location resource. - * - * @deprecated Use the {@link LocationName} class instead. - */ - @Deprecated - public static final String formatLocationName(String project, String location) { - return LOCATION_PATH_TEMPLATE.instantiate( - "project", project, - "location", location); - } - - /** - * Formats a string containing the fully-qualified path to represent a product resource. - * - * @deprecated Use the {@link ProductName} class instead. - */ - @Deprecated - public static final String formatProductName(String project, String location, String product) { - return PRODUCT_PATH_TEMPLATE.instantiate( - "project", project, - "location", location, - "product", product); - } - - /** - * Formats a string containing the fully-qualified path to represent a product_set resource. - * - * @deprecated Use the {@link ProductSetName} class instead. - */ - @Deprecated - public static final String formatProductSetName( - String project, String location, String productSet) { - return PRODUCT_SET_PATH_TEMPLATE.instantiate( - "project", project, - "location", location, - "product_set", productSet); - } - - /** - * Formats a string containing the fully-qualified path to represent a reference_image resource. - * - * @deprecated Use the {@link ReferenceImageName} class instead. - */ - @Deprecated - public static final String formatReferenceImageName( - String project, String location, String product, String referenceImage) { - return REFERENCE_IMAGE_PATH_TEMPLATE.instantiate( - "project", project, - "location", location, - "product", product, - "reference_image", referenceImage); - } - - /** - * Parses the project from the given fully-qualified path which represents a location resource. - * - * @deprecated Use the {@link LocationName} class instead. - */ - @Deprecated - public static final String parseProjectFromLocationName(String locationName) { - return LOCATION_PATH_TEMPLATE.parse(locationName).get("project"); - } - - /** - * Parses the location from the given fully-qualified path which represents a location resource. - * - * @deprecated Use the {@link LocationName} class instead. - */ - @Deprecated - public static final String parseLocationFromLocationName(String locationName) { - return LOCATION_PATH_TEMPLATE.parse(locationName).get("location"); - } - - /** - * Parses the project from the given fully-qualified path which represents a product resource. - * - * @deprecated Use the {@link ProductName} class instead. - */ - @Deprecated - public static final String parseProjectFromProductName(String productName) { - return PRODUCT_PATH_TEMPLATE.parse(productName).get("project"); - } - - /** - * Parses the location from the given fully-qualified path which represents a product resource. - * - * @deprecated Use the {@link ProductName} class instead. - */ - @Deprecated - public static final String parseLocationFromProductName(String productName) { - return PRODUCT_PATH_TEMPLATE.parse(productName).get("location"); - } - - /** - * Parses the product from the given fully-qualified path which represents a product resource. - * - * @deprecated Use the {@link ProductName} class instead. - */ - @Deprecated - public static final String parseProductFromProductName(String productName) { - return PRODUCT_PATH_TEMPLATE.parse(productName).get("product"); - } - - /** - * Parses the project from the given fully-qualified path which represents a product_set resource. - * - * @deprecated Use the {@link ProductSetName} class instead. - */ - @Deprecated - public static final String parseProjectFromProductSetName(String productSetName) { - return PRODUCT_SET_PATH_TEMPLATE.parse(productSetName).get("project"); - } - - /** - * Parses the location from the given fully-qualified path which represents a product_set - * resource. - * - * @deprecated Use the {@link ProductSetName} class instead. - */ - @Deprecated - public static final String parseLocationFromProductSetName(String productSetName) { - return PRODUCT_SET_PATH_TEMPLATE.parse(productSetName).get("location"); - } - - /** - * Parses the product_set from the given fully-qualified path which represents a product_set - * resource. - * - * @deprecated Use the {@link ProductSetName} class instead. - */ - @Deprecated - public static final String parseProductSetFromProductSetName(String productSetName) { - return PRODUCT_SET_PATH_TEMPLATE.parse(productSetName).get("product_set"); - } - - /** - * Parses the project from the given fully-qualified path which represents a reference_image - * resource. - * - * @deprecated Use the {@link ReferenceImageName} class instead. - */ - @Deprecated - public static final String parseProjectFromReferenceImageName(String referenceImageName) { - return REFERENCE_IMAGE_PATH_TEMPLATE.parse(referenceImageName).get("project"); - } - - /** - * Parses the location from the given fully-qualified path which represents a reference_image - * resource. - * - * @deprecated Use the {@link ReferenceImageName} class instead. - */ - @Deprecated - public static final String parseLocationFromReferenceImageName(String referenceImageName) { - return REFERENCE_IMAGE_PATH_TEMPLATE.parse(referenceImageName).get("location"); - } - - /** - * Parses the product from the given fully-qualified path which represents a reference_image - * resource. - * - * @deprecated Use the {@link ReferenceImageName} class instead. - */ - @Deprecated - public static final String parseProductFromReferenceImageName(String referenceImageName) { - return REFERENCE_IMAGE_PATH_TEMPLATE.parse(referenceImageName).get("product"); - } - - /** - * Parses the reference_image from the given fully-qualified path which represents a - * reference_image resource. - * - * @deprecated Use the {@link ReferenceImageName} class instead. - */ - @Deprecated - public static final String parseReferenceImageFromReferenceImageName(String referenceImageName) { - return REFERENCE_IMAGE_PATH_TEMPLATE.parse(referenceImageName).get("reference_image"); - } + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ProductSearchClient with default settings. */ public static final ProductSearchClient create() throws IOException { @@ -341,7 +160,6 @@ public static final ProductSearchClient create(ProductSearchSettings settings) * Constructs an instance of ProductSearchClient, using the given stub for making calls. This is * for advanced usage - prefer using create(ProductSearchSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ProductSearchClient create(ProductSearchStub stub) { return new ProductSearchClient(stub); } @@ -354,21 +172,23 @@ public static final ProductSearchClient create(ProductSearchStub stub) { protected ProductSearchClient(ProductSearchSettings settings) throws IOException { this.settings = settings; this.stub = ((ProductSearchStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ProductSearchClient(ProductSearchStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ProductSearchSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ProductSearchStub getStub() { return stub; } @@ -377,10 +197,19 @@ public ProductSearchStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates and returns a new ProductSet resource. @@ -696,7 +525,7 @@ public final ListProductSetsPagedResponse listProductSets(ListProductSetsRequest * while (true) { * ListProductSetsResponse response = * productSearchClient.listProductSetsCallable().call(request); - * for (ProductSet element : response.getResponsesList()) { + * for (ProductSet element : response.getProductSetsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1373,7 +1202,7 @@ public final ListProductsPagedResponse listProducts(ListProductsRequest request) * .build(); * while (true) { * ListProductsResponse response = productSearchClient.listProductsCallable().call(request); - * for (Product element : response.getResponsesList()) { + * for (Product element : response.getProductsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2257,7 +2086,7 @@ public final ListReferenceImagesPagedResponse listReferenceImages( * while (true) { * ListReferenceImagesResponse response = * productSearchClient.listReferenceImagesCallable().call(request); - * for (ReferenceImage element : response.getResponsesList()) { + * for (ReferenceImage element : response.getReferenceImagesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2981,7 +2810,7 @@ public final ListProductsInProductSetPagedResponse listProductsInProductSet( * while (true) { * ListProductsInProductSetResponse response = * productSearchClient.listProductsInProductSetCallable().call(request); - * for (Product element : response.getResponsesList()) { + * for (Product element : response.getProductsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ProductSearchSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ProductSearchSettings.java index 4a84703f8..948e34eb5 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ProductSearchSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ProductSearchSettings.java @@ -26,6 +26,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -220,11 +221,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ProductSearchStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ProductSearchStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ProductSearchStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ProductSearchStubSettings.defaultTransportChannelProvider(); } @@ -234,11 +242,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ProductSearchStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -276,6 +290,11 @@ private static Builder createDefault() { return new Builder(ProductSearchStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ProductSearchStubSettings.newHttpJsonBuilder()); + } + public ProductSearchStubSettings.Builder getStubSettingsBuilder() { return ((ProductSearchStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/package-info.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/package-info.java index d747f3380..01b562ec0 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/package-info.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/package-info.java @@ -15,7 +15,9 @@ */ /** - * The interfaces provided are listed below, along with usage samples. + * A client to Cloud Vision API + * + *

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

======================= ImageAnnotatorClient ======================= * diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonImageAnnotatorCallableFactory.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonImageAnnotatorCallableFactory.java new file mode 100644 index 000000000..7c06329ac --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonImageAnnotatorCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ImageAnnotator service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonImageAnnotatorCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonImageAnnotatorStub.java new file mode 100644 index 000000000..c07ae59b7 --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonImageAnnotatorStub.java @@ -0,0 +1,441 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse; +import com.google.cloud.vision.v1.BatchAnnotateFilesRequest; +import com.google.cloud.vision.v1.BatchAnnotateFilesResponse; +import com.google.cloud.vision.v1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1.OperationMetadata; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ImageAnnotator service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonImageAnnotatorStub extends ImageAnnotatorStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(AsyncBatchAnnotateFilesResponse.getDescriptor()) + .add(AsyncBatchAnnotateImagesResponse.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + batchAnnotateImagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ImageAnnotator/BatchAnnotateImages") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/images:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/locations/*}/images:annotate", + "/v1/{parent=projects/*}/images:annotate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchAnnotateImagesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchAnnotateFilesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ImageAnnotator/BatchAnnotateFiles") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/files:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/locations/*}/files:annotate", + "/v1/{parent=projects/*}/files:annotate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchAnnotateFilesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + asyncBatchAnnotateImagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateImages") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/images:asyncBatchAnnotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/locations/*}/images:asyncBatchAnnotate", + "/v1/{parent=projects/*}/images:asyncBatchAnnotate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AsyncBatchAnnotateImagesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + asyncBatchAnnotateFilesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateFiles") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/files:asyncBatchAnnotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/locations/*}/files:asyncBatchAnnotate", + "/v1/{parent=projects/*}/files:asyncBatchAnnotate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AsyncBatchAnnotateFilesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + batchAnnotateImagesCallable; + private final UnaryCallable + batchAnnotateFilesCallable; + private final UnaryCallable + asyncBatchAnnotateImagesCallable; + private final OperationCallable< + AsyncBatchAnnotateImagesRequest, AsyncBatchAnnotateImagesResponse, OperationMetadata> + asyncBatchAnnotateImagesOperationCallable; + private final UnaryCallable + asyncBatchAnnotateFilesCallable; + private final OperationCallable< + AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata> + asyncBatchAnnotateFilesOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonImageAnnotatorStub create(ImageAnnotatorStubSettings settings) + throws IOException { + return new HttpJsonImageAnnotatorStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonImageAnnotatorStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonImageAnnotatorStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonImageAnnotatorStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonImageAnnotatorCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonImageAnnotatorStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + batchAnnotateImagesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(batchAnnotateImagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchAnnotateFilesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchAnnotateFilesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + asyncBatchAnnotateImagesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(asyncBatchAnnotateImagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + asyncBatchAnnotateFilesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(asyncBatchAnnotateFilesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.batchAnnotateImagesCallable = + callableFactory.createUnaryCallable( + batchAnnotateImagesTransportSettings, + settings.batchAnnotateImagesSettings(), + clientContext); + this.batchAnnotateFilesCallable = + callableFactory.createUnaryCallable( + batchAnnotateFilesTransportSettings, + settings.batchAnnotateFilesSettings(), + clientContext); + this.asyncBatchAnnotateImagesCallable = + callableFactory.createUnaryCallable( + asyncBatchAnnotateImagesTransportSettings, + settings.asyncBatchAnnotateImagesSettings(), + clientContext); + this.asyncBatchAnnotateImagesOperationCallable = + callableFactory.createOperationCallable( + asyncBatchAnnotateImagesTransportSettings, + settings.asyncBatchAnnotateImagesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.asyncBatchAnnotateFilesCallable = + callableFactory.createUnaryCallable( + asyncBatchAnnotateFilesTransportSettings, + settings.asyncBatchAnnotateFilesSettings(), + clientContext); + this.asyncBatchAnnotateFilesOperationCallable = + callableFactory.createOperationCallable( + asyncBatchAnnotateFilesTransportSettings, + settings.asyncBatchAnnotateFilesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(batchAnnotateImagesMethodDescriptor); + methodDescriptors.add(batchAnnotateFilesMethodDescriptor); + methodDescriptors.add(asyncBatchAnnotateImagesMethodDescriptor); + methodDescriptors.add(asyncBatchAnnotateFilesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + batchAnnotateImagesCallable() { + return batchAnnotateImagesCallable; + } + + @Override + public UnaryCallable + batchAnnotateFilesCallable() { + return batchAnnotateFilesCallable; + } + + @Override + public UnaryCallable + asyncBatchAnnotateImagesCallable() { + return asyncBatchAnnotateImagesCallable; + } + + @Override + public OperationCallable< + AsyncBatchAnnotateImagesRequest, AsyncBatchAnnotateImagesResponse, OperationMetadata> + asyncBatchAnnotateImagesOperationCallable() { + return asyncBatchAnnotateImagesOperationCallable; + } + + @Override + public UnaryCallable + asyncBatchAnnotateFilesCallable() { + return asyncBatchAnnotateFilesCallable; + } + + @Override + public OperationCallable< + AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata> + asyncBatchAnnotateFilesOperationCallable() { + return asyncBatchAnnotateFilesOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonProductSearchCallableFactory.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonProductSearchCallableFactory.java new file mode 100644 index 000000000..c7f302eca --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonProductSearchCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ProductSearch service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonProductSearchCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonProductSearchStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonProductSearchStub.java new file mode 100644 index 000000000..b5b127dfe --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/HttpJsonProductSearchStub.java @@ -0,0 +1,1263 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.stub; + +import static com.google.cloud.vision.v1.ProductSearchClient.ListProductSetsPagedResponse; +import static com.google.cloud.vision.v1.ProductSearchClient.ListProductsInProductSetPagedResponse; +import static com.google.cloud.vision.v1.ProductSearchClient.ListProductsPagedResponse; +import static com.google.cloud.vision.v1.ProductSearchClient.ListReferenceImagesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.vision.v1.AddProductToProductSetRequest; +import com.google.cloud.vision.v1.BatchOperationMetadata; +import com.google.cloud.vision.v1.CreateProductRequest; +import com.google.cloud.vision.v1.CreateProductSetRequest; +import com.google.cloud.vision.v1.CreateReferenceImageRequest; +import com.google.cloud.vision.v1.DeleteProductRequest; +import com.google.cloud.vision.v1.DeleteProductSetRequest; +import com.google.cloud.vision.v1.DeleteReferenceImageRequest; +import com.google.cloud.vision.v1.GetProductRequest; +import com.google.cloud.vision.v1.GetProductSetRequest; +import com.google.cloud.vision.v1.GetReferenceImageRequest; +import com.google.cloud.vision.v1.ImportProductSetsRequest; +import com.google.cloud.vision.v1.ImportProductSetsResponse; +import com.google.cloud.vision.v1.ListProductSetsRequest; +import com.google.cloud.vision.v1.ListProductSetsResponse; +import com.google.cloud.vision.v1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1.ListProductsInProductSetResponse; +import com.google.cloud.vision.v1.ListProductsRequest; +import com.google.cloud.vision.v1.ListProductsResponse; +import com.google.cloud.vision.v1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1.ListReferenceImagesResponse; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSet; +import com.google.cloud.vision.v1.PurgeProductsRequest; +import com.google.cloud.vision.v1.ReferenceImage; +import com.google.cloud.vision.v1.RemoveProductFromProductSetRequest; +import com.google.cloud.vision.v1.UpdateProductRequest; +import com.google.cloud.vision.v1.UpdateProductSetRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ProductSearch service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonProductSearchStub extends ProductSearchStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(ImportProductSetsResponse.getDescriptor()) + .add(BatchOperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/CreateProductSet") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/productSets", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "productSetId", request.getProductSetId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("productSet", request.getProductSet())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ProductSet.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listProductSetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/ListProductSets") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/productSets", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductSetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/GetProductSet") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/productSets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ProductSet.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/UpdateProductSet") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{productSet.name=projects/*/locations/*/productSets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "productSet.name", request.getProductSet().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("productSet", request.getProductSet())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ProductSet.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/DeleteProductSet") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/productSets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/CreateProduct") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "productId", request.getProductId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/ListProducts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/GetProduct") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/products/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/UpdateProduct") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{product.name=projects/*/locations/*/products/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "product.name", request.getProduct().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/DeleteProduct") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/products/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createReferenceImageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/CreateReferenceImage") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/products/*}/referenceImages", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "referenceImageId", request.getReferenceImageId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("referenceImage", request.getReferenceImage())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ReferenceImage.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteReferenceImageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/DeleteReferenceImage") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listReferenceImagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/ListReferenceImages") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/products/*}/referenceImages", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListReferenceImagesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getReferenceImageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/GetReferenceImage") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ReferenceImage.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addProductToProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/AddProductToProductSet") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/productSets/*}:addProduct", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeProductFromProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/RemoveProductFromProductSet") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/productSets/*}:removeProduct", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListProductsInProductSetRequest, ListProductsInProductSetResponse> + listProductsInProductSetMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/ListProductsInProductSet") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/productSets/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsInProductSetResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + importProductSetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/ImportProductSets") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/productSets:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportProductSetsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + purgeProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1.ProductSearch/PurgeProducts") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/products:purge", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (PurgeProductsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createProductSetCallable; + private final UnaryCallable + listProductSetsCallable; + private final UnaryCallable + listProductSetsPagedCallable; + private final UnaryCallable getProductSetCallable; + private final UnaryCallable updateProductSetCallable; + private final UnaryCallable deleteProductSetCallable; + private final UnaryCallable createProductCallable; + private final UnaryCallable listProductsCallable; + private final UnaryCallable + listProductsPagedCallable; + private final UnaryCallable getProductCallable; + private final UnaryCallable updateProductCallable; + private final UnaryCallable deleteProductCallable; + private final UnaryCallable + createReferenceImageCallable; + private final UnaryCallable deleteReferenceImageCallable; + private final UnaryCallable + listReferenceImagesCallable; + private final UnaryCallable + listReferenceImagesPagedCallable; + private final UnaryCallable getReferenceImageCallable; + private final UnaryCallable addProductToProductSetCallable; + private final UnaryCallable + removeProductFromProductSetCallable; + private final UnaryCallable + listProductsInProductSetCallable; + private final UnaryCallable< + ListProductsInProductSetRequest, ListProductsInProductSetPagedResponse> + listProductsInProductSetPagedCallable; + private final UnaryCallable importProductSetsCallable; + private final OperationCallable< + ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> + importProductSetsOperationCallable; + private final UnaryCallable purgeProductsCallable; + private final OperationCallable + purgeProductsOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonProductSearchStub create(ProductSearchStubSettings settings) + throws IOException { + return new HttpJsonProductSearchStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonProductSearchStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonProductSearchStub( + ProductSearchStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonProductSearchStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonProductSearchStub( + ProductSearchStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonProductSearchStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonProductSearchStub( + ProductSearchStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonProductSearchCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonProductSearchStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonProductSearchStub( + ProductSearchStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listProductSetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductSetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createReferenceImageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createReferenceImageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteReferenceImageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteReferenceImageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listReferenceImagesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listReferenceImagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getReferenceImageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getReferenceImageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addProductToProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addProductToProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeProductFromProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeProductFromProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listProductsInProductSetTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listProductsInProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importProductSetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importProductSetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings purgeProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(purgeProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createProductSetCallable = + callableFactory.createUnaryCallable( + createProductSetTransportSettings, settings.createProductSetSettings(), clientContext); + this.listProductSetsCallable = + callableFactory.createUnaryCallable( + listProductSetsTransportSettings, settings.listProductSetsSettings(), clientContext); + this.listProductSetsPagedCallable = + callableFactory.createPagedCallable( + listProductSetsTransportSettings, settings.listProductSetsSettings(), clientContext); + this.getProductSetCallable = + callableFactory.createUnaryCallable( + getProductSetTransportSettings, settings.getProductSetSettings(), clientContext); + this.updateProductSetCallable = + callableFactory.createUnaryCallable( + updateProductSetTransportSettings, settings.updateProductSetSettings(), clientContext); + this.deleteProductSetCallable = + callableFactory.createUnaryCallable( + deleteProductSetTransportSettings, settings.deleteProductSetSettings(), clientContext); + this.createProductCallable = + callableFactory.createUnaryCallable( + createProductTransportSettings, settings.createProductSettings(), clientContext); + this.listProductsCallable = + callableFactory.createUnaryCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.listProductsPagedCallable = + callableFactory.createPagedCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.getProductCallable = + callableFactory.createUnaryCallable( + getProductTransportSettings, settings.getProductSettings(), clientContext); + this.updateProductCallable = + callableFactory.createUnaryCallable( + updateProductTransportSettings, settings.updateProductSettings(), clientContext); + this.deleteProductCallable = + callableFactory.createUnaryCallable( + deleteProductTransportSettings, settings.deleteProductSettings(), clientContext); + this.createReferenceImageCallable = + callableFactory.createUnaryCallable( + createReferenceImageTransportSettings, + settings.createReferenceImageSettings(), + clientContext); + this.deleteReferenceImageCallable = + callableFactory.createUnaryCallable( + deleteReferenceImageTransportSettings, + settings.deleteReferenceImageSettings(), + clientContext); + this.listReferenceImagesCallable = + callableFactory.createUnaryCallable( + listReferenceImagesTransportSettings, + settings.listReferenceImagesSettings(), + clientContext); + this.listReferenceImagesPagedCallable = + callableFactory.createPagedCallable( + listReferenceImagesTransportSettings, + settings.listReferenceImagesSettings(), + clientContext); + this.getReferenceImageCallable = + callableFactory.createUnaryCallable( + getReferenceImageTransportSettings, + settings.getReferenceImageSettings(), + clientContext); + this.addProductToProductSetCallable = + callableFactory.createUnaryCallable( + addProductToProductSetTransportSettings, + settings.addProductToProductSetSettings(), + clientContext); + this.removeProductFromProductSetCallable = + callableFactory.createUnaryCallable( + removeProductFromProductSetTransportSettings, + settings.removeProductFromProductSetSettings(), + clientContext); + this.listProductsInProductSetCallable = + callableFactory.createUnaryCallable( + listProductsInProductSetTransportSettings, + settings.listProductsInProductSetSettings(), + clientContext); + this.listProductsInProductSetPagedCallable = + callableFactory.createPagedCallable( + listProductsInProductSetTransportSettings, + settings.listProductsInProductSetSettings(), + clientContext); + this.importProductSetsCallable = + callableFactory.createUnaryCallable( + importProductSetsTransportSettings, + settings.importProductSetsSettings(), + clientContext); + this.importProductSetsOperationCallable = + callableFactory.createOperationCallable( + importProductSetsTransportSettings, + settings.importProductSetsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.purgeProductsCallable = + callableFactory.createUnaryCallable( + purgeProductsTransportSettings, settings.purgeProductsSettings(), clientContext); + this.purgeProductsOperationCallable = + callableFactory.createOperationCallable( + purgeProductsTransportSettings, + settings.purgeProductsOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createProductSetMethodDescriptor); + methodDescriptors.add(listProductSetsMethodDescriptor); + methodDescriptors.add(getProductSetMethodDescriptor); + methodDescriptors.add(updateProductSetMethodDescriptor); + methodDescriptors.add(deleteProductSetMethodDescriptor); + methodDescriptors.add(createProductMethodDescriptor); + methodDescriptors.add(listProductsMethodDescriptor); + methodDescriptors.add(getProductMethodDescriptor); + methodDescriptors.add(updateProductMethodDescriptor); + methodDescriptors.add(deleteProductMethodDescriptor); + methodDescriptors.add(createReferenceImageMethodDescriptor); + methodDescriptors.add(deleteReferenceImageMethodDescriptor); + methodDescriptors.add(listReferenceImagesMethodDescriptor); + methodDescriptors.add(getReferenceImageMethodDescriptor); + methodDescriptors.add(addProductToProductSetMethodDescriptor); + methodDescriptors.add(removeProductFromProductSetMethodDescriptor); + methodDescriptors.add(listProductsInProductSetMethodDescriptor); + methodDescriptors.add(importProductSetsMethodDescriptor); + methodDescriptors.add(purgeProductsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createProductSetCallable() { + return createProductSetCallable; + } + + @Override + public UnaryCallable listProductSetsCallable() { + return listProductSetsCallable; + } + + @Override + public UnaryCallable + listProductSetsPagedCallable() { + return listProductSetsPagedCallable; + } + + @Override + public UnaryCallable getProductSetCallable() { + return getProductSetCallable; + } + + @Override + public UnaryCallable updateProductSetCallable() { + return updateProductSetCallable; + } + + @Override + public UnaryCallable deleteProductSetCallable() { + return deleteProductSetCallable; + } + + @Override + public UnaryCallable createProductCallable() { + return createProductCallable; + } + + @Override + public UnaryCallable listProductsCallable() { + return listProductsCallable; + } + + @Override + public UnaryCallable listProductsPagedCallable() { + return listProductsPagedCallable; + } + + @Override + public UnaryCallable getProductCallable() { + return getProductCallable; + } + + @Override + public UnaryCallable updateProductCallable() { + return updateProductCallable; + } + + @Override + public UnaryCallable deleteProductCallable() { + return deleteProductCallable; + } + + @Override + public UnaryCallable createReferenceImageCallable() { + return createReferenceImageCallable; + } + + @Override + public UnaryCallable deleteReferenceImageCallable() { + return deleteReferenceImageCallable; + } + + @Override + public UnaryCallable + listReferenceImagesCallable() { + return listReferenceImagesCallable; + } + + @Override + public UnaryCallable + listReferenceImagesPagedCallable() { + return listReferenceImagesPagedCallable; + } + + @Override + public UnaryCallable getReferenceImageCallable() { + return getReferenceImageCallable; + } + + @Override + public UnaryCallable addProductToProductSetCallable() { + return addProductToProductSetCallable; + } + + @Override + public UnaryCallable + removeProductFromProductSetCallable() { + return removeProductFromProductSetCallable; + } + + @Override + public UnaryCallable + listProductsInProductSetCallable() { + return listProductsInProductSetCallable; + } + + @Override + public UnaryCallable + listProductsInProductSetPagedCallable() { + return listProductsInProductSetPagedCallable; + } + + @Override + public UnaryCallable importProductSetsCallable() { + return importProductSetsCallable; + } + + @Override + public OperationCallable< + ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> + importProductSetsOperationCallable() { + return importProductSetsOperationCallable; + } + + @Override + public UnaryCallable purgeProductsCallable() { + return purgeProductsCallable; + } + + @Override + public OperationCallable + purgeProductsOperationCallable() { + return purgeProductsOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStub.java index 3dd0b2552..dad41a2aa 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStub.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStub.java @@ -42,7 +42,11 @@ public abstract class ImageAnnotatorStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStubSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStubSettings.java index 31e695739..8daa7c798 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStubSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStubSettings.java @@ -25,6 +25,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -150,13 +153,17 @@ public class ImageAnnotatorStubSettings extends StubSettings createProductSetCallable() { diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ProductSearchStubSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ProductSearchStubSettings.java index e501b7526..7c1b0a742 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ProductSearchStubSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ProductSearchStubSettings.java @@ -31,6 +31,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -526,13 +529,17 @@ public UnaryCallSettings purgeProductsSettings( return purgeProductsOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ProductSearchStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcProductSearchStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonProductSearchStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -565,18 +572,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ProductSearchStubSettings.class)) @@ -584,11 +598,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ProductSearchStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ProductSearchStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -838,6 +871,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createProductSetSettings() diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorClient.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorClient.java index e345de6b7..8d16fb840 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorClient.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorClient.java @@ -92,6 +92,20 @@ * ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ImageAnnotatorSettings imageAnnotatorSettings =
+ *     ImageAnnotatorSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -118,7 +132,6 @@ public static final ImageAnnotatorClient create(ImageAnnotatorSettings settings) * Constructs an instance of ImageAnnotatorClient, using the given stub for making calls. This is * for advanced usage - prefer using create(ImageAnnotatorSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ImageAnnotatorClient create(ImageAnnotatorStub stub) { return new ImageAnnotatorClient(stub); } @@ -133,7 +146,6 @@ protected ImageAnnotatorClient(ImageAnnotatorSettings settings) throws IOExcepti this.stub = ((ImageAnnotatorStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ImageAnnotatorClient(ImageAnnotatorStub stub) { this.settings = null; this.stub = stub; @@ -143,7 +155,6 @@ public final ImageAnnotatorSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ImageAnnotatorStub getStub() { return stub; } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorSettings.java index b5a7050c0..058193a73 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -100,11 +101,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ImageAnnotatorStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ImageAnnotatorStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ImageAnnotatorStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ImageAnnotatorStubSettings.defaultTransportChannelProvider(); } @@ -114,11 +122,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ImageAnnotatorStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -156,6 +170,11 @@ private static Builder createDefault() { return new Builder(ImageAnnotatorStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ImageAnnotatorStubSettings.newHttpJsonBuilder()); + } + public ImageAnnotatorStubSettings.Builder getStubSettingsBuilder() { return ((ImageAnnotatorStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/HttpJsonImageAnnotatorCallableFactory.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/HttpJsonImageAnnotatorCallableFactory.java new file mode 100644 index 000000000..a3e75588b --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/HttpJsonImageAnnotatorCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p1beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ImageAnnotator service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonImageAnnotatorCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/HttpJsonImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/HttpJsonImageAnnotatorStub.java new file mode 100644 index 000000000..3b2a35511 --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/HttpJsonImageAnnotatorStub.java @@ -0,0 +1,198 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p1beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ImageAnnotator service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonImageAnnotatorStub extends ImageAnnotatorStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + batchAnnotateImagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p1beta1.ImageAnnotator/BatchAnnotateImages") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/images:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchAnnotateImagesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + batchAnnotateImagesCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonImageAnnotatorStub create(ImageAnnotatorStubSettings settings) + throws IOException { + return new HttpJsonImageAnnotatorStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonImageAnnotatorStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonImageAnnotatorStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonImageAnnotatorStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonImageAnnotatorCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonImageAnnotatorStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + batchAnnotateImagesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(batchAnnotateImagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.batchAnnotateImagesCallable = + callableFactory.createUnaryCallable( + batchAnnotateImagesTransportSettings, + settings.batchAnnotateImagesSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(batchAnnotateImagesMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + batchAnnotateImagesCallable() { + return batchAnnotateImagesCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStubSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStubSettings.java index 6864f282a..424d51e69 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStubSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStubSettings.java @@ -24,6 +24,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -95,13 +98,17 @@ public class ImageAnnotatorStubSettings extends StubSettings * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ImageAnnotatorSettings imageAnnotatorSettings =
+ *     ImageAnnotatorSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -103,7 +117,8 @@ public class ImageAnnotatorClient implements BackgroundResource { private final ImageAnnotatorSettings settings; private final ImageAnnotatorStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ImageAnnotatorClient with default settings. */ public static final ImageAnnotatorClient create() throws IOException { @@ -123,7 +138,6 @@ public static final ImageAnnotatorClient create(ImageAnnotatorSettings settings) * Constructs an instance of ImageAnnotatorClient, using the given stub for making calls. This is * for advanced usage - prefer using create(ImageAnnotatorSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ImageAnnotatorClient create(ImageAnnotatorStub stub) { return new ImageAnnotatorClient(stub); } @@ -136,21 +150,23 @@ public static final ImageAnnotatorClient create(ImageAnnotatorStub stub) { protected ImageAnnotatorClient(ImageAnnotatorSettings settings) throws IOException { this.settings = settings; this.stub = ((ImageAnnotatorStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ImageAnnotatorClient(ImageAnnotatorStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ImageAnnotatorSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ImageAnnotatorStub getStub() { return stub; } @@ -159,10 +175,19 @@ public ImageAnnotatorStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Run image detection and annotation for a batch of images. diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorSettings.java index 956be571d..238b1be07 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -116,11 +117,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ImageAnnotatorStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ImageAnnotatorStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ImageAnnotatorStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ImageAnnotatorStubSettings.defaultTransportChannelProvider(); } @@ -130,11 +138,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ImageAnnotatorStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -172,6 +186,11 @@ private static Builder createDefault() { return new Builder(ImageAnnotatorStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ImageAnnotatorStubSettings.newHttpJsonBuilder()); + } + public ImageAnnotatorStubSettings.Builder getStubSettingsBuilder() { return ((ImageAnnotatorStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/HttpJsonImageAnnotatorCallableFactory.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/HttpJsonImageAnnotatorCallableFactory.java new file mode 100644 index 000000000..9fc90fd37 --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/HttpJsonImageAnnotatorCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ImageAnnotator service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonImageAnnotatorCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/HttpJsonImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/HttpJsonImageAnnotatorStub.java new file mode 100644 index 000000000..3d5e84f5b --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/HttpJsonImageAnnotatorStub.java @@ -0,0 +1,290 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p2beta1.OperationMetadata; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ImageAnnotator service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonImageAnnotatorStub extends ImageAnnotatorStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(OperationMetadata.getDescriptor()) + .add(AsyncBatchAnnotateFilesResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + batchAnnotateImagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p2beta1.ImageAnnotator/BatchAnnotateImages") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p2beta1/images:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchAnnotateImagesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + asyncBatchAnnotateFilesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.vision.v1p2beta1.ImageAnnotator/AsyncBatchAnnotateFiles") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p2beta1/files:asyncBatchAnnotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AsyncBatchAnnotateFilesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + batchAnnotateImagesCallable; + private final UnaryCallable + asyncBatchAnnotateFilesCallable; + private final OperationCallable< + AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata> + asyncBatchAnnotateFilesOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonImageAnnotatorStub create(ImageAnnotatorStubSettings settings) + throws IOException { + return new HttpJsonImageAnnotatorStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonImageAnnotatorStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonImageAnnotatorStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonImageAnnotatorStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonImageAnnotatorCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonImageAnnotatorStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + batchAnnotateImagesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(batchAnnotateImagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + asyncBatchAnnotateFilesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(asyncBatchAnnotateFilesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.batchAnnotateImagesCallable = + callableFactory.createUnaryCallable( + batchAnnotateImagesTransportSettings, + settings.batchAnnotateImagesSettings(), + clientContext); + this.asyncBatchAnnotateFilesCallable = + callableFactory.createUnaryCallable( + asyncBatchAnnotateFilesTransportSettings, + settings.asyncBatchAnnotateFilesSettings(), + clientContext); + this.asyncBatchAnnotateFilesOperationCallable = + callableFactory.createOperationCallable( + asyncBatchAnnotateFilesTransportSettings, + settings.asyncBatchAnnotateFilesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(batchAnnotateImagesMethodDescriptor); + methodDescriptors.add(asyncBatchAnnotateFilesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + batchAnnotateImagesCallable() { + return batchAnnotateImagesCallable; + } + + @Override + public UnaryCallable + asyncBatchAnnotateFilesCallable() { + return asyncBatchAnnotateFilesCallable; + } + + @Override + public OperationCallable< + AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata> + asyncBatchAnnotateFilesOperationCallable() { + return asyncBatchAnnotateFilesOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStub.java index 6fa20f7bc..697f897ef 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStub.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStub.java @@ -40,7 +40,11 @@ public abstract class ImageAnnotatorStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStubSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStubSettings.java index 2232a90d5..485b965c8 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStubSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStubSettings.java @@ -25,6 +25,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -121,13 +124,17 @@ public class ImageAnnotatorStubSettings extends StubSettings * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ImageAnnotatorSettings imageAnnotatorSettings =
+ *     ImageAnnotatorSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -103,7 +117,8 @@ public class ImageAnnotatorClient implements BackgroundResource { private final ImageAnnotatorSettings settings; private final ImageAnnotatorStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ImageAnnotatorClient with default settings. */ public static final ImageAnnotatorClient create() throws IOException { @@ -123,7 +138,6 @@ public static final ImageAnnotatorClient create(ImageAnnotatorSettings settings) * Constructs an instance of ImageAnnotatorClient, using the given stub for making calls. This is * for advanced usage - prefer using create(ImageAnnotatorSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ImageAnnotatorClient create(ImageAnnotatorStub stub) { return new ImageAnnotatorClient(stub); } @@ -136,21 +150,23 @@ public static final ImageAnnotatorClient create(ImageAnnotatorStub stub) { protected ImageAnnotatorClient(ImageAnnotatorSettings settings) throws IOException { this.settings = settings; this.stub = ((ImageAnnotatorStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ImageAnnotatorClient(ImageAnnotatorStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ImageAnnotatorSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ImageAnnotatorStub getStub() { return stub; } @@ -159,10 +175,19 @@ public ImageAnnotatorStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Run image detection and annotation for a batch of images. diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ImageAnnotatorSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ImageAnnotatorSettings.java index 48256f899..fc248ff6a 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ImageAnnotatorSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ImageAnnotatorSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -116,11 +117,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ImageAnnotatorStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ImageAnnotatorStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ImageAnnotatorStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ImageAnnotatorStubSettings.defaultTransportChannelProvider(); } @@ -130,11 +138,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ImageAnnotatorStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -172,6 +186,11 @@ private static Builder createDefault() { return new Builder(ImageAnnotatorStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ImageAnnotatorStubSettings.newHttpJsonBuilder()); + } + public ImageAnnotatorStubSettings.Builder getStubSettingsBuilder() { return ((ImageAnnotatorStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchClient.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchClient.java index b75c25911..62156f45d 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchClient.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.vision.v1p3beta1.stub.ProductSearchStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -119,6 +119,20 @@ * ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ProductSearchSettings productSearchSettings =
+ *     ProductSearchSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ProductSearchSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -126,7 +140,8 @@ public class ProductSearchClient implements BackgroundResource { private final ProductSearchSettings settings; private final ProductSearchStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ProductSearchClient with default settings. */ public static final ProductSearchClient create() throws IOException { @@ -146,7 +161,6 @@ public static final ProductSearchClient create(ProductSearchSettings settings) * Constructs an instance of ProductSearchClient, using the given stub for making calls. This is * for advanced usage - prefer using create(ProductSearchSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ProductSearchClient create(ProductSearchStub stub) { return new ProductSearchClient(stub); } @@ -159,21 +173,23 @@ public static final ProductSearchClient create(ProductSearchStub stub) { protected ProductSearchClient(ProductSearchSettings settings) throws IOException { this.settings = settings; this.stub = ((ProductSearchStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ProductSearchClient(ProductSearchStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ProductSearchSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ProductSearchStub getStub() { return stub; } @@ -182,10 +198,19 @@ public ProductSearchStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates and returns a new ProductSet resource. @@ -501,7 +526,7 @@ public final ListProductSetsPagedResponse listProductSets(ListProductSetsRequest * while (true) { * ListProductSetsResponse response = * productSearchClient.listProductSetsCallable().call(request); - * for (ProductSet element : response.getResponsesList()) { + * for (ProductSet element : response.getProductSetsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1202,7 +1227,7 @@ public final ListProductsPagedResponse listProducts(ListProductsRequest request) * .build(); * while (true) { * ListProductsResponse response = productSearchClient.listProductsCallable().call(request); - * for (Product element : response.getResponsesList()) { + * for (Product element : response.getProductsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2134,7 +2159,7 @@ public final ListReferenceImagesPagedResponse listReferenceImages( * while (true) { * ListReferenceImagesResponse response = * productSearchClient.listReferenceImagesCallable().call(request); - * for (ReferenceImage element : response.getResponsesList()) { + * for (ReferenceImage element : response.getReferenceImagesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2894,7 +2919,7 @@ public final ListProductsInProductSetPagedResponse listProductsInProductSet( * while (true) { * ListProductsInProductSetResponse response = * productSearchClient.listProductsInProductSetCallable().call(request); - * for (Product element : response.getResponsesList()) { + * for (Product element : response.getProductsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchSettings.java index 764e236f9..46e8ae4f7 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchSettings.java @@ -26,6 +26,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -210,11 +211,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ProductSearchStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ProductSearchStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ProductSearchStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ProductSearchStubSettings.defaultTransportChannelProvider(); } @@ -224,11 +232,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ProductSearchStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -266,6 +280,11 @@ private static Builder createDefault() { return new Builder(ProductSearchStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ProductSearchStubSettings.newHttpJsonBuilder()); + } + public ProductSearchStubSettings.Builder getStubSettingsBuilder() { return ((ProductSearchStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonImageAnnotatorCallableFactory.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonImageAnnotatorCallableFactory.java new file mode 100644 index 000000000..f172d07f7 --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonImageAnnotatorCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ImageAnnotator service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonImageAnnotatorCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonImageAnnotatorStub.java new file mode 100644 index 000000000..e75814f71 --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonImageAnnotatorStub.java @@ -0,0 +1,290 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p3beta1.OperationMetadata; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ImageAnnotator service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonImageAnnotatorStub extends ImageAnnotatorStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(OperationMetadata.getDescriptor()) + .add(AsyncBatchAnnotateFilesResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + batchAnnotateImagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ImageAnnotator/BatchAnnotateImages") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/images:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchAnnotateImagesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + asyncBatchAnnotateFilesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.vision.v1p3beta1.ImageAnnotator/AsyncBatchAnnotateFiles") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/files:asyncBatchAnnotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AsyncBatchAnnotateFilesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + batchAnnotateImagesCallable; + private final UnaryCallable + asyncBatchAnnotateFilesCallable; + private final OperationCallable< + AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata> + asyncBatchAnnotateFilesOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonImageAnnotatorStub create(ImageAnnotatorStubSettings settings) + throws IOException { + return new HttpJsonImageAnnotatorStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonImageAnnotatorStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonImageAnnotatorStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonImageAnnotatorStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonImageAnnotatorCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonImageAnnotatorStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + batchAnnotateImagesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(batchAnnotateImagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + asyncBatchAnnotateFilesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(asyncBatchAnnotateFilesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.batchAnnotateImagesCallable = + callableFactory.createUnaryCallable( + batchAnnotateImagesTransportSettings, + settings.batchAnnotateImagesSettings(), + clientContext); + this.asyncBatchAnnotateFilesCallable = + callableFactory.createUnaryCallable( + asyncBatchAnnotateFilesTransportSettings, + settings.asyncBatchAnnotateFilesSettings(), + clientContext); + this.asyncBatchAnnotateFilesOperationCallable = + callableFactory.createOperationCallable( + asyncBatchAnnotateFilesTransportSettings, + settings.asyncBatchAnnotateFilesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(batchAnnotateImagesMethodDescriptor); + methodDescriptors.add(asyncBatchAnnotateFilesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + batchAnnotateImagesCallable() { + return batchAnnotateImagesCallable; + } + + @Override + public UnaryCallable + asyncBatchAnnotateFilesCallable() { + return asyncBatchAnnotateFilesCallable; + } + + @Override + public OperationCallable< + AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata> + asyncBatchAnnotateFilesOperationCallable() { + return asyncBatchAnnotateFilesOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonProductSearchCallableFactory.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonProductSearchCallableFactory.java new file mode 100644 index 000000000..ca5283f4c --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonProductSearchCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ProductSearch service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductSearchCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonProductSearchStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonProductSearchStub.java new file mode 100644 index 000000000..2156152ce --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/HttpJsonProductSearchStub.java @@ -0,0 +1,1196 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.stub; + +import static com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductSetsPagedResponse; +import static com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductsInProductSetPagedResponse; +import static com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductsPagedResponse; +import static com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListReferenceImagesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest; +import com.google.cloud.vision.v1p3beta1.BatchOperationMetadata; +import com.google.cloud.vision.v1p3beta1.CreateProductRequest; +import com.google.cloud.vision.v1p3beta1.CreateProductSetRequest; +import com.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest; +import com.google.cloud.vision.v1p3beta1.DeleteProductRequest; +import com.google.cloud.vision.v1p3beta1.DeleteProductSetRequest; +import com.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest; +import com.google.cloud.vision.v1p3beta1.GetProductRequest; +import com.google.cloud.vision.v1p3beta1.GetProductSetRequest; +import com.google.cloud.vision.v1p3beta1.GetReferenceImageRequest; +import com.google.cloud.vision.v1p3beta1.ImportProductSetsRequest; +import com.google.cloud.vision.v1p3beta1.ImportProductSetsResponse; +import com.google.cloud.vision.v1p3beta1.ListProductSetsRequest; +import com.google.cloud.vision.v1p3beta1.ListProductSetsResponse; +import com.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1p3beta1.ListProductsInProductSetResponse; +import com.google.cloud.vision.v1p3beta1.ListProductsRequest; +import com.google.cloud.vision.v1p3beta1.ListProductsResponse; +import com.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1p3beta1.ListReferenceImagesResponse; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSet; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; +import com.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest; +import com.google.cloud.vision.v1p3beta1.UpdateProductRequest; +import com.google.cloud.vision.v1p3beta1.UpdateProductSetRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ProductSearch service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductSearchStub extends ProductSearchStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportProductSetsResponse.getDescriptor()) + .add(BatchOperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/CreateProductSet") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{parent=projects/*/locations/*}/productSets", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "productSetId", request.getProductSetId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("productSet", request.getProductSet())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ProductSet.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listProductSetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/ListProductSets") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{parent=projects/*/locations/*}/productSets", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductSetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/GetProductSet") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{name=projects/*/locations/*/productSets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ProductSet.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/UpdateProductSet") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{productSet.name=projects/*/locations/*/productSets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "productSet.name", request.getProductSet().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("productSet", request.getProductSet())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ProductSet.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/DeleteProductSet") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{name=projects/*/locations/*/productSets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/CreateProduct") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{parent=projects/*/locations/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "productId", request.getProductId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/ListProducts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{parent=projects/*/locations/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/GetProduct") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{name=projects/*/locations/*/products/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/UpdateProduct") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{product.name=projects/*/locations/*/products/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "product.name", request.getProduct().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/DeleteProduct") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{name=projects/*/locations/*/products/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createReferenceImageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/CreateReferenceImage") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "referenceImageId", request.getReferenceImageId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("referenceImage", request.getReferenceImage())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ReferenceImage.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteReferenceImageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/DeleteReferenceImage") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listReferenceImagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/ListReferenceImages") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListReferenceImagesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getReferenceImageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/GetReferenceImage") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ReferenceImage.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addProductToProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.vision.v1p3beta1.ProductSearch/AddProductToProductSet") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:addProduct", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeProductFromProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.vision.v1p3beta1.ProductSearch/RemoveProductFromProductSet") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:removeProduct", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListProductsInProductSetRequest, ListProductsInProductSetResponse> + listProductsInProductSetMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.vision.v1p3beta1.ProductSearch/ListProductsInProductSet") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{name=projects/*/locations/*/productSets/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsInProductSetResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + importProductSetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p3beta1.ProductSearch/ImportProductSets") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/{parent=projects/*/locations/*}/productSets:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportProductSetsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createProductSetCallable; + private final UnaryCallable + listProductSetsCallable; + private final UnaryCallable + listProductSetsPagedCallable; + private final UnaryCallable getProductSetCallable; + private final UnaryCallable updateProductSetCallable; + private final UnaryCallable deleteProductSetCallable; + private final UnaryCallable createProductCallable; + private final UnaryCallable listProductsCallable; + private final UnaryCallable + listProductsPagedCallable; + private final UnaryCallable getProductCallable; + private final UnaryCallable updateProductCallable; + private final UnaryCallable deleteProductCallable; + private final UnaryCallable + createReferenceImageCallable; + private final UnaryCallable deleteReferenceImageCallable; + private final UnaryCallable + listReferenceImagesCallable; + private final UnaryCallable + listReferenceImagesPagedCallable; + private final UnaryCallable getReferenceImageCallable; + private final UnaryCallable addProductToProductSetCallable; + private final UnaryCallable + removeProductFromProductSetCallable; + private final UnaryCallable + listProductsInProductSetCallable; + private final UnaryCallable< + ListProductsInProductSetRequest, ListProductsInProductSetPagedResponse> + listProductsInProductSetPagedCallable; + private final UnaryCallable importProductSetsCallable; + private final OperationCallable< + ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> + importProductSetsOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonProductSearchStub create(ProductSearchStubSettings settings) + throws IOException { + return new HttpJsonProductSearchStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonProductSearchStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonProductSearchStub( + ProductSearchStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonProductSearchStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonProductSearchStub( + ProductSearchStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonProductSearchStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonProductSearchStub( + ProductSearchStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonProductSearchCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonProductSearchStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonProductSearchStub( + ProductSearchStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listProductSetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductSetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createReferenceImageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createReferenceImageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteReferenceImageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteReferenceImageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listReferenceImagesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listReferenceImagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getReferenceImageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getReferenceImageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addProductToProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addProductToProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeProductFromProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeProductFromProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listProductsInProductSetTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listProductsInProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importProductSetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importProductSetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createProductSetCallable = + callableFactory.createUnaryCallable( + createProductSetTransportSettings, settings.createProductSetSettings(), clientContext); + this.listProductSetsCallable = + callableFactory.createUnaryCallable( + listProductSetsTransportSettings, settings.listProductSetsSettings(), clientContext); + this.listProductSetsPagedCallable = + callableFactory.createPagedCallable( + listProductSetsTransportSettings, settings.listProductSetsSettings(), clientContext); + this.getProductSetCallable = + callableFactory.createUnaryCallable( + getProductSetTransportSettings, settings.getProductSetSettings(), clientContext); + this.updateProductSetCallable = + callableFactory.createUnaryCallable( + updateProductSetTransportSettings, settings.updateProductSetSettings(), clientContext); + this.deleteProductSetCallable = + callableFactory.createUnaryCallable( + deleteProductSetTransportSettings, settings.deleteProductSetSettings(), clientContext); + this.createProductCallable = + callableFactory.createUnaryCallable( + createProductTransportSettings, settings.createProductSettings(), clientContext); + this.listProductsCallable = + callableFactory.createUnaryCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.listProductsPagedCallable = + callableFactory.createPagedCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.getProductCallable = + callableFactory.createUnaryCallable( + getProductTransportSettings, settings.getProductSettings(), clientContext); + this.updateProductCallable = + callableFactory.createUnaryCallable( + updateProductTransportSettings, settings.updateProductSettings(), clientContext); + this.deleteProductCallable = + callableFactory.createUnaryCallable( + deleteProductTransportSettings, settings.deleteProductSettings(), clientContext); + this.createReferenceImageCallable = + callableFactory.createUnaryCallable( + createReferenceImageTransportSettings, + settings.createReferenceImageSettings(), + clientContext); + this.deleteReferenceImageCallable = + callableFactory.createUnaryCallable( + deleteReferenceImageTransportSettings, + settings.deleteReferenceImageSettings(), + clientContext); + this.listReferenceImagesCallable = + callableFactory.createUnaryCallable( + listReferenceImagesTransportSettings, + settings.listReferenceImagesSettings(), + clientContext); + this.listReferenceImagesPagedCallable = + callableFactory.createPagedCallable( + listReferenceImagesTransportSettings, + settings.listReferenceImagesSettings(), + clientContext); + this.getReferenceImageCallable = + callableFactory.createUnaryCallable( + getReferenceImageTransportSettings, + settings.getReferenceImageSettings(), + clientContext); + this.addProductToProductSetCallable = + callableFactory.createUnaryCallable( + addProductToProductSetTransportSettings, + settings.addProductToProductSetSettings(), + clientContext); + this.removeProductFromProductSetCallable = + callableFactory.createUnaryCallable( + removeProductFromProductSetTransportSettings, + settings.removeProductFromProductSetSettings(), + clientContext); + this.listProductsInProductSetCallable = + callableFactory.createUnaryCallable( + listProductsInProductSetTransportSettings, + settings.listProductsInProductSetSettings(), + clientContext); + this.listProductsInProductSetPagedCallable = + callableFactory.createPagedCallable( + listProductsInProductSetTransportSettings, + settings.listProductsInProductSetSettings(), + clientContext); + this.importProductSetsCallable = + callableFactory.createUnaryCallable( + importProductSetsTransportSettings, + settings.importProductSetsSettings(), + clientContext); + this.importProductSetsOperationCallable = + callableFactory.createOperationCallable( + importProductSetsTransportSettings, + settings.importProductSetsOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createProductSetMethodDescriptor); + methodDescriptors.add(listProductSetsMethodDescriptor); + methodDescriptors.add(getProductSetMethodDescriptor); + methodDescriptors.add(updateProductSetMethodDescriptor); + methodDescriptors.add(deleteProductSetMethodDescriptor); + methodDescriptors.add(createProductMethodDescriptor); + methodDescriptors.add(listProductsMethodDescriptor); + methodDescriptors.add(getProductMethodDescriptor); + methodDescriptors.add(updateProductMethodDescriptor); + methodDescriptors.add(deleteProductMethodDescriptor); + methodDescriptors.add(createReferenceImageMethodDescriptor); + methodDescriptors.add(deleteReferenceImageMethodDescriptor); + methodDescriptors.add(listReferenceImagesMethodDescriptor); + methodDescriptors.add(getReferenceImageMethodDescriptor); + methodDescriptors.add(addProductToProductSetMethodDescriptor); + methodDescriptors.add(removeProductFromProductSetMethodDescriptor); + methodDescriptors.add(listProductsInProductSetMethodDescriptor); + methodDescriptors.add(importProductSetsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createProductSetCallable() { + return createProductSetCallable; + } + + @Override + public UnaryCallable listProductSetsCallable() { + return listProductSetsCallable; + } + + @Override + public UnaryCallable + listProductSetsPagedCallable() { + return listProductSetsPagedCallable; + } + + @Override + public UnaryCallable getProductSetCallable() { + return getProductSetCallable; + } + + @Override + public UnaryCallable updateProductSetCallable() { + return updateProductSetCallable; + } + + @Override + public UnaryCallable deleteProductSetCallable() { + return deleteProductSetCallable; + } + + @Override + public UnaryCallable createProductCallable() { + return createProductCallable; + } + + @Override + public UnaryCallable listProductsCallable() { + return listProductsCallable; + } + + @Override + public UnaryCallable listProductsPagedCallable() { + return listProductsPagedCallable; + } + + @Override + public UnaryCallable getProductCallable() { + return getProductCallable; + } + + @Override + public UnaryCallable updateProductCallable() { + return updateProductCallable; + } + + @Override + public UnaryCallable deleteProductCallable() { + return deleteProductCallable; + } + + @Override + public UnaryCallable createReferenceImageCallable() { + return createReferenceImageCallable; + } + + @Override + public UnaryCallable deleteReferenceImageCallable() { + return deleteReferenceImageCallable; + } + + @Override + public UnaryCallable + listReferenceImagesCallable() { + return listReferenceImagesCallable; + } + + @Override + public UnaryCallable + listReferenceImagesPagedCallable() { + return listReferenceImagesPagedCallable; + } + + @Override + public UnaryCallable getReferenceImageCallable() { + return getReferenceImageCallable; + } + + @Override + public UnaryCallable addProductToProductSetCallable() { + return addProductToProductSetCallable; + } + + @Override + public UnaryCallable + removeProductFromProductSetCallable() { + return removeProductFromProductSetCallable; + } + + @Override + public UnaryCallable + listProductsInProductSetCallable() { + return listProductsInProductSetCallable; + } + + @Override + public UnaryCallable + listProductsInProductSetPagedCallable() { + return listProductsInProductSetPagedCallable; + } + + @Override + public UnaryCallable importProductSetsCallable() { + return importProductSetsCallable; + } + + @Override + public OperationCallable< + ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> + importProductSetsOperationCallable() { + return importProductSetsOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ImageAnnotatorStub.java index 72d10aaf3..f8f0c7fab 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ImageAnnotatorStub.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ImageAnnotatorStub.java @@ -40,7 +40,11 @@ public abstract class ImageAnnotatorStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ImageAnnotatorStubSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ImageAnnotatorStubSettings.java index 6da68249a..409fa4804 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ImageAnnotatorStubSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ImageAnnotatorStubSettings.java @@ -25,6 +25,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -121,13 +124,17 @@ public class ImageAnnotatorStubSettings extends StubSettings createProductSetCallable() { diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ProductSearchStubSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ProductSearchStubSettings.java index b9ef95c1c..e5ba04f4b 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ProductSearchStubSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p3beta1/stub/ProductSearchStubSettings.java @@ -31,6 +31,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -512,13 +515,17 @@ public UnaryCallSettings importProductSetsS return importProductSetsOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ProductSearchStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcProductSearchStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonProductSearchStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -551,18 +558,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ProductSearchStubSettings.class)) @@ -570,11 +584,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ProductSearchStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ProductSearchStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -813,6 +846,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createProductSetSettings() diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ImageAnnotatorClient.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ImageAnnotatorClient.java index 1cbe52791..2f1cabcf5 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ImageAnnotatorClient.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ImageAnnotatorClient.java @@ -18,13 +18,13 @@ import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.vision.v1p4beta1.stub.ImageAnnotatorStub; import com.google.cloud.vision.v1p4beta1.stub.ImageAnnotatorStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -96,6 +96,20 @@ * ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ImageAnnotatorSettings imageAnnotatorSettings =
+ *     ImageAnnotatorSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -103,7 +117,8 @@ public class ImageAnnotatorClient implements BackgroundResource { private final ImageAnnotatorSettings settings; private final ImageAnnotatorStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ImageAnnotatorClient with default settings. */ public static final ImageAnnotatorClient create() throws IOException { @@ -123,7 +138,6 @@ public static final ImageAnnotatorClient create(ImageAnnotatorSettings settings) * Constructs an instance of ImageAnnotatorClient, using the given stub for making calls. This is * for advanced usage - prefer using create(ImageAnnotatorSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ImageAnnotatorClient create(ImageAnnotatorStub stub) { return new ImageAnnotatorClient(stub); } @@ -136,21 +150,23 @@ public static final ImageAnnotatorClient create(ImageAnnotatorStub stub) { protected ImageAnnotatorClient(ImageAnnotatorSettings settings) throws IOException { this.settings = settings; this.stub = ((ImageAnnotatorStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ImageAnnotatorClient(ImageAnnotatorStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ImageAnnotatorSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ImageAnnotatorStub getStub() { return stub; } @@ -159,10 +175,19 @@ public ImageAnnotatorStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Run image detection and annotation for a batch of images. diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ImageAnnotatorSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ImageAnnotatorSettings.java index d8c3c3be4..02757a739 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ImageAnnotatorSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ImageAnnotatorSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -136,11 +137,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ImageAnnotatorStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ImageAnnotatorStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ImageAnnotatorStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ImageAnnotatorStubSettings.defaultTransportChannelProvider(); } @@ -150,11 +158,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ImageAnnotatorStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -192,6 +206,11 @@ private static Builder createDefault() { return new Builder(ImageAnnotatorStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ImageAnnotatorStubSettings.newHttpJsonBuilder()); + } + public ImageAnnotatorStubSettings.Builder getStubSettingsBuilder() { return ((ImageAnnotatorStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ProductSearchClient.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ProductSearchClient.java index 338b7df34..f4ee7d0ca 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ProductSearchClient.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ProductSearchClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.vision.v1p4beta1.stub.ProductSearchStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -119,6 +119,20 @@ * ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ProductSearchSettings productSearchSettings =
+ *     ProductSearchSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ProductSearchSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -126,7 +140,8 @@ public class ProductSearchClient implements BackgroundResource { private final ProductSearchSettings settings; private final ProductSearchStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ProductSearchClient with default settings. */ public static final ProductSearchClient create() throws IOException { @@ -146,7 +161,6 @@ public static final ProductSearchClient create(ProductSearchSettings settings) * Constructs an instance of ProductSearchClient, using the given stub for making calls. This is * for advanced usage - prefer using create(ProductSearchSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ProductSearchClient create(ProductSearchStub stub) { return new ProductSearchClient(stub); } @@ -159,21 +173,23 @@ public static final ProductSearchClient create(ProductSearchStub stub) { protected ProductSearchClient(ProductSearchSettings settings) throws IOException { this.settings = settings; this.stub = ((ProductSearchStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ProductSearchClient(ProductSearchStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ProductSearchSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ProductSearchStub getStub() { return stub; } @@ -182,10 +198,19 @@ public ProductSearchStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates and returns a new ProductSet resource. @@ -501,7 +526,7 @@ public final ListProductSetsPagedResponse listProductSets(ListProductSetsRequest * while (true) { * ListProductSetsResponse response = * productSearchClient.listProductSetsCallable().call(request); - * for (ProductSet element : response.getResponsesList()) { + * for (ProductSet element : response.getProductSetsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1178,7 +1203,7 @@ public final ListProductsPagedResponse listProducts(ListProductsRequest request) * .build(); * while (true) { * ListProductsResponse response = productSearchClient.listProductsCallable().call(request); - * for (Product element : response.getResponsesList()) { + * for (Product element : response.getProductsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2062,7 +2087,7 @@ public final ListReferenceImagesPagedResponse listReferenceImages( * while (true) { * ListReferenceImagesResponse response = * productSearchClient.listReferenceImagesCallable().call(request); - * for (ReferenceImage element : response.getResponsesList()) { + * for (ReferenceImage element : response.getReferenceImagesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2786,7 +2811,7 @@ public final ListProductsInProductSetPagedResponse listProductsInProductSet( * while (true) { * ListProductsInProductSetResponse response = * productSearchClient.listProductsInProductSetCallable().call(request); - * for (Product element : response.getResponsesList()) { + * for (Product element : response.getProductsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ProductSearchSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ProductSearchSettings.java index a10d1467d..24833d6b6 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ProductSearchSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/ProductSearchSettings.java @@ -26,6 +26,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -221,11 +222,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ProductSearchStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ProductSearchStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ProductSearchStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ProductSearchStubSettings.defaultTransportChannelProvider(); } @@ -235,11 +243,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ProductSearchStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -277,6 +291,11 @@ private static Builder createDefault() { return new Builder(ProductSearchStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ProductSearchStubSettings.newHttpJsonBuilder()); + } + public ProductSearchStubSettings.Builder getStubSettingsBuilder() { return ((ProductSearchStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonImageAnnotatorCallableFactory.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonImageAnnotatorCallableFactory.java new file mode 100644 index 000000000..6cecdfaec --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonImageAnnotatorCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ImageAnnotator service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonImageAnnotatorCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonImageAnnotatorStub.java new file mode 100644 index 000000000..233845066 --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonImageAnnotatorStub.java @@ -0,0 +1,423 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p4beta1.OperationMetadata; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ImageAnnotator service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonImageAnnotatorStub extends ImageAnnotatorStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(OperationMetadata.getDescriptor()) + .add(AsyncBatchAnnotateFilesResponse.getDescriptor()) + .add(AsyncBatchAnnotateImagesResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + batchAnnotateImagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ImageAnnotator/BatchAnnotateImages") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/images:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchAnnotateImagesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchAnnotateFilesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ImageAnnotator/BatchAnnotateFiles") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/files:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchAnnotateFilesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + asyncBatchAnnotateImagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.vision.v1p4beta1.ImageAnnotator/AsyncBatchAnnotateImages") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/images:asyncBatchAnnotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AsyncBatchAnnotateImagesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + asyncBatchAnnotateFilesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.vision.v1p4beta1.ImageAnnotator/AsyncBatchAnnotateFiles") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/files:asyncBatchAnnotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AsyncBatchAnnotateFilesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + batchAnnotateImagesCallable; + private final UnaryCallable + batchAnnotateFilesCallable; + private final UnaryCallable + asyncBatchAnnotateImagesCallable; + private final OperationCallable< + AsyncBatchAnnotateImagesRequest, AsyncBatchAnnotateImagesResponse, OperationMetadata> + asyncBatchAnnotateImagesOperationCallable; + private final UnaryCallable + asyncBatchAnnotateFilesCallable; + private final OperationCallable< + AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata> + asyncBatchAnnotateFilesOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonImageAnnotatorStub create(ImageAnnotatorStubSettings settings) + throws IOException { + return new HttpJsonImageAnnotatorStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonImageAnnotatorStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonImageAnnotatorStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonImageAnnotatorStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonImageAnnotatorCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonImageAnnotatorStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonImageAnnotatorStub( + ImageAnnotatorStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + batchAnnotateImagesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(batchAnnotateImagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchAnnotateFilesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchAnnotateFilesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + asyncBatchAnnotateImagesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(asyncBatchAnnotateImagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + asyncBatchAnnotateFilesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(asyncBatchAnnotateFilesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.batchAnnotateImagesCallable = + callableFactory.createUnaryCallable( + batchAnnotateImagesTransportSettings, + settings.batchAnnotateImagesSettings(), + clientContext); + this.batchAnnotateFilesCallable = + callableFactory.createUnaryCallable( + batchAnnotateFilesTransportSettings, + settings.batchAnnotateFilesSettings(), + clientContext); + this.asyncBatchAnnotateImagesCallable = + callableFactory.createUnaryCallable( + asyncBatchAnnotateImagesTransportSettings, + settings.asyncBatchAnnotateImagesSettings(), + clientContext); + this.asyncBatchAnnotateImagesOperationCallable = + callableFactory.createOperationCallable( + asyncBatchAnnotateImagesTransportSettings, + settings.asyncBatchAnnotateImagesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.asyncBatchAnnotateFilesCallable = + callableFactory.createUnaryCallable( + asyncBatchAnnotateFilesTransportSettings, + settings.asyncBatchAnnotateFilesSettings(), + clientContext); + this.asyncBatchAnnotateFilesOperationCallable = + callableFactory.createOperationCallable( + asyncBatchAnnotateFilesTransportSettings, + settings.asyncBatchAnnotateFilesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(batchAnnotateImagesMethodDescriptor); + methodDescriptors.add(batchAnnotateFilesMethodDescriptor); + methodDescriptors.add(asyncBatchAnnotateImagesMethodDescriptor); + methodDescriptors.add(asyncBatchAnnotateFilesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + batchAnnotateImagesCallable() { + return batchAnnotateImagesCallable; + } + + @Override + public UnaryCallable + batchAnnotateFilesCallable() { + return batchAnnotateFilesCallable; + } + + @Override + public UnaryCallable + asyncBatchAnnotateImagesCallable() { + return asyncBatchAnnotateImagesCallable; + } + + @Override + public OperationCallable< + AsyncBatchAnnotateImagesRequest, AsyncBatchAnnotateImagesResponse, OperationMetadata> + asyncBatchAnnotateImagesOperationCallable() { + return asyncBatchAnnotateImagesOperationCallable; + } + + @Override + public UnaryCallable + asyncBatchAnnotateFilesCallable() { + return asyncBatchAnnotateFilesCallable; + } + + @Override + public OperationCallable< + AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata> + asyncBatchAnnotateFilesOperationCallable() { + return asyncBatchAnnotateFilesOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonProductSearchCallableFactory.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonProductSearchCallableFactory.java new file mode 100644 index 000000000..9554d926c --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonProductSearchCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ProductSearch service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductSearchCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonProductSearchStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonProductSearchStub.java new file mode 100644 index 000000000..91d9edfc0 --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/HttpJsonProductSearchStub.java @@ -0,0 +1,1266 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.stub; + +import static com.google.cloud.vision.v1p4beta1.ProductSearchClient.ListProductSetsPagedResponse; +import static com.google.cloud.vision.v1p4beta1.ProductSearchClient.ListProductsInProductSetPagedResponse; +import static com.google.cloud.vision.v1p4beta1.ProductSearchClient.ListProductsPagedResponse; +import static com.google.cloud.vision.v1p4beta1.ProductSearchClient.ListReferenceImagesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest; +import com.google.cloud.vision.v1p4beta1.BatchOperationMetadata; +import com.google.cloud.vision.v1p4beta1.CreateProductRequest; +import com.google.cloud.vision.v1p4beta1.CreateProductSetRequest; +import com.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest; +import com.google.cloud.vision.v1p4beta1.DeleteProductRequest; +import com.google.cloud.vision.v1p4beta1.DeleteProductSetRequest; +import com.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest; +import com.google.cloud.vision.v1p4beta1.GetProductRequest; +import com.google.cloud.vision.v1p4beta1.GetProductSetRequest; +import com.google.cloud.vision.v1p4beta1.GetReferenceImageRequest; +import com.google.cloud.vision.v1p4beta1.ImportProductSetsRequest; +import com.google.cloud.vision.v1p4beta1.ImportProductSetsResponse; +import com.google.cloud.vision.v1p4beta1.ListProductSetsRequest; +import com.google.cloud.vision.v1p4beta1.ListProductSetsResponse; +import com.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1p4beta1.ListProductsInProductSetResponse; +import com.google.cloud.vision.v1p4beta1.ListProductsRequest; +import com.google.cloud.vision.v1p4beta1.ListProductsResponse; +import com.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1p4beta1.ListReferenceImagesResponse; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSet; +import com.google.cloud.vision.v1p4beta1.PurgeProductsRequest; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; +import com.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest; +import com.google.cloud.vision.v1p4beta1.UpdateProductRequest; +import com.google.cloud.vision.v1p4beta1.UpdateProductSetRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ProductSearch service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductSearchStub extends ProductSearchStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportProductSetsResponse.getDescriptor()) + .add(Empty.getDescriptor()) + .add(BatchOperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/CreateProductSet") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{parent=projects/*/locations/*}/productSets", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "productSetId", request.getProductSetId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("productSet", request.getProductSet())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ProductSet.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listProductSetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/ListProductSets") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{parent=projects/*/locations/*}/productSets", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductSetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/GetProductSet") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{name=projects/*/locations/*/productSets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ProductSet.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/UpdateProductSet") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{productSet.name=projects/*/locations/*/productSets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "productSet.name", request.getProductSet().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("productSet", request.getProductSet())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ProductSet.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/DeleteProductSet") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{name=projects/*/locations/*/productSets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/CreateProduct") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{parent=projects/*/locations/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "productId", request.getProductId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/ListProducts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{parent=projects/*/locations/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/GetProduct") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{name=projects/*/locations/*/products/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/UpdateProduct") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{product.name=projects/*/locations/*/products/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "product.name", request.getProduct().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/DeleteProduct") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{name=projects/*/locations/*/products/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createReferenceImageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/CreateReferenceImage") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "referenceImageId", request.getReferenceImageId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("referenceImage", request.getReferenceImage())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ReferenceImage.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteReferenceImageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/DeleteReferenceImage") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listReferenceImagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/ListReferenceImages") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListReferenceImagesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getReferenceImageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/GetReferenceImage") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ReferenceImage.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addProductToProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.vision.v1p4beta1.ProductSearch/AddProductToProductSet") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:addProduct", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeProductFromProductSetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.vision.v1p4beta1.ProductSearch/RemoveProductFromProductSet") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:removeProduct", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListProductsInProductSetRequest, ListProductsInProductSetResponse> + listProductsInProductSetMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.vision.v1p4beta1.ProductSearch/ListProductsInProductSet") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{name=projects/*/locations/*/productSets/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsInProductSetResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + importProductSetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/ImportProductSets") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{parent=projects/*/locations/*}/productSets:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportProductSetsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + purgeProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.vision.v1p4beta1.ProductSearch/PurgeProducts") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p4beta1/{parent=projects/*/locations/*}/products:purge", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (PurgeProductsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createProductSetCallable; + private final UnaryCallable + listProductSetsCallable; + private final UnaryCallable + listProductSetsPagedCallable; + private final UnaryCallable getProductSetCallable; + private final UnaryCallable updateProductSetCallable; + private final UnaryCallable deleteProductSetCallable; + private final UnaryCallable createProductCallable; + private final UnaryCallable listProductsCallable; + private final UnaryCallable + listProductsPagedCallable; + private final UnaryCallable getProductCallable; + private final UnaryCallable updateProductCallable; + private final UnaryCallable deleteProductCallable; + private final UnaryCallable + createReferenceImageCallable; + private final UnaryCallable deleteReferenceImageCallable; + private final UnaryCallable + listReferenceImagesCallable; + private final UnaryCallable + listReferenceImagesPagedCallable; + private final UnaryCallable getReferenceImageCallable; + private final UnaryCallable addProductToProductSetCallable; + private final UnaryCallable + removeProductFromProductSetCallable; + private final UnaryCallable + listProductsInProductSetCallable; + private final UnaryCallable< + ListProductsInProductSetRequest, ListProductsInProductSetPagedResponse> + listProductsInProductSetPagedCallable; + private final UnaryCallable importProductSetsCallable; + private final OperationCallable< + ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> + importProductSetsOperationCallable; + private final UnaryCallable purgeProductsCallable; + private final OperationCallable + purgeProductsOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonProductSearchStub create(ProductSearchStubSettings settings) + throws IOException { + return new HttpJsonProductSearchStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonProductSearchStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonProductSearchStub( + ProductSearchStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonProductSearchStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonProductSearchStub( + ProductSearchStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonProductSearchStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonProductSearchStub( + ProductSearchStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonProductSearchCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonProductSearchStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonProductSearchStub( + ProductSearchStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listProductSetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductSetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createReferenceImageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createReferenceImageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteReferenceImageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteReferenceImageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listReferenceImagesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listReferenceImagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getReferenceImageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getReferenceImageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addProductToProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addProductToProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeProductFromProductSetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeProductFromProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listProductsInProductSetTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listProductsInProductSetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importProductSetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importProductSetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings purgeProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(purgeProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createProductSetCallable = + callableFactory.createUnaryCallable( + createProductSetTransportSettings, settings.createProductSetSettings(), clientContext); + this.listProductSetsCallable = + callableFactory.createUnaryCallable( + listProductSetsTransportSettings, settings.listProductSetsSettings(), clientContext); + this.listProductSetsPagedCallable = + callableFactory.createPagedCallable( + listProductSetsTransportSettings, settings.listProductSetsSettings(), clientContext); + this.getProductSetCallable = + callableFactory.createUnaryCallable( + getProductSetTransportSettings, settings.getProductSetSettings(), clientContext); + this.updateProductSetCallable = + callableFactory.createUnaryCallable( + updateProductSetTransportSettings, settings.updateProductSetSettings(), clientContext); + this.deleteProductSetCallable = + callableFactory.createUnaryCallable( + deleteProductSetTransportSettings, settings.deleteProductSetSettings(), clientContext); + this.createProductCallable = + callableFactory.createUnaryCallable( + createProductTransportSettings, settings.createProductSettings(), clientContext); + this.listProductsCallable = + callableFactory.createUnaryCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.listProductsPagedCallable = + callableFactory.createPagedCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.getProductCallable = + callableFactory.createUnaryCallable( + getProductTransportSettings, settings.getProductSettings(), clientContext); + this.updateProductCallable = + callableFactory.createUnaryCallable( + updateProductTransportSettings, settings.updateProductSettings(), clientContext); + this.deleteProductCallable = + callableFactory.createUnaryCallable( + deleteProductTransportSettings, settings.deleteProductSettings(), clientContext); + this.createReferenceImageCallable = + callableFactory.createUnaryCallable( + createReferenceImageTransportSettings, + settings.createReferenceImageSettings(), + clientContext); + this.deleteReferenceImageCallable = + callableFactory.createUnaryCallable( + deleteReferenceImageTransportSettings, + settings.deleteReferenceImageSettings(), + clientContext); + this.listReferenceImagesCallable = + callableFactory.createUnaryCallable( + listReferenceImagesTransportSettings, + settings.listReferenceImagesSettings(), + clientContext); + this.listReferenceImagesPagedCallable = + callableFactory.createPagedCallable( + listReferenceImagesTransportSettings, + settings.listReferenceImagesSettings(), + clientContext); + this.getReferenceImageCallable = + callableFactory.createUnaryCallable( + getReferenceImageTransportSettings, + settings.getReferenceImageSettings(), + clientContext); + this.addProductToProductSetCallable = + callableFactory.createUnaryCallable( + addProductToProductSetTransportSettings, + settings.addProductToProductSetSettings(), + clientContext); + this.removeProductFromProductSetCallable = + callableFactory.createUnaryCallable( + removeProductFromProductSetTransportSettings, + settings.removeProductFromProductSetSettings(), + clientContext); + this.listProductsInProductSetCallable = + callableFactory.createUnaryCallable( + listProductsInProductSetTransportSettings, + settings.listProductsInProductSetSettings(), + clientContext); + this.listProductsInProductSetPagedCallable = + callableFactory.createPagedCallable( + listProductsInProductSetTransportSettings, + settings.listProductsInProductSetSettings(), + clientContext); + this.importProductSetsCallable = + callableFactory.createUnaryCallable( + importProductSetsTransportSettings, + settings.importProductSetsSettings(), + clientContext); + this.importProductSetsOperationCallable = + callableFactory.createOperationCallable( + importProductSetsTransportSettings, + settings.importProductSetsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.purgeProductsCallable = + callableFactory.createUnaryCallable( + purgeProductsTransportSettings, settings.purgeProductsSettings(), clientContext); + this.purgeProductsOperationCallable = + callableFactory.createOperationCallable( + purgeProductsTransportSettings, + settings.purgeProductsOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createProductSetMethodDescriptor); + methodDescriptors.add(listProductSetsMethodDescriptor); + methodDescriptors.add(getProductSetMethodDescriptor); + methodDescriptors.add(updateProductSetMethodDescriptor); + methodDescriptors.add(deleteProductSetMethodDescriptor); + methodDescriptors.add(createProductMethodDescriptor); + methodDescriptors.add(listProductsMethodDescriptor); + methodDescriptors.add(getProductMethodDescriptor); + methodDescriptors.add(updateProductMethodDescriptor); + methodDescriptors.add(deleteProductMethodDescriptor); + methodDescriptors.add(createReferenceImageMethodDescriptor); + methodDescriptors.add(deleteReferenceImageMethodDescriptor); + methodDescriptors.add(listReferenceImagesMethodDescriptor); + methodDescriptors.add(getReferenceImageMethodDescriptor); + methodDescriptors.add(addProductToProductSetMethodDescriptor); + methodDescriptors.add(removeProductFromProductSetMethodDescriptor); + methodDescriptors.add(listProductsInProductSetMethodDescriptor); + methodDescriptors.add(importProductSetsMethodDescriptor); + methodDescriptors.add(purgeProductsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createProductSetCallable() { + return createProductSetCallable; + } + + @Override + public UnaryCallable listProductSetsCallable() { + return listProductSetsCallable; + } + + @Override + public UnaryCallable + listProductSetsPagedCallable() { + return listProductSetsPagedCallable; + } + + @Override + public UnaryCallable getProductSetCallable() { + return getProductSetCallable; + } + + @Override + public UnaryCallable updateProductSetCallable() { + return updateProductSetCallable; + } + + @Override + public UnaryCallable deleteProductSetCallable() { + return deleteProductSetCallable; + } + + @Override + public UnaryCallable createProductCallable() { + return createProductCallable; + } + + @Override + public UnaryCallable listProductsCallable() { + return listProductsCallable; + } + + @Override + public UnaryCallable listProductsPagedCallable() { + return listProductsPagedCallable; + } + + @Override + public UnaryCallable getProductCallable() { + return getProductCallable; + } + + @Override + public UnaryCallable updateProductCallable() { + return updateProductCallable; + } + + @Override + public UnaryCallable deleteProductCallable() { + return deleteProductCallable; + } + + @Override + public UnaryCallable createReferenceImageCallable() { + return createReferenceImageCallable; + } + + @Override + public UnaryCallable deleteReferenceImageCallable() { + return deleteReferenceImageCallable; + } + + @Override + public UnaryCallable + listReferenceImagesCallable() { + return listReferenceImagesCallable; + } + + @Override + public UnaryCallable + listReferenceImagesPagedCallable() { + return listReferenceImagesPagedCallable; + } + + @Override + public UnaryCallable getReferenceImageCallable() { + return getReferenceImageCallable; + } + + @Override + public UnaryCallable addProductToProductSetCallable() { + return addProductToProductSetCallable; + } + + @Override + public UnaryCallable + removeProductFromProductSetCallable() { + return removeProductFromProductSetCallable; + } + + @Override + public UnaryCallable + listProductsInProductSetCallable() { + return listProductsInProductSetCallable; + } + + @Override + public UnaryCallable + listProductsInProductSetPagedCallable() { + return listProductsInProductSetPagedCallable; + } + + @Override + public UnaryCallable importProductSetsCallable() { + return importProductSetsCallable; + } + + @Override + public OperationCallable< + ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> + importProductSetsOperationCallable() { + return importProductSetsOperationCallable; + } + + @Override + public UnaryCallable purgeProductsCallable() { + return purgeProductsCallable; + } + + @Override + public OperationCallable + purgeProductsOperationCallable() { + return purgeProductsOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ImageAnnotatorStub.java index 80cadb04e..8097b695f 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ImageAnnotatorStub.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ImageAnnotatorStub.java @@ -44,7 +44,11 @@ public abstract class ImageAnnotatorStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ImageAnnotatorStubSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ImageAnnotatorStubSettings.java index 25c2382d9..d604bd13b 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ImageAnnotatorStubSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ImageAnnotatorStubSettings.java @@ -25,6 +25,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -151,13 +154,17 @@ public class ImageAnnotatorStubSettings extends StubSettings createProductSetCallable() { diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ProductSearchStubSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ProductSearchStubSettings.java index df9a0200c..ecb4054b1 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ProductSearchStubSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p4beta1/stub/ProductSearchStubSettings.java @@ -31,6 +31,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -527,13 +530,17 @@ public UnaryCallSettings purgeProductsSettings( return purgeProductsOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ProductSearchStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcProductSearchStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonProductSearchStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -566,18 +573,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ProductSearchStubSettings.class)) @@ -585,11 +599,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ProductSearchStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ProductSearchStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -842,6 +875,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createProductSetSettings() diff --git a/google-cloud-vision/src/test/java/com/google/cloud/vision/v1/ImageAnnotatorClientHttpJsonTest.java b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1/ImageAnnotatorClientHttpJsonTest.java new file mode 100644 index 000000000..2abdc0914 --- /dev/null +++ b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1/ImageAnnotatorClientHttpJsonTest.java @@ -0,0 +1,267 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.vision.v1.stub.HttpJsonImageAnnotatorStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ImageAnnotatorClientHttpJsonTest { + private static MockHttpService mockService; + private static ImageAnnotatorClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonImageAnnotatorStub.getMethodDescriptors(), + ImageAnnotatorSettings.getDefaultEndpoint()); + ImageAnnotatorSettings settings = + ImageAnnotatorSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ImageAnnotatorClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void batchAnnotateImagesTest() throws Exception { + BatchAnnotateImagesResponse expectedResponse = + BatchAnnotateImagesResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + List requests = new ArrayList<>(); + + BatchAnnotateImagesResponse actualResponse = client.batchAnnotateImages(requests); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchAnnotateImagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + client.batchAnnotateImages(requests); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchAnnotateFilesTest() throws Exception { + BatchAnnotateFilesResponse expectedResponse = + BatchAnnotateFilesResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + List requests = new ArrayList<>(); + + BatchAnnotateFilesResponse actualResponse = client.batchAnnotateFiles(requests); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchAnnotateFilesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + client.batchAnnotateFiles(requests); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void asyncBatchAnnotateImagesTest() throws Exception { + AsyncBatchAnnotateImagesResponse expectedResponse = + AsyncBatchAnnotateImagesResponse.newBuilder() + .setOutputConfig(OutputConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("asyncBatchAnnotateImagesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + List requests = new ArrayList<>(); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + + AsyncBatchAnnotateImagesResponse actualResponse = + client.asyncBatchAnnotateImagesAsync(requests, outputConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void asyncBatchAnnotateImagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + client.asyncBatchAnnotateImagesAsync(requests, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void asyncBatchAnnotateFilesTest() throws Exception { + AsyncBatchAnnotateFilesResponse expectedResponse = + AsyncBatchAnnotateFilesResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("asyncBatchAnnotateFilesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + List requests = new ArrayList<>(); + + AsyncBatchAnnotateFilesResponse actualResponse = + client.asyncBatchAnnotateFilesAsync(requests).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void asyncBatchAnnotateFilesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + client.asyncBatchAnnotateFilesAsync(requests).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-vision/src/test/java/com/google/cloud/vision/v1/ProductSearchClientHttpJsonTest.java b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1/ProductSearchClientHttpJsonTest.java new file mode 100644 index 000000000..e28a2d689 --- /dev/null +++ b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1/ProductSearchClientHttpJsonTest.java @@ -0,0 +1,1991 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1; + +import static com.google.cloud.vision.v1.ProductSearchClient.ListProductSetsPagedResponse; +import static com.google.cloud.vision.v1.ProductSearchClient.ListProductsInProductSetPagedResponse; +import static com.google.cloud.vision.v1.ProductSearchClient.ListProductsPagedResponse; +import static com.google.cloud.vision.v1.ProductSearchClient.ListReferenceImagesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.vision.v1.stub.HttpJsonProductSearchStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ProductSearchClientHttpJsonTest { + private static MockHttpService mockService; + private static ProductSearchClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonProductSearchStub.getMethodDescriptors(), + ProductSearchSettings.getDefaultEndpoint()); + ProductSearchSettings settings = + ProductSearchSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ProductSearchSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ProductSearchClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createProductSetTest() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + + ProductSet actualResponse = client.createProductSet(parent, productSet, productSetId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + client.createProductSet(parent, productSet, productSetId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductSetTest2() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + + ProductSet actualResponse = client.createProductSet(parent, productSet, productSetId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + client.createProductSet(parent, productSet, productSetId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductSetsTest() throws Exception { + ProductSet responsesElement = ProductSet.newBuilder().build(); + ListProductSetsResponse expectedResponse = + ListProductSetsResponse.newBuilder() + .setNextPageToken("") + .addAllProductSets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListProductSetsPagedResponse pagedListResponse = client.listProductSets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductSetsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductSetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listProductSets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductSetsTest2() throws Exception { + ProductSet responsesElement = ProductSet.newBuilder().build(); + ListProductSetsResponse expectedResponse = + ListProductSetsResponse.newBuilder() + .setNextPageToken("") + .addAllProductSets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListProductSetsPagedResponse pagedListResponse = client.listProductSets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductSetsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductSetsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listProductSets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductSetTest() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + + ProductSet actualResponse = client.getProductSet(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + client.getProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductSetTest2() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + + ProductSet actualResponse = client.getProductSet(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + client.getProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateProductSetTest() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProductSet productSet = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ProductSet actualResponse = client.updateProductSet(productSet, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSet productSet = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateProductSet(productSet, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductSetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + + client.deleteProductSet(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + client.deleteProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductSetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + + client.deleteProductSet(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + client.deleteProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest2() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Product product = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Product actualResponse = client.updateProduct(product, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product product = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateProduct(product, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createReferenceImageTest() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + + ReferenceImage actualResponse = + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createReferenceImageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createReferenceImageTest2() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + + ReferenceImage actualResponse = + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createReferenceImageExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteReferenceImageTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + + client.deleteReferenceImage(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteReferenceImageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + client.deleteReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteReferenceImageTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + + client.deleteReferenceImage(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteReferenceImageExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + client.deleteReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listReferenceImagesTest() throws Exception { + ReferenceImage responsesElement = ReferenceImage.newBuilder().build(); + ListReferenceImagesResponse expectedResponse = + ListReferenceImagesResponse.newBuilder() + .setNextPageToken("") + .addAllReferenceImages(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + ListReferenceImagesPagedResponse pagedListResponse = client.listReferenceImages(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getReferenceImagesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listReferenceImagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.listReferenceImages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listReferenceImagesTest2() throws Exception { + ReferenceImage responsesElement = ReferenceImage.newBuilder().build(); + ListReferenceImagesResponse expectedResponse = + ListReferenceImagesResponse.newBuilder() + .setNextPageToken("") + .addAllReferenceImages(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + + ListReferenceImagesPagedResponse pagedListResponse = client.listReferenceImages(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getReferenceImagesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listReferenceImagesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + client.listReferenceImages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getReferenceImageTest() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + + ReferenceImage actualResponse = client.getReferenceImage(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getReferenceImageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + client.getReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getReferenceImageTest2() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + + ReferenceImage actualResponse = client.getReferenceImage(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getReferenceImageExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + client.getReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsInProductSetTest() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsInProductSetResponse expectedResponse = + ListProductsInProductSetResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + + ListProductsInProductSetPagedResponse pagedListResponse = client.listProductsInProductSet(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsInProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + client.listProductsInProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsInProductSetTest2() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsInProductSetResponse expectedResponse = + ListProductsInProductSetResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + + ListProductsInProductSetPagedResponse pagedListResponse = client.listProductsInProductSet(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsInProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + client.listProductsInProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importProductSetsTest() throws Exception { + ImportProductSetsResponse expectedResponse = + ImportProductSetsResponse.newBuilder() + .addAllReferenceImages(new ArrayList()) + .addAllStatuses(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductSetsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + + ImportProductSetsResponse actualResponse = + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importProductSetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importProductSetsTest2() throws Exception { + ImportProductSetsResponse expectedResponse = + ImportProductSetsResponse.newBuilder() + .addAllReferenceImages(new ArrayList()) + .addAllStatuses(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductSetsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + + ImportProductSetsResponse actualResponse = + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importProductSetsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void purgeProductsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + client.purgeProductsAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void purgeProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.purgeProductsAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void purgeProductsTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + + client.purgeProductsAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void purgeProductsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.purgeProductsAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorClientHttpJsonTest.java b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorClientHttpJsonTest.java new file mode 100644 index 000000000..f2dc9dfff --- /dev/null +++ b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorClientHttpJsonTest.java @@ -0,0 +1,118 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p1beta1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.vision.v1p1beta1.stub.HttpJsonImageAnnotatorStub; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ImageAnnotatorClientHttpJsonTest { + private static MockHttpService mockService; + private static ImageAnnotatorClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonImageAnnotatorStub.getMethodDescriptors(), + ImageAnnotatorSettings.getDefaultEndpoint()); + ImageAnnotatorSettings settings = + ImageAnnotatorSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ImageAnnotatorClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void batchAnnotateImagesTest() throws Exception { + BatchAnnotateImagesResponse expectedResponse = + BatchAnnotateImagesResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + List requests = new ArrayList<>(); + + BatchAnnotateImagesResponse actualResponse = client.batchAnnotateImages(requests); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchAnnotateImagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + client.batchAnnotateImages(requests); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorClientHttpJsonTest.java b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorClientHttpJsonTest.java new file mode 100644 index 000000000..345c3ad70 --- /dev/null +++ b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorClientHttpJsonTest.java @@ -0,0 +1,171 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.vision.v1p2beta1.stub.HttpJsonImageAnnotatorStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ImageAnnotatorClientHttpJsonTest { + private static MockHttpService mockService; + private static ImageAnnotatorClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonImageAnnotatorStub.getMethodDescriptors(), + ImageAnnotatorSettings.getDefaultEndpoint()); + ImageAnnotatorSettings settings = + ImageAnnotatorSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ImageAnnotatorClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void batchAnnotateImagesTest() throws Exception { + BatchAnnotateImagesResponse expectedResponse = + BatchAnnotateImagesResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + List requests = new ArrayList<>(); + + BatchAnnotateImagesResponse actualResponse = client.batchAnnotateImages(requests); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchAnnotateImagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + client.batchAnnotateImages(requests); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void asyncBatchAnnotateFilesTest() throws Exception { + AsyncBatchAnnotateFilesResponse expectedResponse = + AsyncBatchAnnotateFilesResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("asyncBatchAnnotateFilesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + List requests = new ArrayList<>(); + + AsyncBatchAnnotateFilesResponse actualResponse = + client.asyncBatchAnnotateFilesAsync(requests).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void asyncBatchAnnotateFilesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + client.asyncBatchAnnotateFilesAsync(requests).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p3beta1/ImageAnnotatorClientHttpJsonTest.java b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p3beta1/ImageAnnotatorClientHttpJsonTest.java new file mode 100644 index 000000000..6cd55ee1f --- /dev/null +++ b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p3beta1/ImageAnnotatorClientHttpJsonTest.java @@ -0,0 +1,171 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.vision.v1p3beta1.stub.HttpJsonImageAnnotatorStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ImageAnnotatorClientHttpJsonTest { + private static MockHttpService mockService; + private static ImageAnnotatorClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonImageAnnotatorStub.getMethodDescriptors(), + ImageAnnotatorSettings.getDefaultEndpoint()); + ImageAnnotatorSettings settings = + ImageAnnotatorSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ImageAnnotatorClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void batchAnnotateImagesTest() throws Exception { + BatchAnnotateImagesResponse expectedResponse = + BatchAnnotateImagesResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + List requests = new ArrayList<>(); + + BatchAnnotateImagesResponse actualResponse = client.batchAnnotateImages(requests); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchAnnotateImagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + client.batchAnnotateImages(requests); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void asyncBatchAnnotateFilesTest() throws Exception { + AsyncBatchAnnotateFilesResponse expectedResponse = + AsyncBatchAnnotateFilesResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("asyncBatchAnnotateFilesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + List requests = new ArrayList<>(); + + AsyncBatchAnnotateFilesResponse actualResponse = + client.asyncBatchAnnotateFilesAsync(requests).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void asyncBatchAnnotateFilesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + client.asyncBatchAnnotateFilesAsync(requests).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p3beta1/ProductSearchClientHttpJsonTest.java b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p3beta1/ProductSearchClientHttpJsonTest.java new file mode 100644 index 000000000..57159bb8a --- /dev/null +++ b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p3beta1/ProductSearchClientHttpJsonTest.java @@ -0,0 +1,1901 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1; + +import static com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductSetsPagedResponse; +import static com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductsInProductSetPagedResponse; +import static com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductsPagedResponse; +import static com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListReferenceImagesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.vision.v1p3beta1.stub.HttpJsonProductSearchStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ProductSearchClientHttpJsonTest { + private static MockHttpService mockService; + private static ProductSearchClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonProductSearchStub.getMethodDescriptors(), + ProductSearchSettings.getDefaultEndpoint()); + ProductSearchSettings settings = + ProductSearchSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ProductSearchSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ProductSearchClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createProductSetTest() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + + ProductSet actualResponse = client.createProductSet(parent, productSet, productSetId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + client.createProductSet(parent, productSet, productSetId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductSetTest2() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + + ProductSet actualResponse = client.createProductSet(parent, productSet, productSetId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + client.createProductSet(parent, productSet, productSetId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductSetsTest() throws Exception { + ProductSet responsesElement = ProductSet.newBuilder().build(); + ListProductSetsResponse expectedResponse = + ListProductSetsResponse.newBuilder() + .setNextPageToken("") + .addAllProductSets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListProductSetsPagedResponse pagedListResponse = client.listProductSets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductSetsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductSetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listProductSets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductSetsTest2() throws Exception { + ProductSet responsesElement = ProductSet.newBuilder().build(); + ListProductSetsResponse expectedResponse = + ListProductSetsResponse.newBuilder() + .setNextPageToken("") + .addAllProductSets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListProductSetsPagedResponse pagedListResponse = client.listProductSets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductSetsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductSetsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listProductSets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductSetTest() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + + ProductSet actualResponse = client.getProductSet(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + client.getProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductSetTest2() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + + ProductSet actualResponse = client.getProductSet(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + client.getProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateProductSetTest() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProductSet productSet = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ProductSet actualResponse = client.updateProductSet(productSet, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSet productSet = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateProductSet(productSet, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductSetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + + client.deleteProductSet(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + client.deleteProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductSetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + + client.deleteProductSet(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + client.deleteProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest2() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Product product = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Product actualResponse = client.updateProduct(product, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product product = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateProduct(product, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createReferenceImageTest() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + + ReferenceImage actualResponse = + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createReferenceImageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createReferenceImageTest2() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + + ReferenceImage actualResponse = + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createReferenceImageExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteReferenceImageTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + + client.deleteReferenceImage(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteReferenceImageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + client.deleteReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteReferenceImageTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + + client.deleteReferenceImage(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteReferenceImageExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + client.deleteReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listReferenceImagesTest() throws Exception { + ReferenceImage responsesElement = ReferenceImage.newBuilder().build(); + ListReferenceImagesResponse expectedResponse = + ListReferenceImagesResponse.newBuilder() + .setNextPageToken("") + .addAllReferenceImages(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + ListReferenceImagesPagedResponse pagedListResponse = client.listReferenceImages(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getReferenceImagesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listReferenceImagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.listReferenceImages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listReferenceImagesTest2() throws Exception { + ReferenceImage responsesElement = ReferenceImage.newBuilder().build(); + ListReferenceImagesResponse expectedResponse = + ListReferenceImagesResponse.newBuilder() + .setNextPageToken("") + .addAllReferenceImages(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + + ListReferenceImagesPagedResponse pagedListResponse = client.listReferenceImages(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getReferenceImagesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listReferenceImagesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + client.listReferenceImages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getReferenceImageTest() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + + ReferenceImage actualResponse = client.getReferenceImage(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getReferenceImageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + client.getReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getReferenceImageTest2() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + + ReferenceImage actualResponse = client.getReferenceImage(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getReferenceImageExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + client.getReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsInProductSetTest() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsInProductSetResponse expectedResponse = + ListProductsInProductSetResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + + ListProductsInProductSetPagedResponse pagedListResponse = client.listProductsInProductSet(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsInProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + client.listProductsInProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsInProductSetTest2() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsInProductSetResponse expectedResponse = + ListProductsInProductSetResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + + ListProductsInProductSetPagedResponse pagedListResponse = client.listProductsInProductSet(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsInProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + client.listProductsInProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importProductSetsTest() throws Exception { + ImportProductSetsResponse expectedResponse = + ImportProductSetsResponse.newBuilder() + .addAllReferenceImages(new ArrayList()) + .addAllStatuses(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductSetsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + + ImportProductSetsResponse actualResponse = + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importProductSetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importProductSetsTest2() throws Exception { + ImportProductSetsResponse expectedResponse = + ImportProductSetsResponse.newBuilder() + .addAllReferenceImages(new ArrayList()) + .addAllStatuses(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductSetsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + + ImportProductSetsResponse actualResponse = + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importProductSetsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p4beta1/ImageAnnotatorClientHttpJsonTest.java b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p4beta1/ImageAnnotatorClientHttpJsonTest.java new file mode 100644 index 000000000..f6c37238b --- /dev/null +++ b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p4beta1/ImageAnnotatorClientHttpJsonTest.java @@ -0,0 +1,267 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.vision.v1p4beta1.stub.HttpJsonImageAnnotatorStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ImageAnnotatorClientHttpJsonTest { + private static MockHttpService mockService; + private static ImageAnnotatorClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonImageAnnotatorStub.getMethodDescriptors(), + ImageAnnotatorSettings.getDefaultEndpoint()); + ImageAnnotatorSettings settings = + ImageAnnotatorSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ImageAnnotatorClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void batchAnnotateImagesTest() throws Exception { + BatchAnnotateImagesResponse expectedResponse = + BatchAnnotateImagesResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + List requests = new ArrayList<>(); + + BatchAnnotateImagesResponse actualResponse = client.batchAnnotateImages(requests); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchAnnotateImagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + client.batchAnnotateImages(requests); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchAnnotateFilesTest() throws Exception { + BatchAnnotateFilesResponse expectedResponse = + BatchAnnotateFilesResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + List requests = new ArrayList<>(); + + BatchAnnotateFilesResponse actualResponse = client.batchAnnotateFiles(requests); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchAnnotateFilesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + client.batchAnnotateFiles(requests); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void asyncBatchAnnotateImagesTest() throws Exception { + AsyncBatchAnnotateImagesResponse expectedResponse = + AsyncBatchAnnotateImagesResponse.newBuilder() + .setOutputConfig(OutputConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("asyncBatchAnnotateImagesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + List requests = new ArrayList<>(); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + + AsyncBatchAnnotateImagesResponse actualResponse = + client.asyncBatchAnnotateImagesAsync(requests, outputConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void asyncBatchAnnotateImagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + client.asyncBatchAnnotateImagesAsync(requests, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void asyncBatchAnnotateFilesTest() throws Exception { + AsyncBatchAnnotateFilesResponse expectedResponse = + AsyncBatchAnnotateFilesResponse.newBuilder() + .addAllResponses(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("asyncBatchAnnotateFilesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + List requests = new ArrayList<>(); + + AsyncBatchAnnotateFilesResponse actualResponse = + client.asyncBatchAnnotateFilesAsync(requests).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void asyncBatchAnnotateFilesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List requests = new ArrayList<>(); + client.asyncBatchAnnotateFilesAsync(requests).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p4beta1/ProductSearchClientHttpJsonTest.java b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p4beta1/ProductSearchClientHttpJsonTest.java new file mode 100644 index 000000000..f4805121c --- /dev/null +++ b/google-cloud-vision/src/test/java/com/google/cloud/vision/v1p4beta1/ProductSearchClientHttpJsonTest.java @@ -0,0 +1,1991 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1; + +import static com.google.cloud.vision.v1p4beta1.ProductSearchClient.ListProductSetsPagedResponse; +import static com.google.cloud.vision.v1p4beta1.ProductSearchClient.ListProductsInProductSetPagedResponse; +import static com.google.cloud.vision.v1p4beta1.ProductSearchClient.ListProductsPagedResponse; +import static com.google.cloud.vision.v1p4beta1.ProductSearchClient.ListReferenceImagesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.vision.v1p4beta1.stub.HttpJsonProductSearchStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ProductSearchClientHttpJsonTest { + private static MockHttpService mockService; + private static ProductSearchClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonProductSearchStub.getMethodDescriptors(), + ProductSearchSettings.getDefaultEndpoint()); + ProductSearchSettings settings = + ProductSearchSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ProductSearchSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ProductSearchClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createProductSetTest() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + + ProductSet actualResponse = client.createProductSet(parent, productSet, productSetId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + client.createProductSet(parent, productSet, productSetId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductSetTest2() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + + ProductSet actualResponse = client.createProductSet(parent, productSet, productSetId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + client.createProductSet(parent, productSet, productSetId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductSetsTest() throws Exception { + ProductSet responsesElement = ProductSet.newBuilder().build(); + ListProductSetsResponse expectedResponse = + ListProductSetsResponse.newBuilder() + .setNextPageToken("") + .addAllProductSets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListProductSetsPagedResponse pagedListResponse = client.listProductSets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductSetsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductSetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listProductSets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductSetsTest2() throws Exception { + ProductSet responsesElement = ProductSet.newBuilder().build(); + ListProductSetsResponse expectedResponse = + ListProductSetsResponse.newBuilder() + .setNextPageToken("") + .addAllProductSets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListProductSetsPagedResponse pagedListResponse = client.listProductSets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductSetsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductSetsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listProductSets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductSetTest() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + + ProductSet actualResponse = client.getProductSet(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + client.getProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductSetTest2() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + + ProductSet actualResponse = client.getProductSet(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + client.getProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateProductSetTest() throws Exception { + ProductSet expectedResponse = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProductSet productSet = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ProductSet actualResponse = client.updateProductSet(productSet, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSet productSet = + ProductSet.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setDisplayName("displayName1714148973") + .setIndexTime(Timestamp.newBuilder().build()) + .setIndexError(Status.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateProductSet(productSet, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductSetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + + client.deleteProductSet(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + client.deleteProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductSetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + + client.deleteProductSet(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + client.deleteProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest2() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Product product = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Product actualResponse = client.updateProduct(product, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product product = + Product.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setProductCategory("productCategory197299981") + .addAllProductLabels(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateProduct(product, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4324/locations/location-4324/products/product-4324"; + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createReferenceImageTest() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + + ReferenceImage actualResponse = + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createReferenceImageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createReferenceImageTest2() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + + ReferenceImage actualResponse = + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createReferenceImageExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + client.createReferenceImage(parent, referenceImage, referenceImageId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteReferenceImageTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + + client.deleteReferenceImage(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteReferenceImageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + client.deleteReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteReferenceImageTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + + client.deleteReferenceImage(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteReferenceImageExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + client.deleteReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listReferenceImagesTest() throws Exception { + ReferenceImage responsesElement = ReferenceImage.newBuilder().build(); + ListReferenceImagesResponse expectedResponse = + ListReferenceImagesResponse.newBuilder() + .setNextPageToken("") + .addAllReferenceImages(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + ListReferenceImagesPagedResponse pagedListResponse = client.listReferenceImages(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getReferenceImagesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listReferenceImagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.listReferenceImages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listReferenceImagesTest2() throws Exception { + ReferenceImage responsesElement = ReferenceImage.newBuilder().build(); + ListReferenceImagesResponse expectedResponse = + ListReferenceImagesResponse.newBuilder() + .setNextPageToken("") + .addAllReferenceImages(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + + ListReferenceImagesPagedResponse pagedListResponse = client.listReferenceImages(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getReferenceImagesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listReferenceImagesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-7253/locations/location-7253/products/product-7253"; + client.listReferenceImages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getReferenceImageTest() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + + ReferenceImage actualResponse = client.getReferenceImage(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getReferenceImageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + client.getReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getReferenceImageTest2() throws Exception { + ReferenceImage expectedResponse = + ReferenceImage.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .setUri("uri116076") + .addAllBoundingPolys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + + ReferenceImage actualResponse = client.getReferenceImage(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getReferenceImageExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-61/locations/location-61/products/product-61/referenceImages/referenceImage-61"; + client.getReferenceImage(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addProductToProductSetTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + + client.addProductToProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addProductToProductSetExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + client.addProductToProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = "product-309474065"; + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeProductFromProductSetTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + + client.removeProductFromProductSet(name, product); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeProductFromProductSetExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + String product = "product-309474065"; + client.removeProductFromProductSet(name, product); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsInProductSetTest() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsInProductSetResponse expectedResponse = + ListProductsInProductSetResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + + ListProductsInProductSetPagedResponse pagedListResponse = client.listProductsInProductSet(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsInProductSetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + client.listProductsInProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsInProductSetTest2() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsInProductSetResponse expectedResponse = + ListProductsInProductSetResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + + ListProductsInProductSetPagedResponse pagedListResponse = client.listProductsInProductSet(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsInProductSetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7514/locations/location-7514/productSets/productSet-7514"; + client.listProductsInProductSet(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importProductSetsTest() throws Exception { + ImportProductSetsResponse expectedResponse = + ImportProductSetsResponse.newBuilder() + .addAllReferenceImages(new ArrayList()) + .addAllStatuses(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductSetsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + + ImportProductSetsResponse actualResponse = + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importProductSetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importProductSetsTest2() throws Exception { + ImportProductSetsResponse expectedResponse = + ImportProductSetsResponse.newBuilder() + .addAllReferenceImages(new ArrayList()) + .addAllStatuses(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductSetsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + + ImportProductSetsResponse actualResponse = + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importProductSetsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + client.importProductSetsAsync(parent, inputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void purgeProductsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + client.purgeProductsAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void purgeProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.purgeProductsAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void purgeProductsTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + + client.purgeProductsAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void purgeProductsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.purgeProductsAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/BatchAnnotateFilesRequest.java b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/BatchAnnotateFilesRequest.java index b3b864bab..7b4419806 100644 --- a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/BatchAnnotateFilesRequest.java +++ b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/BatchAnnotateFilesRequest.java @@ -136,8 +136,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * *

-   * Required. The list of file annotation requests. Right now we support only
-   * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+   * Required. The list of file annotation requests. Right now we support only one
+   * AnnotateFileRequest in BatchAnnotateFilesRequest.
    * 
* * @@ -152,8 +152,8 @@ public java.util.List getRequest * * *
-   * Required. The list of file annotation requests. Right now we support only
-   * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+   * Required. The list of file annotation requests. Right now we support only one
+   * AnnotateFileRequest in BatchAnnotateFilesRequest.
    * 
* * @@ -169,8 +169,8 @@ public java.util.List getRequest * * *
-   * Required. The list of file annotation requests. Right now we support only
-   * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+   * Required. The list of file annotation requests. Right now we support only one
+   * AnnotateFileRequest in BatchAnnotateFilesRequest.
    * 
* * @@ -185,8 +185,8 @@ public int getRequestsCount() { * * *
-   * Required. The list of file annotation requests. Right now we support only
-   * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+   * Required. The list of file annotation requests. Right now we support only one
+   * AnnotateFileRequest in BatchAnnotateFilesRequest.
    * 
* * @@ -201,8 +201,8 @@ public com.google.cloud.vision.v1.AnnotateFileRequest getRequests(int index) { * * *
-   * Required. The list of file annotation requests. Right now we support only
-   * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+   * Required. The list of file annotation requests. Right now we support only one
+   * AnnotateFileRequest in BatchAnnotateFilesRequest.
    * 
* * @@ -674,8 +674,8 @@ private void ensureRequestsIsMutable() { * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -693,8 +693,8 @@ public java.util.List getRequest * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -712,8 +712,8 @@ public int getRequestsCount() { * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -731,8 +731,8 @@ public com.google.cloud.vision.v1.AnnotateFileRequest getRequests(int index) { * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -756,8 +756,8 @@ public Builder setRequests(int index, com.google.cloud.vision.v1.AnnotateFileReq * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -779,8 +779,8 @@ public Builder setRequests( * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -804,8 +804,8 @@ public Builder addRequests(com.google.cloud.vision.v1.AnnotateFileRequest value) * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -829,8 +829,8 @@ public Builder addRequests(int index, com.google.cloud.vision.v1.AnnotateFileReq * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -852,8 +852,8 @@ public Builder addRequests( * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -875,8 +875,8 @@ public Builder addRequests( * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -898,8 +898,8 @@ public Builder addAllRequests( * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -920,8 +920,8 @@ public Builder clearRequests() { * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -942,8 +942,8 @@ public Builder removeRequests(int index) { * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -957,8 +957,8 @@ public com.google.cloud.vision.v1.AnnotateFileRequest.Builder getRequestsBuilder * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -976,8 +976,8 @@ public com.google.cloud.vision.v1.AnnotateFileRequestOrBuilder getRequestsOrBuil * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -996,8 +996,8 @@ public com.google.cloud.vision.v1.AnnotateFileRequestOrBuilder getRequestsOrBuil * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -1012,8 +1012,8 @@ public com.google.cloud.vision.v1.AnnotateFileRequest.Builder addRequestsBuilder * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * @@ -1028,8 +1028,8 @@ public com.google.cloud.vision.v1.AnnotateFileRequest.Builder addRequestsBuilder * * *
-     * Required. The list of file annotation requests. Right now we support only
-     * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+     * Required. The list of file annotation requests. Right now we support only one
+     * AnnotateFileRequest in BatchAnnotateFilesRequest.
      * 
* * diff --git a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/BatchAnnotateFilesRequestOrBuilder.java b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/BatchAnnotateFilesRequestOrBuilder.java index 3aec31a48..59b062994 100644 --- a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/BatchAnnotateFilesRequestOrBuilder.java +++ b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/BatchAnnotateFilesRequestOrBuilder.java @@ -27,8 +27,8 @@ public interface BatchAnnotateFilesRequestOrBuilder * * *
-   * Required. The list of file annotation requests. Right now we support only
-   * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+   * Required. The list of file annotation requests. Right now we support only one
+   * AnnotateFileRequest in BatchAnnotateFilesRequest.
    * 
* * @@ -40,8 +40,8 @@ public interface BatchAnnotateFilesRequestOrBuilder * * *
-   * Required. The list of file annotation requests. Right now we support only
-   * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+   * Required. The list of file annotation requests. Right now we support only one
+   * AnnotateFileRequest in BatchAnnotateFilesRequest.
    * 
* * @@ -53,8 +53,8 @@ public interface BatchAnnotateFilesRequestOrBuilder * * *
-   * Required. The list of file annotation requests. Right now we support only
-   * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+   * Required. The list of file annotation requests. Right now we support only one
+   * AnnotateFileRequest in BatchAnnotateFilesRequest.
    * 
* * @@ -66,8 +66,8 @@ public interface BatchAnnotateFilesRequestOrBuilder * * *
-   * Required. The list of file annotation requests. Right now we support only
-   * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+   * Required. The list of file annotation requests. Right now we support only one
+   * AnnotateFileRequest in BatchAnnotateFilesRequest.
    * 
* * @@ -80,8 +80,8 @@ public interface BatchAnnotateFilesRequestOrBuilder * * *
-   * Required. The list of file annotation requests. Right now we support only
-   * one AnnotateFileRequest in BatchAnnotateFilesRequest.
+   * Required. The list of file annotation requests. Right now we support only one
+   * AnnotateFileRequest in BatchAnnotateFilesRequest.
    * 
* * diff --git a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/EntityAnnotation.java b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/EntityAnnotation.java index 3dcc04b19..d699fcc13 100644 --- a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/EntityAnnotation.java +++ b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/EntityAnnotation.java @@ -378,7 +378,7 @@ public float getScore() { * float confidence = 5 [deprecated = true]; * * @deprecated google.cloud.vision.v1.EntityAnnotation.confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=509 + * google/cloud/vision/v1/image_annotator.proto;l=505 * @return The confidence. */ @java.lang.Override @@ -1559,7 +1559,7 @@ public Builder clearScore() { * float confidence = 5 [deprecated = true]; * * @deprecated google.cloud.vision.v1.EntityAnnotation.confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=509 + * google/cloud/vision/v1/image_annotator.proto;l=505 * @return The confidence. */ @java.lang.Override @@ -1581,7 +1581,7 @@ public float getConfidence() { * float confidence = 5 [deprecated = true]; * * @deprecated google.cloud.vision.v1.EntityAnnotation.confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=509 + * google/cloud/vision/v1/image_annotator.proto;l=505 * @param value The confidence to set. * @return This builder for chaining. */ @@ -1606,7 +1606,7 @@ public Builder setConfidence(float value) { * float confidence = 5 [deprecated = true]; * * @deprecated google.cloud.vision.v1.EntityAnnotation.confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=509 + * google/cloud/vision/v1/image_annotator.proto;l=505 * @return This builder for chaining. */ @java.lang.Deprecated diff --git a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/EntityAnnotationOrBuilder.java b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/EntityAnnotationOrBuilder.java index 812d8fefa..979005b27 100644 --- a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/EntityAnnotationOrBuilder.java +++ b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/EntityAnnotationOrBuilder.java @@ -131,7 +131,7 @@ public interface EntityAnnotationOrBuilder * float confidence = 5 [deprecated = true]; * * @deprecated google.cloud.vision.v1.EntityAnnotation.confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=509 + * google/cloud/vision/v1/image_annotator.proto;l=505 * @return The confidence. */ @java.lang.Deprecated diff --git a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorProto.java b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorProto.java index 0a8524c0e..d5f7e4f6e 100644 --- a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorProto.java +++ b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorProto.java @@ -280,174 +280,169 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "on\022\013\n\003mid\030\001 \001(\t\022\025\n\rlanguage_code\030\002 \001(\t\022\014" + "\n\004name\030\003 \001(\t\022\r\n\005score\030\004 \001(\002\022;\n\rbounding_" + "poly\030\005 \001(\0132$.google.cloud.vision.v1.Boun" - + "dingPoly\"\320\003\n\024SafeSearchAnnotation\0221\n\005adu" + + "dingPoly\"\231\002\n\024SafeSearchAnnotation\0221\n\005adu" + "lt\030\001 \001(\0162\".google.cloud.vision.v1.Likeli" + "hood\0221\n\005spoof\030\002 \001(\0162\".google.cloud.visio" + "n.v1.Likelihood\0223\n\007medical\030\003 \001(\0162\".googl" + "e.cloud.vision.v1.Likelihood\0224\n\010violence" + "\030\004 \001(\0162\".google.cloud.vision.v1.Likeliho" + "od\0220\n\004racy\030\t \001(\0162\".google.cloud.vision.v" - + "1.Likelihood\022\034\n\020adult_confidence\030\020 \001(\002B\002" - + "\030\001\022\034\n\020spoof_confidence\030\022 \001(\002B\002\030\001\022\036\n\022medi" - + "cal_confidence\030\024 \001(\002B\002\030\001\022\037\n\023violence_con" - + "fidence\030\026 \001(\002B\002\030\001\022\033\n\017racy_confidence\030\030 \001" - + "(\002B\002\030\001\022\033\n\017nsfw_confidence\030\032 \001(\002B\002\030\001\"a\n\013L" - + "atLongRect\022(\n\013min_lat_lng\030\001 \001(\0132\023.google" - + ".type.LatLng\022(\n\013max_lat_lng\030\002 \001(\0132\023.goog" - + "le.type.LatLng\"U\n\tColorInfo\022!\n\005color\030\001 \001" - + "(\0132\022.google.type.Color\022\r\n\005score\030\002 \001(\002\022\026\n" - + "\016pixel_fraction\030\003 \001(\002\"M\n\030DominantColorsA" - + "nnotation\0221\n\006colors\030\001 \003(\0132!.google.cloud" - + ".vision.v1.ColorInfo\"\\\n\017ImageProperties\022" - + "I\n\017dominant_colors\030\001 \001(\01320.google.cloud." - + "vision.v1.DominantColorsAnnotation\"x\n\010Cr" - + "opHint\022;\n\rbounding_poly\030\001 \001(\0132$.google.c" - + "loud.vision.v1.BoundingPoly\022\022\n\nconfidenc" - + "e\030\002 \001(\002\022\033\n\023importance_fraction\030\003 \001(\002\"K\n\023" - + "CropHintsAnnotation\0224\n\ncrop_hints\030\001 \003(\0132" - + " .google.cloud.vision.v1.CropHint\"(\n\017Cro" - + "pHintsParams\022\025\n\raspect_ratios\030\001 \003(\002\"1\n\022W" - + "ebDetectionParams\022\033\n\023include_geo_results" - + "\030\002 \001(\010\"E\n\023TextDetectionParams\022.\n&enable_" - + "text_detection_confidence_score\030\t \001(\010\"\210\003" - + "\n\014ImageContext\022:\n\rlat_long_rect\030\001 \001(\0132#." - + "google.cloud.vision.v1.LatLongRect\022\026\n\016la" - + "nguage_hints\030\002 \003(\t\022B\n\021crop_hints_params\030" - + "\004 \001(\0132\'.google.cloud.vision.v1.CropHints" - + "Params\022J\n\025product_search_params\030\005 \001(\0132+." - + "google.cloud.vision.v1.ProductSearchPara" - + "ms\022H\n\024web_detection_params\030\006 \001(\0132*.googl" - + "e.cloud.vision.v1.WebDetectionParams\022J\n\025" - + "text_detection_params\030\014 \001(\0132+.google.clo" - + "ud.vision.v1.TextDetectionParams\"\264\001\n\024Ann" - + "otateImageRequest\022,\n\005image\030\001 \001(\0132\035.googl" - + "e.cloud.vision.v1.Image\0221\n\010features\030\002 \003(" - + "\0132\037.google.cloud.vision.v1.Feature\022;\n\rim" - + "age_context\030\003 \001(\0132$.google.cloud.vision." - + "v1.ImageContext\":\n\026ImageAnnotationContex" - + "t\022\013\n\003uri\030\001 \001(\t\022\023\n\013page_number\030\002 \001(\005\"\344\007\n\025" - + "AnnotateImageResponse\022@\n\020face_annotation" - + "s\030\001 \003(\0132&.google.cloud.vision.v1.FaceAnn" - + "otation\022F\n\024landmark_annotations\030\002 \003(\0132(." - + "google.cloud.vision.v1.EntityAnnotation\022" - + "B\n\020logo_annotations\030\003 \003(\0132(.google.cloud" - + ".vision.v1.EntityAnnotation\022C\n\021label_ann" - + "otations\030\004 \003(\0132(.google.cloud.vision.v1." - + "EntityAnnotation\022W\n\034localized_object_ann" - + "otations\030\026 \003(\01321.google.cloud.vision.v1." - + "LocalizedObjectAnnotation\022B\n\020text_annota" - + "tions\030\005 \003(\0132(.google.cloud.vision.v1.Ent" - + "ityAnnotation\022D\n\024full_text_annotation\030\014 " - + "\001(\0132&.google.cloud.vision.v1.TextAnnotat" - + "ion\022L\n\026safe_search_annotation\030\006 \001(\0132,.go" - + "ogle.cloud.vision.v1.SafeSearchAnnotatio" - + "n\022L\n\033image_properties_annotation\030\010 \001(\0132\'" - + ".google.cloud.vision.v1.ImageProperties\022" - + "J\n\025crop_hints_annotation\030\013 \001(\0132+.google." - + "cloud.vision.v1.CropHintsAnnotation\022;\n\rw" - + "eb_detection\030\r \001(\0132$.google.cloud.vision" - + ".v1.WebDetection\022L\n\026product_search_resul" - + "ts\030\016 \001(\0132,.google.cloud.vision.v1.Produc" - + "tSearchResults\022!\n\005error\030\t \001(\0132\022.google.r" - + "pc.Status\022?\n\007context\030\025 \001(\0132..google.clou" - + "d.vision.v1.ImageAnnotationContext\"q\n\032Ba" - + "tchAnnotateImagesRequest\022C\n\010requests\030\001 \003" - + "(\0132,.google.cloud.vision.v1.AnnotateImag" - + "eRequestB\003\340A\002\022\016\n\006parent\030\004 \001(\t\"_\n\033BatchAn" - + "notateImagesResponse\022@\n\tresponses\030\001 \003(\0132" - + "-.google.cloud.vision.v1.AnnotateImageRe" - + "sponse\"\317\001\n\023AnnotateFileRequest\0229\n\014input_" - + "config\030\001 \001(\0132#.google.cloud.vision.v1.In" - + "putConfig\0221\n\010features\030\002 \003(\0132\037.google.clo" - + "ud.vision.v1.Feature\022;\n\rimage_context\030\003 " - + "\001(\0132$.google.cloud.vision.v1.ImageContex" - + "t\022\r\n\005pages\030\004 \003(\005\"\313\001\n\024AnnotateFileRespons" - + "e\0229\n\014input_config\030\001 \001(\0132#.google.cloud.v" - + "ision.v1.InputConfig\022@\n\tresponses\030\002 \003(\0132" - + "-.google.cloud.vision.v1.AnnotateImageRe" - + "sponse\022\023\n\013total_pages\030\003 \001(\005\022!\n\005error\030\004 \001" - + "(\0132\022.google.rpc.Status\"o\n\031BatchAnnotateF" - + "ilesRequest\022B\n\010requests\030\001 \003(\0132+.google.c" - + "loud.vision.v1.AnnotateFileRequestB\003\340A\002\022" - + "\016\n\006parent\030\003 \001(\t\"]\n\032BatchAnnotateFilesRes" - + "ponse\022?\n\tresponses\030\001 \003(\0132,.google.cloud." - + "vision.v1.AnnotateFileResponse\"\202\002\n\030Async" - + "AnnotateFileRequest\0229\n\014input_config\030\001 \001(" - + "\0132#.google.cloud.vision.v1.InputConfig\0221" - + "\n\010features\030\002 \003(\0132\037.google.cloud.vision.v" - + "1.Feature\022;\n\rimage_context\030\003 \001(\0132$.googl" - + "e.cloud.vision.v1.ImageContext\022;\n\routput" - + "_config\030\004 \001(\0132$.google.cloud.vision.v1.O" - + "utputConfig\"X\n\031AsyncAnnotateFileResponse" - + "\022;\n\routput_config\030\001 \001(\0132$.google.cloud.v" - + "ision.v1.OutputConfig\"\270\001\n\037AsyncBatchAnno" - + "tateImagesRequest\022C\n\010requests\030\001 \003(\0132,.go" - + "ogle.cloud.vision.v1.AnnotateImageReques" - + "tB\003\340A\002\022@\n\routput_config\030\002 \001(\0132$.google.c" - + "loud.vision.v1.OutputConfigB\003\340A\002\022\016\n\006pare" - + "nt\030\004 \001(\t\"_\n AsyncBatchAnnotateImagesResp" - + "onse\022;\n\routput_config\030\001 \001(\0132$.google.clo" - + "ud.vision.v1.OutputConfig\"y\n\036AsyncBatchA" - + "nnotateFilesRequest\022G\n\010requests\030\001 \003(\01320." - + "google.cloud.vision.v1.AsyncAnnotateFile" - + "RequestB\003\340A\002\022\016\n\006parent\030\004 \001(\t\"g\n\037AsyncBat" - + "chAnnotateFilesResponse\022D\n\tresponses\030\001 \003" - + "(\01321.google.cloud.vision.v1.AsyncAnnotat" - + "eFileResponse\"h\n\013InputConfig\0225\n\ngcs_sour" - + "ce\030\001 \001(\0132!.google.cloud.vision.v1.GcsSou" - + "rce\022\017\n\007content\030\003 \001(\014\022\021\n\tmime_type\030\002 \001(\t\"" - + "c\n\014OutputConfig\022?\n\017gcs_destination\030\001 \001(\013" - + "2&.google.cloud.vision.v1.GcsDestination" - + "\022\022\n\nbatch_size\030\002 \001(\005\"\030\n\tGcsSource\022\013\n\003uri" - + "\030\001 \001(\t\"\035\n\016GcsDestination\022\013\n\003uri\030\001 \001(\t\"\210\002" - + "\n\021OperationMetadata\022>\n\005state\030\001 \001(\0162/.goo" - + "gle.cloud.vision.v1.OperationMetadata.St" - + "ate\022/\n\013create_time\030\005 \001(\0132\032.google.protob" - + "uf.Timestamp\022/\n\013update_time\030\006 \001(\0132\032.goog" - + "le.protobuf.Timestamp\"Q\n\005State\022\025\n\021STATE_" - + "UNSPECIFIED\020\000\022\013\n\007CREATED\020\001\022\013\n\007RUNNING\020\002\022" - + "\010\n\004DONE\020\003\022\r\n\tCANCELLED\020\004*e\n\nLikelihood\022\013" - + "\n\007UNKNOWN\020\000\022\021\n\rVERY_UNLIKELY\020\001\022\014\n\010UNLIKE" - + "LY\020\002\022\014\n\010POSSIBLE\020\003\022\n\n\006LIKELY\020\004\022\017\n\013VERY_L" - + "IKELY\020\0052\365\n\n\016ImageAnnotator\022\223\002\n\023BatchAnno" - + "tateImages\0222.google.cloud.vision.v1.Batc" - + "hAnnotateImagesRequest\0323.google.cloud.vi" - + "sion.v1.BatchAnnotateImagesResponse\"\222\001\202\323" - + "\344\223\002\200\001\"\023/v1/images:annotate:\001*Z8\"3/v1/{pa" - + "rent=projects/*/locations/*}/images:anno" - + "tate:\001*Z,\"\'/v1/{parent=projects/*}/image" - + "s:annotate:\001*\332A\010requests\022\214\002\n\022BatchAnnota" - + "teFiles\0221.google.cloud.vision.v1.BatchAn" - + "notateFilesRequest\0322.google.cloud.vision" - + ".v1.BatchAnnotateFilesResponse\"\216\001\202\323\344\223\002}\"" - + "\022/v1/files:annotate:\001*Z7\"2/v1/{parent=pr" - + "ojects/*/locations/*}/files:annotate:\001*Z" - + "+\"&/v1/{parent=projects/*}/files:annotat" - + "e:\001*\332A\010requests\022\353\002\n\030AsyncBatchAnnotateIm" - + "ages\0227.google.cloud.vision.v1.AsyncBatch" - + "AnnotateImagesRequest\032\035.google.longrunni" - + "ng.Operation\"\366\001\202\323\344\223\002\236\001\"\035/v1/images:async" - + "BatchAnnotate:\001*ZB\"=/v1/{parent=projects" - + "/*/locations/*}/images:asyncBatchAnnotat" - + "e:\001*Z6\"1/v1/{parent=projects/*}/images:a" - + "syncBatchAnnotate:\001*\332A\026requests,output_c" - + "onfig\312A5\n AsyncBatchAnnotateImagesRespon" - + "se\022\021OperationMetadata\022\327\002\n\027AsyncBatchAnno" - + "tateFiles\0226.google.cloud.vision.v1.Async" - + "BatchAnnotateFilesRequest\032\035.google.longr" - + "unning.Operation\"\344\001\202\323\344\223\002\233\001\"\034/v1/files:as" - + "yncBatchAnnotate:\001*ZA\"\n\005" + + "state\030\001 \001(\0162/.google.cloud.vision.v1.Ope" + + "rationMetadata.State\022/\n\013create_time\030\005 \001(" + + "\0132\032.google.protobuf.Timestamp\022/\n\013update_" + + "time\030\006 \001(\0132\032.google.protobuf.Timestamp\"Q" + + "\n\005State\022\025\n\021STATE_UNSPECIFIED\020\000\022\013\n\007CREATE" + + "D\020\001\022\013\n\007RUNNING\020\002\022\010\n\004DONE\020\003\022\r\n\tCANCELLED\020" + + "\004*e\n\nLikelihood\022\013\n\007UNKNOWN\020\000\022\021\n\rVERY_UNL" + + "IKELY\020\001\022\014\n\010UNLIKELY\020\002\022\014\n\010POSSIBLE\020\003\022\n\n\006L" + + "IKELY\020\004\022\017\n\013VERY_LIKELY\020\0052\365\n\n\016ImageAnnota" + + "tor\022\223\002\n\023BatchAnnotateImages\0222.google.clo" + + "ud.vision.v1.BatchAnnotateImagesRequest\032" + + "3.google.cloud.vision.v1.BatchAnnotateIm" + + "agesResponse\"\222\001\202\323\344\223\002\200\001\"\023/v1/images:annot" + + "ate:\001*Z8\"3/v1/{parent=projects/*/locatio" + + "ns/*}/images:annotate:\001*Z,\"\'/v1/{parent=" + + "projects/*}/images:annotate:\001*\332A\010request" + + "s\022\214\002\n\022BatchAnnotateFiles\0221.google.cloud." + + "vision.v1.BatchAnnotateFilesRequest\0322.go" + + "ogle.cloud.vision.v1.BatchAnnotateFilesR" + + "esponse\"\216\001\202\323\344\223\002}\"\022/v1/files:annotate:\001*Z" + + "7\"2/v1/{parent=projects/*/locations/*}/f" + + "iles:annotate:\001*Z+\"&/v1/{parent=projects" + + "/*}/files:annotate:\001*\332A\010requests\022\353\002\n\030Asy" + + "ncBatchAnnotateImages\0227.google.cloud.vis" + + "ion.v1.AsyncBatchAnnotateImagesRequest\032\035" + + ".google.longrunning.Operation\"\366\001\202\323\344\223\002\236\001\"" + + "\035/v1/images:asyncBatchAnnotate:\001*ZB\"=/v1" + + "/{parent=projects/*/locations/*}/images:" + + "asyncBatchAnnotate:\001*Z6\"1/v1/{parent=pro" + + "jects/*}/images:asyncBatchAnnotate:\001*\332A\026" + + "requests,output_config\312A5\n AsyncBatchAnn" + + "otateImagesResponse\022\021OperationMetadata\022\327" + + "\002\n\027AsyncBatchAnnotateFiles\0226.google.clou" + + "d.vision.v1.AsyncBatchAnnotateFilesReque" + + "st\032\035.google.longrunning.Operation\"\344\001\202\323\344\223" + + "\002\233\001\"\034/v1/files:asyncBatchAnnotate:\001*ZA\"<" + + "/v1/{parent=projects/*/locations/*}/file" + + "s:asyncBatchAnnotate:\001*Z5\"0/v1/{parent=p" + + "rojects/*}/files:asyncBatchAnnotate:\001*\332A" + + "\010requests\312A4\n\037AsyncBatchAnnotateFilesRes" + + "ponse\022\021OperationMetadata\032v\312A\025vision.goog" + + "leapis.com\322A[https://www.googleapis.com/" + + "auth/cloud-platform,https://www.googleap" + + "is.com/auth/cloud-visionB{\n\032com.google.c" + + "loud.vision.v1B\023ImageAnnotatorProtoP\001Z - * Confidence of adult_score. Range [0, 1]. 0 means not confident, 1 means - * very confident. - * - * - * float adult_confidence = 16 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.adult_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=582 - * @return The adultConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getAdultConfidence() { - return adultConfidence_; - } - - public static final int SPOOF_CONFIDENCE_FIELD_NUMBER = 18; - private float spoofConfidence_; - /** - * - * - *
-   * Confidence of spoof_score. Range [0, 1]. 0 means not confident, 1 means
-   * very confident.
-   * 
- * - * float spoof_confidence = 18 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.spoof_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=586 - * @return The spoofConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getSpoofConfidence() { - return spoofConfidence_; - } - - public static final int MEDICAL_CONFIDENCE_FIELD_NUMBER = 20; - private float medicalConfidence_; - /** - * - * - *
-   * Confidence of medical_score. Range [0, 1]. 0 means not confident, 1 means
-   * very confident.
-   * 
- * - * float medical_confidence = 20 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.medical_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=590 - * @return The medicalConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getMedicalConfidence() { - return medicalConfidence_; - } - - public static final int VIOLENCE_CONFIDENCE_FIELD_NUMBER = 22; - private float violenceConfidence_; - /** - * - * - *
-   * Confidence of violence_score. Range [0, 1]. 0 means not confident, 1 means
-   * very confident.
-   * 
- * - * float violence_confidence = 22 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.violence_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=594 - * @return The violenceConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getViolenceConfidence() { - return violenceConfidence_; - } - - public static final int RACY_CONFIDENCE_FIELD_NUMBER = 24; - private float racyConfidence_; - /** - * - * - *
-   * Confidence of racy_score. Range [0, 1]. 0 means not confident, 1 means very
-   * confident.
-   * 
- * - * float racy_confidence = 24 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.racy_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=598 - * @return The racyConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getRacyConfidence() { - return racyConfidence_; - } - - public static final int NSFW_CONFIDENCE_FIELD_NUMBER = 26; - private float nsfwConfidence_; - /** - * - * - *
-   * Confidence of nsfw_score. Range [0, 1]. 0 means not confident, 1 means very
-   * confident.
-   * 
- * - * float nsfw_confidence = 26 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.nsfw_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=602 - * @return The nsfwConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getNsfwConfidence() { - return nsfwConfidence_; - } - private byte memoizedIsInitialized = -1; @java.lang.Override @@ -532,24 +370,6 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (racy_ != com.google.cloud.vision.v1.Likelihood.UNKNOWN.getNumber()) { output.writeEnum(9, racy_); } - if (java.lang.Float.floatToRawIntBits(adultConfidence_) != 0) { - output.writeFloat(16, adultConfidence_); - } - if (java.lang.Float.floatToRawIntBits(spoofConfidence_) != 0) { - output.writeFloat(18, spoofConfidence_); - } - if (java.lang.Float.floatToRawIntBits(medicalConfidence_) != 0) { - output.writeFloat(20, medicalConfidence_); - } - if (java.lang.Float.floatToRawIntBits(violenceConfidence_) != 0) { - output.writeFloat(22, violenceConfidence_); - } - if (java.lang.Float.floatToRawIntBits(racyConfidence_) != 0) { - output.writeFloat(24, racyConfidence_); - } - if (java.lang.Float.floatToRawIntBits(nsfwConfidence_) != 0) { - output.writeFloat(26, nsfwConfidence_); - } unknownFields.writeTo(output); } @@ -574,24 +394,6 @@ public int getSerializedSize() { if (racy_ != com.google.cloud.vision.v1.Likelihood.UNKNOWN.getNumber()) { size += com.google.protobuf.CodedOutputStream.computeEnumSize(9, racy_); } - if (java.lang.Float.floatToRawIntBits(adultConfidence_) != 0) { - size += com.google.protobuf.CodedOutputStream.computeFloatSize(16, adultConfidence_); - } - if (java.lang.Float.floatToRawIntBits(spoofConfidence_) != 0) { - size += com.google.protobuf.CodedOutputStream.computeFloatSize(18, spoofConfidence_); - } - if (java.lang.Float.floatToRawIntBits(medicalConfidence_) != 0) { - size += com.google.protobuf.CodedOutputStream.computeFloatSize(20, medicalConfidence_); - } - if (java.lang.Float.floatToRawIntBits(violenceConfidence_) != 0) { - size += com.google.protobuf.CodedOutputStream.computeFloatSize(22, violenceConfidence_); - } - if (java.lang.Float.floatToRawIntBits(racyConfidence_) != 0) { - size += com.google.protobuf.CodedOutputStream.computeFloatSize(24, racyConfidence_); - } - if (java.lang.Float.floatToRawIntBits(nsfwConfidence_) != 0) { - size += com.google.protobuf.CodedOutputStream.computeFloatSize(26, nsfwConfidence_); - } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -613,18 +415,6 @@ public boolean equals(final java.lang.Object obj) { if (medical_ != other.medical_) return false; if (violence_ != other.violence_) return false; if (racy_ != other.racy_) return false; - if (java.lang.Float.floatToIntBits(getAdultConfidence()) - != java.lang.Float.floatToIntBits(other.getAdultConfidence())) return false; - if (java.lang.Float.floatToIntBits(getSpoofConfidence()) - != java.lang.Float.floatToIntBits(other.getSpoofConfidence())) return false; - if (java.lang.Float.floatToIntBits(getMedicalConfidence()) - != java.lang.Float.floatToIntBits(other.getMedicalConfidence())) return false; - if (java.lang.Float.floatToIntBits(getViolenceConfidence()) - != java.lang.Float.floatToIntBits(other.getViolenceConfidence())) return false; - if (java.lang.Float.floatToIntBits(getRacyConfidence()) - != java.lang.Float.floatToIntBits(other.getRacyConfidence())) return false; - if (java.lang.Float.floatToIntBits(getNsfwConfidence()) - != java.lang.Float.floatToIntBits(other.getNsfwConfidence())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -646,18 +436,6 @@ public int hashCode() { hash = (53 * hash) + violence_; hash = (37 * hash) + RACY_FIELD_NUMBER; hash = (53 * hash) + racy_; - hash = (37 * hash) + ADULT_CONFIDENCE_FIELD_NUMBER; - hash = (53 * hash) + java.lang.Float.floatToIntBits(getAdultConfidence()); - hash = (37 * hash) + SPOOF_CONFIDENCE_FIELD_NUMBER; - hash = (53 * hash) + java.lang.Float.floatToIntBits(getSpoofConfidence()); - hash = (37 * hash) + MEDICAL_CONFIDENCE_FIELD_NUMBER; - hash = (53 * hash) + java.lang.Float.floatToIntBits(getMedicalConfidence()); - hash = (37 * hash) + VIOLENCE_CONFIDENCE_FIELD_NUMBER; - hash = (53 * hash) + java.lang.Float.floatToIntBits(getViolenceConfidence()); - hash = (37 * hash) + RACY_CONFIDENCE_FIELD_NUMBER; - hash = (53 * hash) + java.lang.Float.floatToIntBits(getRacyConfidence()); - hash = (37 * hash) + NSFW_CONFIDENCE_FIELD_NUMBER; - hash = (53 * hash) + java.lang.Float.floatToIntBits(getNsfwConfidence()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -815,18 +593,6 @@ public Builder clear() { racy_ = 0; - adultConfidence_ = 0F; - - spoofConfidence_ = 0F; - - medicalConfidence_ = 0F; - - violenceConfidence_ = 0F; - - racyConfidence_ = 0F; - - nsfwConfidence_ = 0F; - return this; } @@ -859,12 +625,6 @@ public com.google.cloud.vision.v1.SafeSearchAnnotation buildPartial() { result.medical_ = medical_; result.violence_ = violence_; result.racy_ = racy_; - result.adultConfidence_ = adultConfidence_; - result.spoofConfidence_ = spoofConfidence_; - result.medicalConfidence_ = medicalConfidence_; - result.violenceConfidence_ = violenceConfidence_; - result.racyConfidence_ = racyConfidence_; - result.nsfwConfidence_ = nsfwConfidence_; onBuilt(); return result; } @@ -930,24 +690,6 @@ public Builder mergeFrom(com.google.cloud.vision.v1.SafeSearchAnnotation other) if (other.racy_ != 0) { setRacyValue(other.getRacyValue()); } - if (other.getAdultConfidence() != 0F) { - setAdultConfidence(other.getAdultConfidence()); - } - if (other.getSpoofConfidence() != 0F) { - setSpoofConfidence(other.getSpoofConfidence()); - } - if (other.getMedicalConfidence() != 0F) { - setMedicalConfidence(other.getMedicalConfidence()); - } - if (other.getViolenceConfidence() != 0F) { - setViolenceConfidence(other.getViolenceConfidence()); - } - if (other.getRacyConfidence() != 0F) { - setRacyConfidence(other.getRacyConfidence()); - } - if (other.getNsfwConfidence() != 0F) { - setNsfwConfidence(other.getNsfwConfidence()); - } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -1467,390 +1209,6 @@ public Builder clearRacy() { return this; } - private float adultConfidence_; - /** - * - * - *
-     * Confidence of adult_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float adult_confidence = 16 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.adult_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=582 - * @return The adultConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getAdultConfidence() { - return adultConfidence_; - } - /** - * - * - *
-     * Confidence of adult_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float adult_confidence = 16 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.adult_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=582 - * @param value The adultConfidence to set. - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder setAdultConfidence(float value) { - - adultConfidence_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Confidence of adult_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float adult_confidence = 16 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.adult_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=582 - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder clearAdultConfidence() { - - adultConfidence_ = 0F; - onChanged(); - return this; - } - - private float spoofConfidence_; - /** - * - * - *
-     * Confidence of spoof_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float spoof_confidence = 18 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.spoof_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=586 - * @return The spoofConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getSpoofConfidence() { - return spoofConfidence_; - } - /** - * - * - *
-     * Confidence of spoof_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float spoof_confidence = 18 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.spoof_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=586 - * @param value The spoofConfidence to set. - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder setSpoofConfidence(float value) { - - spoofConfidence_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Confidence of spoof_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float spoof_confidence = 18 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.spoof_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=586 - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder clearSpoofConfidence() { - - spoofConfidence_ = 0F; - onChanged(); - return this; - } - - private float medicalConfidence_; - /** - * - * - *
-     * Confidence of medical_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float medical_confidence = 20 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.medical_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=590 - * @return The medicalConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getMedicalConfidence() { - return medicalConfidence_; - } - /** - * - * - *
-     * Confidence of medical_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float medical_confidence = 20 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.medical_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=590 - * @param value The medicalConfidence to set. - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder setMedicalConfidence(float value) { - - medicalConfidence_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Confidence of medical_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float medical_confidence = 20 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.medical_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=590 - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder clearMedicalConfidence() { - - medicalConfidence_ = 0F; - onChanged(); - return this; - } - - private float violenceConfidence_; - /** - * - * - *
-     * Confidence of violence_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float violence_confidence = 22 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.violence_confidence is deprecated. - * See google/cloud/vision/v1/image_annotator.proto;l=594 - * @return The violenceConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getViolenceConfidence() { - return violenceConfidence_; - } - /** - * - * - *
-     * Confidence of violence_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float violence_confidence = 22 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.violence_confidence is deprecated. - * See google/cloud/vision/v1/image_annotator.proto;l=594 - * @param value The violenceConfidence to set. - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder setViolenceConfidence(float value) { - - violenceConfidence_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Confidence of violence_score. Range [0, 1]. 0 means not confident, 1 means
-     * very confident.
-     * 
- * - * float violence_confidence = 22 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.violence_confidence is deprecated. - * See google/cloud/vision/v1/image_annotator.proto;l=594 - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder clearViolenceConfidence() { - - violenceConfidence_ = 0F; - onChanged(); - return this; - } - - private float racyConfidence_; - /** - * - * - *
-     * Confidence of racy_score. Range [0, 1]. 0 means not confident, 1 means very
-     * confident.
-     * 
- * - * float racy_confidence = 24 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.racy_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=598 - * @return The racyConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getRacyConfidence() { - return racyConfidence_; - } - /** - * - * - *
-     * Confidence of racy_score. Range [0, 1]. 0 means not confident, 1 means very
-     * confident.
-     * 
- * - * float racy_confidence = 24 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.racy_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=598 - * @param value The racyConfidence to set. - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder setRacyConfidence(float value) { - - racyConfidence_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Confidence of racy_score. Range [0, 1]. 0 means not confident, 1 means very
-     * confident.
-     * 
- * - * float racy_confidence = 24 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.racy_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=598 - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder clearRacyConfidence() { - - racyConfidence_ = 0F; - onChanged(); - return this; - } - - private float nsfwConfidence_; - /** - * - * - *
-     * Confidence of nsfw_score. Range [0, 1]. 0 means not confident, 1 means very
-     * confident.
-     * 
- * - * float nsfw_confidence = 26 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.nsfw_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=602 - * @return The nsfwConfidence. - */ - @java.lang.Override - @java.lang.Deprecated - public float getNsfwConfidence() { - return nsfwConfidence_; - } - /** - * - * - *
-     * Confidence of nsfw_score. Range [0, 1]. 0 means not confident, 1 means very
-     * confident.
-     * 
- * - * float nsfw_confidence = 26 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.nsfw_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=602 - * @param value The nsfwConfidence to set. - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder setNsfwConfidence(float value) { - - nsfwConfidence_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Confidence of nsfw_score. Range [0, 1]. 0 means not confident, 1 means very
-     * confident.
-     * 
- * - * float nsfw_confidence = 26 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.nsfw_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=602 - * @return This builder for chaining. - */ - @java.lang.Deprecated - public Builder clearNsfwConfidence() { - - nsfwConfidence_ = 0F; - onChanged(); - return this; - } - @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/SafeSearchAnnotationOrBuilder.java b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/SafeSearchAnnotationOrBuilder.java index 52f299c5a..2391cd7a6 100644 --- a/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/SafeSearchAnnotationOrBuilder.java +++ b/proto-google-cloud-vision-v1/src/main/java/com/google/cloud/vision/v1/SafeSearchAnnotationOrBuilder.java @@ -161,106 +161,4 @@ public interface SafeSearchAnnotationOrBuilder * @return The racy. */ com.google.cloud.vision.v1.Likelihood getRacy(); - - /** - * - * - *
-   * Confidence of adult_score. Range [0, 1]. 0 means not confident, 1 means
-   * very confident.
-   * 
- * - * float adult_confidence = 16 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.adult_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=582 - * @return The adultConfidence. - */ - @java.lang.Deprecated - float getAdultConfidence(); - - /** - * - * - *
-   * Confidence of spoof_score. Range [0, 1]. 0 means not confident, 1 means
-   * very confident.
-   * 
- * - * float spoof_confidence = 18 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.spoof_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=586 - * @return The spoofConfidence. - */ - @java.lang.Deprecated - float getSpoofConfidence(); - - /** - * - * - *
-   * Confidence of medical_score. Range [0, 1]. 0 means not confident, 1 means
-   * very confident.
-   * 
- * - * float medical_confidence = 20 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.medical_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=590 - * @return The medicalConfidence. - */ - @java.lang.Deprecated - float getMedicalConfidence(); - - /** - * - * - *
-   * Confidence of violence_score. Range [0, 1]. 0 means not confident, 1 means
-   * very confident.
-   * 
- * - * float violence_confidence = 22 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.violence_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=594 - * @return The violenceConfidence. - */ - @java.lang.Deprecated - float getViolenceConfidence(); - - /** - * - * - *
-   * Confidence of racy_score. Range [0, 1]. 0 means not confident, 1 means very
-   * confident.
-   * 
- * - * float racy_confidence = 24 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.racy_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=598 - * @return The racyConfidence. - */ - @java.lang.Deprecated - float getRacyConfidence(); - - /** - * - * - *
-   * Confidence of nsfw_score. Range [0, 1]. 0 means not confident, 1 means very
-   * confident.
-   * 
- * - * float nsfw_confidence = 26 [deprecated = true]; - * - * @deprecated google.cloud.vision.v1.SafeSearchAnnotation.nsfw_confidence is deprecated. See - * google/cloud/vision/v1/image_annotator.proto;l=602 - * @return The nsfwConfidence. - */ - @java.lang.Deprecated - float getNsfwConfidence(); } diff --git a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/geometry.proto b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/geometry.proto index 4e808eaf6..7e0d24c2f 100644 --- a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/geometry.proto +++ b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/geometry.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/image_annotator.proto b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/image_annotator.proto index 906455c31..a70c7fdc8 100644 --- a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/image_annotator.proto +++ b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/image_annotator.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -46,8 +46,7 @@ service ImageAnnotator { "https://www.googleapis.com/auth/cloud-vision"; // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) - returns (BatchAnnotateImagesResponse) { + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { option (google.api.http) = { post: "/v1/images:annotate" body: "*" @@ -70,8 +69,7 @@ service ImageAnnotator { // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each // file provided and perform detection and annotation for each image // extracted. - rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) - returns (BatchAnnotateFilesResponse) { + rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) returns (BatchAnnotateFilesResponse) { option (google.api.http) = { post: "/v1/files:annotate" body: "*" @@ -96,8 +94,7 @@ service ImageAnnotator { // // This service will write image annotation outputs to json files in customer // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) - returns (google.longrunning.Operation) { + rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) returns (google.longrunning.Operation) { option (google.api.http) = { post: "/v1/images:asyncBatchAnnotate" body: "*" @@ -123,8 +120,7 @@ service ImageAnnotator { // `google.longrunning.Operations` interface. // `Operation.metadata` contains `OperationMetadata` (metadata). // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) - returns (google.longrunning.Operation) { + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { option (google.api.http) = { post: "/v1/files:asyncBatchAnnotate" body: "*" @@ -145,6 +141,28 @@ service ImageAnnotator { } } +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely. + VERY_UNLIKELY = 1; + + // It is unlikely. + UNLIKELY = 2; + + // It is possible. + POSSIBLE = 3; + + // It is likely. + LIKELY = 4; + + // It is very likely. + VERY_LIKELY = 5; +} + // The type of Google Cloud Vision API detection to perform, and the maximum // number of results to return for that type. Multiple `Feature` objects can // be specified in the `features` list. @@ -255,28 +273,6 @@ message Image { ImageSource source = 2; } -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely. - VERY_UNLIKELY = 1; - - // It is unlikely. - UNLIKELY = 2; - - // It is possible. - POSSIBLE = 3; - - // It is likely. - LIKELY = 4; - - // It is very likely. - VERY_LIKELY = 5; -} - // A face annotation object contains the results of face detection. message FaceAnnotation { // A face-specific landmark (for example, a face feature). @@ -577,30 +573,6 @@ message SafeSearchAnnotation { // covered nudity, lewd or provocative poses, or close-ups of sensitive // body areas. Likelihood racy = 9; - - // Confidence of adult_score. Range [0, 1]. 0 means not confident, 1 means - // very confident. - float adult_confidence = 16 [deprecated = true]; - - // Confidence of spoof_score. Range [0, 1]. 0 means not confident, 1 means - // very confident. - float spoof_confidence = 18 [deprecated = true]; - - // Confidence of medical_score. Range [0, 1]. 0 means not confident, 1 means - // very confident. - float medical_confidence = 20 [deprecated = true]; - - // Confidence of violence_score. Range [0, 1]. 0 means not confident, 1 means - // very confident. - float violence_confidence = 22 [deprecated = true]; - - // Confidence of racy_score. Range [0, 1]. 0 means not confident, 1 means very - // confident. - float racy_confidence = 24 [deprecated = true]; - - // Confidence of nsfw_score. Range [0, 1]. 0 means not confident, 1 means very - // confident. - float nsfw_confidence = 26 [deprecated = true]; } // Rectangle determined by min and max `LatLng` pairs. @@ -791,8 +763,7 @@ message AnnotateImageResponse { // Multiple image annotation requests are batched into a single service call. message BatchAnnotateImagesRequest { // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; // Optional. Target project and location to make a call. // @@ -863,10 +834,9 @@ message AnnotateFileResponse { // A list of requests to annotate files using the BatchAnnotateFiles API. message BatchAnnotateFilesRequest { - // Required. The list of file annotation requests. Right now we support only - // one AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; + // Required. The list of file annotation requests. Right now we support only one + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; // Optional. Target project and location to make a call. // @@ -914,8 +884,7 @@ message AsyncAnnotateFileResponse { // Request for async image annotation for a list of images. message AsyncBatchAnnotateImagesRequest { // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; // Required. The desired output location and metadata (e.g. format). OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; @@ -945,8 +914,7 @@ message AsyncBatchAnnotateImagesResponse { // call. message AsyncBatchAnnotateFilesRequest { // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; // Optional. Target project and location to make a call. // diff --git a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/product_search.proto b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/product_search.proto index 73cb35249..a2a985058 100644 --- a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/product_search.proto +++ b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/product_search.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/product_search_service.proto b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/product_search_service.proto index 5a61f5422..65680d909 100644 --- a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/product_search_service.proto +++ b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/product_search_service.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/text_annotation.proto b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/text_annotation.proto index ad7db17a7..9c07c3220 100644 --- a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/text_annotation.proto +++ b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/text_annotation.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/web_detection.proto b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/web_detection.proto index d5b4d5ba4..369a1350d 100644 --- a/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/web_detection.proto +++ b/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/web_detection.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/BatchAnnotateImagesRequest.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/BatchAnnotateImagesRequest.java index fb5021016..bfc8f4ccd 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/BatchAnnotateImagesRequest.java +++ b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/BatchAnnotateImagesRequest.java @@ -133,7 +133,9 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ @java.lang.Override public java.util.List getRequestsList() { @@ -146,7 +148,9 @@ public java.util.List ge * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ @java.lang.Override public java.util.List @@ -160,7 +164,9 @@ public java.util.List ge * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ @java.lang.Override public int getRequestsCount() { @@ -173,7 +179,9 @@ public int getRequestsCount() { * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ @java.lang.Override public com.google.cloud.vision.v1p3beta1.AnnotateImageRequest getRequests(int index) { @@ -186,7 +194,9 @@ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequest getRequests(int in * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ @java.lang.Override public com.google.cloud.vision.v1p3beta1.AnnotateImageRequestOrBuilder getRequestsOrBuilder( @@ -582,7 +592,9 @@ private void ensureRequestsIsMutable() { * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public java.util.List getRequestsList() { @@ -599,7 +611,9 @@ private void ensureRequestsIsMutable() { * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public int getRequestsCount() { if (requestsBuilder_ == null) { @@ -615,7 +629,9 @@ public int getRequestsCount() { * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequest getRequests(int index) { if (requestsBuilder_ == null) { @@ -631,7 +647,9 @@ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequest getRequests(int in * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder setRequests( int index, com.google.cloud.vision.v1p3beta1.AnnotateImageRequest value) { @@ -654,7 +672,9 @@ public Builder setRequests( * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder setRequests( int index, com.google.cloud.vision.v1p3beta1.AnnotateImageRequest.Builder builderForValue) { @@ -674,7 +694,9 @@ public Builder setRequests( * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder addRequests(com.google.cloud.vision.v1p3beta1.AnnotateImageRequest value) { if (requestsBuilder_ == null) { @@ -696,7 +718,9 @@ public Builder addRequests(com.google.cloud.vision.v1p3beta1.AnnotateImageReques * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder addRequests( int index, com.google.cloud.vision.v1p3beta1.AnnotateImageRequest value) { @@ -719,7 +743,9 @@ public Builder addRequests( * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder addRequests( com.google.cloud.vision.v1p3beta1.AnnotateImageRequest.Builder builderForValue) { @@ -739,7 +765,9 @@ public Builder addRequests( * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder addRequests( int index, com.google.cloud.vision.v1p3beta1.AnnotateImageRequest.Builder builderForValue) { @@ -759,7 +787,9 @@ public Builder addRequests( * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder addAllRequests( java.lang.Iterable @@ -780,7 +810,9 @@ public Builder addAllRequests( * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder clearRequests() { if (requestsBuilder_ == null) { @@ -799,7 +831,9 @@ public Builder clearRequests() { * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder removeRequests(int index) { if (requestsBuilder_ == null) { @@ -818,7 +852,9 @@ public Builder removeRequests(int index) { * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequest.Builder getRequestsBuilder( int index) { @@ -831,7 +867,9 @@ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequest.Builder getRequest * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequestOrBuilder getRequestsOrBuilder( int index) { @@ -848,7 +886,9 @@ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequestOrBuilder getReques * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public java.util.List getRequestsOrBuilderList() { @@ -865,7 +905,9 @@ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequestOrBuilder getReques * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequest.Builder addRequestsBuilder() { return getRequestsFieldBuilder() @@ -878,7 +920,9 @@ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequest.Builder addRequest * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequest.Builder addRequestsBuilder( int index) { @@ -893,7 +937,9 @@ public com.google.cloud.vision.v1p3beta1.AnnotateImageRequest.Builder addRequest * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ public java.util.List getRequestsBuilderList() { diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/BatchAnnotateImagesRequestOrBuilder.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/BatchAnnotateImagesRequestOrBuilder.java index 13f8ac924..a91be685a 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/BatchAnnotateImagesRequestOrBuilder.java +++ b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/BatchAnnotateImagesRequestOrBuilder.java @@ -30,7 +30,9 @@ public interface BatchAnnotateImagesRequestOrBuilder * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ java.util.List getRequestsList(); /** @@ -40,7 +42,9 @@ public interface BatchAnnotateImagesRequestOrBuilder * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ com.google.cloud.vision.v1p3beta1.AnnotateImageRequest getRequests(int index); /** @@ -50,7 +54,9 @@ public interface BatchAnnotateImagesRequestOrBuilder * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ int getRequestsCount(); /** @@ -60,7 +66,9 @@ public interface BatchAnnotateImagesRequestOrBuilder * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ java.util.List getRequestsOrBuilderList(); @@ -71,7 +79,9 @@ public interface BatchAnnotateImagesRequestOrBuilder * Individual image annotation requests for this batch. * * - * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1; + * + * repeated .google.cloud.vision.v1p3beta1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED]; + * */ com.google.cloud.vision.v1p3beta1.AnnotateImageRequestOrBuilder getRequestsOrBuilder(int index); } diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/GeometryProto.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/GeometryProto.java index 487454c58..ccd4dcd18 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/GeometryProto.java +++ b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/GeometryProto.java @@ -39,10 +39,6 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_cloud_vision_v1p3beta1_BoundingPoly_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_cloud_vision_v1p3beta1_BoundingPoly_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_vision_v1p3beta1_NormalizedBoundingPoly_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_vision_v1p3beta1_NormalizedBoundingPoly_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_cloud_vision_v1p3beta1_Position_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable @@ -57,28 +53,22 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { static { java.lang.String[] descriptorData = { "\n,google/cloud/vision/v1p3beta1/geometry" - + ".proto\022\035google.cloud.vision.v1p3beta1\032\034g" - + "oogle/api/annotations.proto\"\036\n\006Vertex\022\t\n" - + "\001x\030\001 \001(\005\022\t\n\001y\030\002 \001(\005\"(\n\020NormalizedVertex\022" - + "\t\n\001x\030\001 \001(\002\022\t\n\001y\030\002 \001(\002\"\225\001\n\014BoundingPoly\0227" - + "\n\010vertices\030\001 \003(\0132%.google.cloud.vision.v" - + "1p3beta1.Vertex\022L\n\023normalized_vertices\030\002" - + " \003(\0132/.google.cloud.vision.v1p3beta1.Nor" - + "malizedVertex\"[\n\026NormalizedBoundingPoly\022" - + "A\n\010vertices\030\001 \003(\0132/.google.cloud.vision." - + "v1p3beta1.NormalizedVertex\"+\n\010Position\022\t" - + "\n\001x\030\001 \001(\002\022\t\n\001y\030\002 \001(\002\022\t\n\001z\030\003 \001(\002B|\n!com.g" - + "oogle.cloud.vision.v1p3beta1B\rGeometryPr" - + "otoP\001ZCgoogle.golang.org/genproto/google" - + "apis/cloud/vision/v1p3beta1;vision\370\001\001b\006p" - + "roto3" + + ".proto\022\035google.cloud.vision.v1p3beta1\"\036\n" + + "\006Vertex\022\t\n\001x\030\001 \001(\005\022\t\n\001y\030\002 \001(\005\"(\n\020Normali" + + "zedVertex\022\t\n\001x\030\001 \001(\002\022\t\n\001y\030\002 \001(\002\"\225\001\n\014Boun" + + "dingPoly\0227\n\010vertices\030\001 \003(\0132%.google.clou" + + "d.vision.v1p3beta1.Vertex\022L\n\023normalized_" + + "vertices\030\002 \003(\0132/.google.cloud.vision.v1p" + + "3beta1.NormalizedVertex\"+\n\010Position\022\t\n\001x" + + "\030\001 \001(\002\022\t\n\001y\030\002 \001(\002\022\t\n\001z\030\003 \001(\002B\203\001\n!com.goo" + + "gle.cloud.vision.v1p3beta1B\rGeometryProt" + + "oP\001ZCgoogle.golang.org/genproto/googleap" + + "is/cloud/vision/v1p3beta1;vision\370\001\001\242\002\004GC" + + "VNb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.api.AnnotationsProto.getDescriptor(), - }); + descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}); internal_static_google_cloud_vision_v1p3beta1_Vertex_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_cloud_vision_v1p3beta1_Vertex_fieldAccessorTable = @@ -103,23 +93,14 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new java.lang.String[] { "Vertices", "NormalizedVertices", }); - internal_static_google_cloud_vision_v1p3beta1_NormalizedBoundingPoly_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_google_cloud_vision_v1p3beta1_NormalizedBoundingPoly_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_vision_v1p3beta1_NormalizedBoundingPoly_descriptor, - new java.lang.String[] { - "Vertices", - }); internal_static_google_cloud_vision_v1p3beta1_Position_descriptor = - getDescriptor().getMessageTypes().get(4); + getDescriptor().getMessageTypes().get(3); internal_static_google_cloud_vision_v1p3beta1_Position_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_cloud_vision_v1p3beta1_Position_descriptor, new java.lang.String[] { "X", "Y", "Z", }); - com.google.api.AnnotationsProto.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ImageAnnotatorProto.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ImageAnnotatorProto.java index 0bcaa243c..c3faa0587 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ImageAnnotatorProto.java +++ b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ImageAnnotatorProto.java @@ -338,61 +338,61 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "nse\022@\n\014input_config\030\001 \001(\0132*.google.cloud" + ".vision.v1p3beta1.InputConfig\022G\n\trespons" + "es\030\002 \003(\01324.google.cloud.vision.v1p3beta1" - + ".AnnotateImageResponse\"c\n\032BatchAnnotateI" - + "magesRequest\022E\n\010requests\030\001 \003(\01323.google." + + ".AnnotateImageResponse\"h\n\032BatchAnnotateI" + + "magesRequest\022J\n\010requests\030\001 \003(\01323.google." + "cloud.vision.v1p3beta1.AnnotateImageRequ" - + "est\"f\n\033BatchAnnotateImagesResponse\022G\n\tre" - + "sponses\030\001 \003(\01324.google.cloud.vision.v1p3" - + "beta1.AnnotateImageResponse\"\236\002\n\030AsyncAnn" - + "otateFileRequest\022@\n\014input_config\030\001 \001(\0132*" - + ".google.cloud.vision.v1p3beta1.InputConf" - + "ig\0228\n\010features\030\002 \003(\0132&.google.cloud.visi" - + "on.v1p3beta1.Feature\022B\n\rimage_context\030\003 " - + "\001(\0132+.google.cloud.vision.v1p3beta1.Imag" - + "eContext\022B\n\routput_config\030\004 \001(\0132+.google" - + ".cloud.vision.v1p3beta1.OutputConfig\"_\n\031" - + "AsyncAnnotateFileResponse\022B\n\routput_conf" - + "ig\030\001 \001(\0132+.google.cloud.vision.v1p3beta1" - + ".OutputConfig\"p\n\036AsyncBatchAnnotateFiles" - + "Request\022N\n\010requests\030\001 \003(\01327.google.cloud" - + ".vision.v1p3beta1.AsyncAnnotateFileReque" - + "stB\003\340A\002\"n\n\037AsyncBatchAnnotateFilesRespon" - + "se\022K\n\tresponses\030\001 \003(\01328.google.cloud.vis" - + "ion.v1p3beta1.AsyncAnnotateFileResponse\"" - + "^\n\013InputConfig\022<\n\ngcs_source\030\001 \001(\0132(.goo" - + "gle.cloud.vision.v1p3beta1.GcsSource\022\021\n\t" - + "mime_type\030\002 \001(\t\"j\n\014OutputConfig\022F\n\017gcs_d" - + "estination\030\001 \001(\0132-.google.cloud.vision.v" - + "1p3beta1.GcsDestination\022\022\n\nbatch_size\030\002 " - + "\001(\005\"\030\n\tGcsSource\022\013\n\003uri\030\001 \001(\t\"\035\n\016GcsDest" - + "ination\022\013\n\003uri\030\001 \001(\t\"\217\002\n\021OperationMetada" - + "ta\022E\n\005state\030\001 \001(\01626.google.cloud.vision." - + "v1p3beta1.OperationMetadata.State\022/\n\013cre" - + "ate_time\030\005 \001(\0132\032.google.protobuf.Timesta" - + "mp\022/\n\013update_time\030\006 \001(\0132\032.google.protobu" - + "f.Timestamp\"Q\n\005State\022\025\n\021STATE_UNSPECIFIE" - + "D\020\000\022\013\n\007CREATED\020\001\022\013\n\007RUNNING\020\002\022\010\n\004DONE\020\003\022" - + "\r\n\tCANCELLED\020\004*e\n\nLikelihood\022\013\n\007UNKNOWN\020" - + "\000\022\021\n\rVERY_UNLIKELY\020\001\022\014\n\010UNLIKELY\020\002\022\014\n\010PO" - + "SSIBLE\020\003\022\n\n\006LIKELY\020\004\022\017\n\013VERY_LIKELY\020\0052\265\004" - + "\n\016ImageAnnotator\022\276\001\n\023BatchAnnotateImages" - + "\0229.google.cloud.vision.v1p3beta1.BatchAn" - + "notateImagesRequest\032:.google.cloud.visio" - + "n.v1p3beta1.BatchAnnotateImagesResponse\"" - + "0\202\323\344\223\002\037\"\032/v1p3beta1/images:annotate:\001*\332A" - + "\010requests\022\351\001\n\027AsyncBatchAnnotateFiles\022=." - + "google.cloud.vision.v1p3beta1.AsyncBatch" - + "AnnotateFilesRequest\032\035.google.longrunnin" - + "g.Operation\"p\202\323\344\223\002(\"#/v1p3beta1/files:as" - + "yncBatchAnnotate:\001*\332A\010requests\312A4\n\037Async" - + "BatchAnnotateFilesResponse\022\021OperationMet" - + "adata\032v\312A\025vision.googleapis.com\322A[https:" - + "//www.googleapis.com/auth/cloud-platform" - + ",https://www.googleapis.com/auth/cloud-v" - + "isionB\202\001\n!com.google.cloud.vision.v1p3be" - + "ta1B\023ImageAnnotatorProtoP\001ZCgoogle.golan" - + "g.org/genproto/googleapis/cloud/vision/v" - + "1p3beta1;vision\370\001\001b\006proto3" + + "estB\003\340A\002\"f\n\033BatchAnnotateImagesResponse\022" + + "G\n\tresponses\030\001 \003(\01324.google.cloud.vision" + + ".v1p3beta1.AnnotateImageResponse\"\236\002\n\030Asy" + + "ncAnnotateFileRequest\022@\n\014input_config\030\001 " + + "\001(\0132*.google.cloud.vision.v1p3beta1.Inpu" + + "tConfig\0228\n\010features\030\002 \003(\0132&.google.cloud" + + ".vision.v1p3beta1.Feature\022B\n\rimage_conte" + + "xt\030\003 \001(\0132+.google.cloud.vision.v1p3beta1" + + ".ImageContext\022B\n\routput_config\030\004 \001(\0132+.g" + + "oogle.cloud.vision.v1p3beta1.OutputConfi" + + "g\"_\n\031AsyncAnnotateFileResponse\022B\n\routput" + + "_config\030\001 \001(\0132+.google.cloud.vision.v1p3" + + "beta1.OutputConfig\"p\n\036AsyncBatchAnnotate" + + "FilesRequest\022N\n\010requests\030\001 \003(\01327.google." + + "cloud.vision.v1p3beta1.AsyncAnnotateFile" + + "RequestB\003\340A\002\"n\n\037AsyncBatchAnnotateFilesR" + + "esponse\022K\n\tresponses\030\001 \003(\01328.google.clou" + + "d.vision.v1p3beta1.AsyncAnnotateFileResp" + + "onse\"^\n\013InputConfig\022<\n\ngcs_source\030\001 \001(\0132" + + "(.google.cloud.vision.v1p3beta1.GcsSourc" + + "e\022\021\n\tmime_type\030\002 \001(\t\"j\n\014OutputConfig\022F\n\017" + + "gcs_destination\030\001 \001(\0132-.google.cloud.vis" + + "ion.v1p3beta1.GcsDestination\022\022\n\nbatch_si" + + "ze\030\002 \001(\005\"\030\n\tGcsSource\022\013\n\003uri\030\001 \001(\t\"\035\n\016Gc" + + "sDestination\022\013\n\003uri\030\001 \001(\t\"\217\002\n\021OperationM" + + "etadata\022E\n\005state\030\001 \001(\01626.google.cloud.vi" + + "sion.v1p3beta1.OperationMetadata.State\022/" + + "\n\013create_time\030\005 \001(\0132\032.google.protobuf.Ti" + + "mestamp\022/\n\013update_time\030\006 \001(\0132\032.google.pr" + + "otobuf.Timestamp\"Q\n\005State\022\025\n\021STATE_UNSPE" + + "CIFIED\020\000\022\013\n\007CREATED\020\001\022\013\n\007RUNNING\020\002\022\010\n\004DO" + + "NE\020\003\022\r\n\tCANCELLED\020\004*e\n\nLikelihood\022\013\n\007UNK" + + "NOWN\020\000\022\021\n\rVERY_UNLIKELY\020\001\022\014\n\010UNLIKELY\020\002\022" + + "\014\n\010POSSIBLE\020\003\022\n\n\006LIKELY\020\004\022\017\n\013VERY_LIKELY" + + "\020\0052\265\004\n\016ImageAnnotator\022\276\001\n\023BatchAnnotateI" + + "mages\0229.google.cloud.vision.v1p3beta1.Ba" + + "tchAnnotateImagesRequest\032:.google.cloud." + + "vision.v1p3beta1.BatchAnnotateImagesResp" + + "onse\"0\202\323\344\223\002\037\"\032/v1p3beta1/images:annotate" + + ":\001*\332A\010requests\022\351\001\n\027AsyncBatchAnnotateFil" + + "es\022=.google.cloud.vision.v1p3beta1.Async" + + "BatchAnnotateFilesRequest\032\035.google.longr" + + "unning.Operation\"p\202\323\344\223\002(\"#/v1p3beta1/fil" + + "es:asyncBatchAnnotate:\001*\332A\010requests\312A4\n\037" + + "AsyncBatchAnnotateFilesResponse\022\021Operati" + + "onMetadata\032v\312A\025vision.googleapis.com\322A[h" + + "ttps://www.googleapis.com/auth/cloud-pla" + + "tform,https://www.googleapis.com/auth/cl" + + "oud-visionB\202\001\n!com.google.cloud.vision.v" + + "1p3beta1B\023ImageAnnotatorProtoP\001ZCgoogle." + + "golang.org/genproto/googleapis/cloud/vis" + + "ion/v1p3beta1;vision\370\001\001b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/NormalizedBoundingPoly.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/NormalizedBoundingPoly.java deleted file mode 100644 index 2e3f6361f..000000000 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/NormalizedBoundingPoly.java +++ /dev/null @@ -1,963 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/vision/v1p3beta1/geometry.proto - -package com.google.cloud.vision.v1p3beta1; - -/** - * - * - *
- * A normalized bounding polygon around a portion of an image.
- * 
- * - * Protobuf type {@code google.cloud.vision.v1p3beta1.NormalizedBoundingPoly} - */ -public final class NormalizedBoundingPoly extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.vision.v1p3beta1.NormalizedBoundingPoly) - NormalizedBoundingPolyOrBuilder { - private static final long serialVersionUID = 0L; - // Use NormalizedBoundingPoly.newBuilder() to construct. - private NormalizedBoundingPoly(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private NormalizedBoundingPoly() { - vertices_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new NormalizedBoundingPoly(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - private NormalizedBoundingPoly( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - if (!((mutable_bitField0_ & 0x00000001) != 0)) { - vertices_ = - new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - vertices_.add( - input.readMessage( - com.google.cloud.vision.v1p3beta1.NormalizedVertex.parser(), - extensionRegistry)); - break; - } - default: - { - if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) != 0)) { - vertices_ = java.util.Collections.unmodifiableList(vertices_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.vision.v1p3beta1.GeometryProto - .internal_static_google_cloud_vision_v1p3beta1_NormalizedBoundingPoly_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.vision.v1p3beta1.GeometryProto - .internal_static_google_cloud_vision_v1p3beta1_NormalizedBoundingPoly_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.class, - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.Builder.class); - } - - public static final int VERTICES_FIELD_NUMBER = 1; - private java.util.List vertices_; - /** - * - * - *
-   * Normalized vertices of the bounding polygon.
-   * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - @java.lang.Override - public java.util.List getVerticesList() { - return vertices_; - } - /** - * - * - *
-   * Normalized vertices of the bounding polygon.
-   * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - @java.lang.Override - public java.util.List - getVerticesOrBuilderList() { - return vertices_; - } - /** - * - * - *
-   * Normalized vertices of the bounding polygon.
-   * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - @java.lang.Override - public int getVerticesCount() { - return vertices_.size(); - } - /** - * - * - *
-   * Normalized vertices of the bounding polygon.
-   * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.NormalizedVertex getVertices(int index) { - return vertices_.get(index); - } - /** - * - * - *
-   * Normalized vertices of the bounding polygon.
-   * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.NormalizedVertexOrBuilder getVerticesOrBuilder( - int index) { - return vertices_.get(index); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - for (int i = 0; i < vertices_.size(); i++) { - output.writeMessage(1, vertices_.get(i)); - } - unknownFields.writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < vertices_.size(); i++) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, vertices_.get(i)); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly)) { - return super.equals(obj); - } - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly other = - (com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly) obj; - - if (!getVerticesList().equals(other.getVerticesList())) return false; - if (!unknownFields.equals(other.unknownFields)) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (getVerticesCount() > 0) { - hash = (37 * hash) + VERTICES_FIELD_NUMBER; - hash = (53 * hash) + getVerticesList().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder( - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * A normalized bounding polygon around a portion of an image.
-   * 
- * - * Protobuf type {@code google.cloud.vision.v1p3beta1.NormalizedBoundingPoly} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.vision.v1p3beta1.NormalizedBoundingPoly) - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPolyOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.vision.v1p3beta1.GeometryProto - .internal_static_google_cloud_vision_v1p3beta1_NormalizedBoundingPoly_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.vision.v1p3beta1.GeometryProto - .internal_static_google_cloud_vision_v1p3beta1_NormalizedBoundingPoly_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.class, - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.Builder.class); - } - - // Construct using com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { - getVerticesFieldBuilder(); - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (verticesBuilder_ == null) { - vertices_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - verticesBuilder_.clear(); - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.vision.v1p3beta1.GeometryProto - .internal_static_google_cloud_vision_v1p3beta1_NormalizedBoundingPoly_descriptor; - } - - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly getDefaultInstanceForType() { - return com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly build() { - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly buildPartial() { - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly result = - new com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly(this); - int from_bitField0_ = bitField0_; - if (verticesBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0)) { - vertices_ = java.util.Collections.unmodifiableList(vertices_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.vertices_ = vertices_; - } else { - result.vertices_ = verticesBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly) { - return mergeFrom((com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly other) { - if (other == com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.getDefaultInstance()) - return this; - if (verticesBuilder_ == null) { - if (!other.vertices_.isEmpty()) { - if (vertices_.isEmpty()) { - vertices_ = other.vertices_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureVerticesIsMutable(); - vertices_.addAll(other.vertices_); - } - onChanged(); - } - } else { - if (!other.vertices_.isEmpty()) { - if (verticesBuilder_.isEmpty()) { - verticesBuilder_.dispose(); - verticesBuilder_ = null; - vertices_ = other.vertices_; - bitField0_ = (bitField0_ & ~0x00000001); - verticesBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders - ? getVerticesFieldBuilder() - : null; - } else { - verticesBuilder_.addAllMessages(other.vertices_); - } - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = - (com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int bitField0_; - - private java.util.List vertices_ = - java.util.Collections.emptyList(); - - private void ensureVerticesIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - vertices_ = - new java.util.ArrayList(vertices_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.NormalizedVertex, - com.google.cloud.vision.v1p3beta1.NormalizedVertex.Builder, - com.google.cloud.vision.v1p3beta1.NormalizedVertexOrBuilder> - verticesBuilder_; - - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public java.util.List getVerticesList() { - if (verticesBuilder_ == null) { - return java.util.Collections.unmodifiableList(vertices_); - } else { - return verticesBuilder_.getMessageList(); - } - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public int getVerticesCount() { - if (verticesBuilder_ == null) { - return vertices_.size(); - } else { - return verticesBuilder_.getCount(); - } - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public com.google.cloud.vision.v1p3beta1.NormalizedVertex getVertices(int index) { - if (verticesBuilder_ == null) { - return vertices_.get(index); - } else { - return verticesBuilder_.getMessage(index); - } - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public Builder setVertices( - int index, com.google.cloud.vision.v1p3beta1.NormalizedVertex value) { - if (verticesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureVerticesIsMutable(); - vertices_.set(index, value); - onChanged(); - } else { - verticesBuilder_.setMessage(index, value); - } - return this; - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public Builder setVertices( - int index, com.google.cloud.vision.v1p3beta1.NormalizedVertex.Builder builderForValue) { - if (verticesBuilder_ == null) { - ensureVerticesIsMutable(); - vertices_.set(index, builderForValue.build()); - onChanged(); - } else { - verticesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public Builder addVertices(com.google.cloud.vision.v1p3beta1.NormalizedVertex value) { - if (verticesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureVerticesIsMutable(); - vertices_.add(value); - onChanged(); - } else { - verticesBuilder_.addMessage(value); - } - return this; - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public Builder addVertices( - int index, com.google.cloud.vision.v1p3beta1.NormalizedVertex value) { - if (verticesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureVerticesIsMutable(); - vertices_.add(index, value); - onChanged(); - } else { - verticesBuilder_.addMessage(index, value); - } - return this; - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public Builder addVertices( - com.google.cloud.vision.v1p3beta1.NormalizedVertex.Builder builderForValue) { - if (verticesBuilder_ == null) { - ensureVerticesIsMutable(); - vertices_.add(builderForValue.build()); - onChanged(); - } else { - verticesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public Builder addVertices( - int index, com.google.cloud.vision.v1p3beta1.NormalizedVertex.Builder builderForValue) { - if (verticesBuilder_ == null) { - ensureVerticesIsMutable(); - vertices_.add(index, builderForValue.build()); - onChanged(); - } else { - verticesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public Builder addAllVertices( - java.lang.Iterable values) { - if (verticesBuilder_ == null) { - ensureVerticesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll(values, vertices_); - onChanged(); - } else { - verticesBuilder_.addAllMessages(values); - } - return this; - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public Builder clearVertices() { - if (verticesBuilder_ == null) { - vertices_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - verticesBuilder_.clear(); - } - return this; - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public Builder removeVertices(int index) { - if (verticesBuilder_ == null) { - ensureVerticesIsMutable(); - vertices_.remove(index); - onChanged(); - } else { - verticesBuilder_.remove(index); - } - return this; - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public com.google.cloud.vision.v1p3beta1.NormalizedVertex.Builder getVerticesBuilder( - int index) { - return getVerticesFieldBuilder().getBuilder(index); - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public com.google.cloud.vision.v1p3beta1.NormalizedVertexOrBuilder getVerticesOrBuilder( - int index) { - if (verticesBuilder_ == null) { - return vertices_.get(index); - } else { - return verticesBuilder_.getMessageOrBuilder(index); - } - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public java.util.List - getVerticesOrBuilderList() { - if (verticesBuilder_ != null) { - return verticesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(vertices_); - } - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public com.google.cloud.vision.v1p3beta1.NormalizedVertex.Builder addVerticesBuilder() { - return getVerticesFieldBuilder() - .addBuilder(com.google.cloud.vision.v1p3beta1.NormalizedVertex.getDefaultInstance()); - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public com.google.cloud.vision.v1p3beta1.NormalizedVertex.Builder addVerticesBuilder( - int index) { - return getVerticesFieldBuilder() - .addBuilder( - index, com.google.cloud.vision.v1p3beta1.NormalizedVertex.getDefaultInstance()); - } - /** - * - * - *
-     * Normalized vertices of the bounding polygon.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - public java.util.List - getVerticesBuilderList() { - return getVerticesFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.NormalizedVertex, - com.google.cloud.vision.v1p3beta1.NormalizedVertex.Builder, - com.google.cloud.vision.v1p3beta1.NormalizedVertexOrBuilder> - getVerticesFieldBuilder() { - if (verticesBuilder_ == null) { - verticesBuilder_ = - new com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.NormalizedVertex, - com.google.cloud.vision.v1p3beta1.NormalizedVertex.Builder, - com.google.cloud.vision.v1p3beta1.NormalizedVertexOrBuilder>( - vertices_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); - vertices_ = null; - } - return verticesBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.vision.v1p3beta1.NormalizedBoundingPoly) - } - - // @@protoc_insertion_point(class_scope:google.cloud.vision.v1p3beta1.NormalizedBoundingPoly) - private static final com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly(); - } - - public static com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public NormalizedBoundingPoly parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new NormalizedBoundingPoly(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/NormalizedBoundingPolyOrBuilder.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/NormalizedBoundingPolyOrBuilder.java deleted file mode 100644 index 16488c4cb..000000000 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/NormalizedBoundingPolyOrBuilder.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/vision/v1p3beta1/geometry.proto - -package com.google.cloud.vision.v1p3beta1; - -public interface NormalizedBoundingPolyOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.vision.v1p3beta1.NormalizedBoundingPoly) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Normalized vertices of the bounding polygon.
-   * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - java.util.List getVerticesList(); - /** - * - * - *
-   * Normalized vertices of the bounding polygon.
-   * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - com.google.cloud.vision.v1p3beta1.NormalizedVertex getVertices(int index); - /** - * - * - *
-   * Normalized vertices of the bounding polygon.
-   * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - int getVerticesCount(); - /** - * - * - *
-   * Normalized vertices of the bounding polygon.
-   * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - java.util.List - getVerticesOrBuilderList(); - /** - * - * - *
-   * Normalized vertices of the bounding polygon.
-   * 
- * - * repeated .google.cloud.vision.v1p3beta1.NormalizedVertex vertices = 1; - */ - com.google.cloud.vision.v1p3beta1.NormalizedVertexOrBuilder getVerticesOrBuilder(int index); -} diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchCategory.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchCategory.java deleted file mode 100644 index ca625356e..000000000 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchCategory.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/vision/v1p3beta1/product_search.proto - -package com.google.cloud.vision.v1p3beta1; - -/** - * - * - *
- * Supported product search categories.
- * 
- * - * Protobuf enum {@code google.cloud.vision.v1p3beta1.ProductSearchCategory} - */ -public enum ProductSearchCategory implements com.google.protobuf.ProtocolMessageEnum { - /** - * - * - *
-   * Default value used when a category is not specified.
-   * 
- * - * PRODUCT_SEARCH_CATEGORY_UNSPECIFIED = 0; - */ - PRODUCT_SEARCH_CATEGORY_UNSPECIFIED(0), - /** - * - * - *
-   * Shoes category.
-   * 
- * - * SHOES = 1; - */ - SHOES(1), - /** - * - * - *
-   * Bags category.
-   * 
- * - * BAGS = 2; - */ - BAGS(2), - UNRECOGNIZED(-1), - ; - - /** - * - * - *
-   * Default value used when a category is not specified.
-   * 
- * - * PRODUCT_SEARCH_CATEGORY_UNSPECIFIED = 0; - */ - public static final int PRODUCT_SEARCH_CATEGORY_UNSPECIFIED_VALUE = 0; - /** - * - * - *
-   * Shoes category.
-   * 
- * - * SHOES = 1; - */ - public static final int SHOES_VALUE = 1; - /** - * - * - *
-   * Bags category.
-   * 
- * - * BAGS = 2; - */ - public static final int BAGS_VALUE = 2; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static ProductSearchCategory valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static ProductSearchCategory forNumber(int value) { - switch (value) { - case 0: - return PRODUCT_SEARCH_CATEGORY_UNSPECIFIED; - case 1: - return SHOES; - case 2: - return BAGS; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - - private static final com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public ProductSearchCategory findValueByNumber(int number) { - return ProductSearchCategory.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return com.google.cloud.vision.v1p3beta1.ProductSearchProto.getDescriptor() - .getEnumTypes() - .get(0); - } - - private static final ProductSearchCategory[] VALUES = values(); - - public static ProductSearchCategory valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private ProductSearchCategory(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:google.cloud.vision.v1p3beta1.ProductSearchCategory) -} diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchParams.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchParams.java index f4c552600..6ac655aeb 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchParams.java +++ b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchParams.java @@ -38,10 +38,6 @@ private ProductSearchParams(com.google.protobuf.GeneratedMessageV3.Builder bu } private ProductSearchParams() { - catalogName_ = ""; - category_ = 0; - productCategory_ = ""; - view_ = 0; productSet_ = ""; productCategories_ = com.google.protobuf.LazyStringArrayList.EMPTY; filter_ = ""; @@ -77,51 +73,6 @@ private ProductSearchParams( case 0: done = true; break; - case 10: - { - java.lang.String s = input.readStringRequireUtf8(); - - catalogName_ = s; - break; - } - case 16: - { - int rawValue = input.readEnum(); - - category_ = rawValue; - break; - } - case 26: - { - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.Builder subBuilder = null; - if (normalizedBoundingPoly_ != null) { - subBuilder = normalizedBoundingPoly_.toBuilder(); - } - normalizedBoundingPoly_ = - input.readMessage( - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.parser(), - extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(normalizedBoundingPoly_); - normalizedBoundingPoly_ = subBuilder.buildPartial(); - } - - break; - } - case 32: - { - int rawValue = input.readEnum(); - - view_ = rawValue; - break; - } - case 42: - { - java.lang.String s = input.readStringRequireUtf8(); - - productCategory_ = s; - break; - } case 50: { java.lang.String s = input.readStringRequireUtf8(); @@ -201,212 +152,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.cloud.vision.v1p3beta1.ProductSearchParams.Builder.class); } - public static final int CATALOG_NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object catalogName_; - /** - * - * - *
-   * The resource name of the catalog to search.
-   * Format is: `productSearch/catalogs/CATALOG_NAME`.
-   * 
- * - * string catalog_name = 1; - * - * @return The catalogName. - */ - @java.lang.Override - public java.lang.String getCatalogName() { - java.lang.Object ref = catalogName_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - catalogName_ = s; - return s; - } - } - /** - * - * - *
-   * The resource name of the catalog to search.
-   * Format is: `productSearch/catalogs/CATALOG_NAME`.
-   * 
- * - * string catalog_name = 1; - * - * @return The bytes for catalogName. - */ - @java.lang.Override - public com.google.protobuf.ByteString getCatalogNameBytes() { - java.lang.Object ref = catalogName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - catalogName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int CATEGORY_FIELD_NUMBER = 2; - private int category_; - /** - * - * - *
-   * The category to search in.
-   * Optional. It is inferred by the system if it is not specified.
-   * [Deprecated] Use `product_category`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 2; - * - * @return The enum numeric value on the wire for category. - */ - @java.lang.Override - public int getCategoryValue() { - return category_; - } - /** - * - * - *
-   * The category to search in.
-   * Optional. It is inferred by the system if it is not specified.
-   * [Deprecated] Use `product_category`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 2; - * - * @return The category. - */ - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchCategory getCategory() { - @SuppressWarnings("deprecation") - com.google.cloud.vision.v1p3beta1.ProductSearchCategory result = - com.google.cloud.vision.v1p3beta1.ProductSearchCategory.valueOf(category_); - return result == null - ? com.google.cloud.vision.v1p3beta1.ProductSearchCategory.UNRECOGNIZED - : result; - } - - public static final int PRODUCT_CATEGORY_FIELD_NUMBER = 5; - private volatile java.lang.Object productCategory_; - /** - * - * - *
-   * The product category to search in.
-   * Optional. It is inferred by the system if it is not specified.
-   * Supported values are `bag`, `shoe`, `sunglasses`, `dress`, `outerwear`,
-   * `skirt`, `top`, `shorts`, and `pants`.
-   * 
- * - * string product_category = 5; - * - * @return The productCategory. - */ - @java.lang.Override - public java.lang.String getProductCategory() { - java.lang.Object ref = productCategory_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - productCategory_ = s; - return s; - } - } - /** - * - * - *
-   * The product category to search in.
-   * Optional. It is inferred by the system if it is not specified.
-   * Supported values are `bag`, `shoe`, `sunglasses`, `dress`, `outerwear`,
-   * `skirt`, `top`, `shorts`, and `pants`.
-   * 
- * - * string product_category = 5; - * - * @return The bytes for productCategory. - */ - @java.lang.Override - public com.google.protobuf.ByteString getProductCategoryBytes() { - java.lang.Object ref = productCategory_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - productCategory_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int NORMALIZED_BOUNDING_POLY_FIELD_NUMBER = 3; - private com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalizedBoundingPoly_; - /** - * - * - *
-   * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
-   * [Deprecated] Use `bounding_poly`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - * - * @return Whether the normalizedBoundingPoly field is set. - */ - @java.lang.Override - public boolean hasNormalizedBoundingPoly() { - return normalizedBoundingPoly_ != null; - } - /** - * - * - *
-   * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
-   * [Deprecated] Use `bounding_poly`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - * - * @return The normalizedBoundingPoly. - */ - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly getNormalizedBoundingPoly() { - return normalizedBoundingPoly_ == null - ? com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.getDefaultInstance() - : normalizedBoundingPoly_; - } - /** - * - * - *
-   * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
-   * [Deprecated] Use `bounding_poly`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - */ - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.NormalizedBoundingPolyOrBuilder - getNormalizedBoundingPolyOrBuilder() { - return getNormalizedBoundingPoly(); - } - public static final int BOUNDING_POLY_FIELD_NUMBER = 9; private com.google.cloud.vision.v1p3beta1.BoundingPoly boundingPoly_; /** @@ -414,7 +159,7 @@ public com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly getNormalizedBou * *
    * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
+   * If it is not specified, system discretion will be applied.
    * 
* * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; @@ -430,7 +175,7 @@ public boolean hasBoundingPoly() { * *
    * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
+   * If it is not specified, system discretion will be applied.
    * 
* * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; @@ -448,7 +193,7 @@ public com.google.cloud.vision.v1p3beta1.BoundingPoly getBoundingPoly() { * *
    * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
+   * If it is not specified, system discretion will be applied.
    * 
* * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; @@ -458,55 +203,13 @@ public com.google.cloud.vision.v1p3beta1.BoundingPolyOrBuilder getBoundingPolyOr return getBoundingPoly(); } - public static final int VIEW_FIELD_NUMBER = 4; - private int view_; - /** - * - * - *
-   * Specifies the verbosity of the  product search results.
-   * Optional. Defaults to `BASIC`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchResultsView view = 4; - * - * @return The enum numeric value on the wire for view. - */ - @java.lang.Override - public int getViewValue() { - return view_; - } - /** - * - * - *
-   * Specifies the verbosity of the  product search results.
-   * Optional. Defaults to `BASIC`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchResultsView view = 4; - * - * @return The view. - */ - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResultsView getView() { - @SuppressWarnings("deprecation") - com.google.cloud.vision.v1p3beta1.ProductSearchResultsView result = - com.google.cloud.vision.v1p3beta1.ProductSearchResultsView.valueOf(view_); - return result == null - ? com.google.cloud.vision.v1p3beta1.ProductSearchResultsView.UNRECOGNIZED - : result; - } - public static final int PRODUCT_SET_FIELD_NUMBER = 6; private volatile java.lang.Object productSet_; /** * * *
-   * The resource name of a
-   * [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for
-   * similar images.
+   * The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images.
    * Format is:
    * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
    * 
@@ -531,9 +234,7 @@ public java.lang.String getProductSet() { * * *
-   * The resource name of a
-   * [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for
-   * similar images.
+   * The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images.
    * Format is:
    * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
    * 
@@ -562,8 +263,12 @@ public com.google.protobuf.ByteString getProductSetBytes() { * *
    * The list of product categories to search in. Currently, we only consider
-   * the first category, and either "homegoods" or "apparel" should be
-   * specified.
+   * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+   * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+   * categories "homegoods", "apparel", and "toys" are still supported but will
+   * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+   * or "toys-v2" for better product search accuracy. It is recommended to
+   * migrate existing products to these categories as well.
    * 
* * repeated string product_categories = 7; @@ -578,8 +283,12 @@ public com.google.protobuf.ProtocolStringList getProductCategoriesList() { * *
    * The list of product categories to search in. Currently, we only consider
-   * the first category, and either "homegoods" or "apparel" should be
-   * specified.
+   * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+   * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+   * categories "homegoods", "apparel", and "toys" are still supported but will
+   * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+   * or "toys-v2" for better product search accuracy. It is recommended to
+   * migrate existing products to these categories as well.
    * 
* * repeated string product_categories = 7; @@ -594,8 +303,12 @@ public int getProductCategoriesCount() { * *
    * The list of product categories to search in. Currently, we only consider
-   * the first category, and either "homegoods" or "apparel" should be
-   * specified.
+   * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+   * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+   * categories "homegoods", "apparel", and "toys" are still supported but will
+   * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+   * or "toys-v2" for better product search accuracy. It is recommended to
+   * migrate existing products to these categories as well.
    * 
* * repeated string product_categories = 7; @@ -611,8 +324,12 @@ public java.lang.String getProductCategories(int index) { * *
    * The list of product categories to search in. Currently, we only consider
-   * the first category, and either "homegoods" or "apparel" should be
-   * specified.
+   * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+   * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+   * categories "homegoods", "apparel", and "toys" are still supported but will
+   * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+   * or "toys-v2" for better product search accuracy. It is recommended to
+   * migrate existing products to these categories as well.
    * 
* * repeated string product_categories = 7; @@ -632,9 +349,11 @@ public com.google.protobuf.ByteString getProductCategoriesBytes(int index) { *
    * The filtering expression. This can be used to restrict search results based
    * on Product labels. We currently support an AND of OR of key-value
-   * expressions, where each expression within an OR must have the same key.
+   * expressions, where each expression within an OR must have the same key. An
+   * '=' should be used to connect the key and value.
    * For example, "(color = red OR color = blue) AND brand = Google" is
-   * acceptable, but not "(color = red OR brand = Google)" or "color: red".
+   * acceptable, but "(color = red OR brand = Google)" is not acceptable.
+   * "color: red" is not acceptable because it uses a ':' instead of an '='.
    * 
* * string filter = 8; @@ -659,9 +378,11 @@ public java.lang.String getFilter() { *
    * The filtering expression. This can be used to restrict search results based
    * on Product labels. We currently support an AND of OR of key-value
-   * expressions, where each expression within an OR must have the same key.
+   * expressions, where each expression within an OR must have the same key. An
+   * '=' should be used to connect the key and value.
    * For example, "(color = red OR color = blue) AND brand = Google" is
-   * acceptable, but not "(color = red OR brand = Google)" or "color: red".
+   * acceptable, but "(color = red OR brand = Google)" is not acceptable.
+   * "color: red" is not acceptable because it uses a ':' instead of an '='.
    * 
* * string filter = 8; @@ -695,24 +416,6 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(catalogName_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, catalogName_); - } - if (category_ - != com.google.cloud.vision.v1p3beta1.ProductSearchCategory - .PRODUCT_SEARCH_CATEGORY_UNSPECIFIED - .getNumber()) { - output.writeEnum(2, category_); - } - if (normalizedBoundingPoly_ != null) { - output.writeMessage(3, getNormalizedBoundingPoly()); - } - if (view_ != com.google.cloud.vision.v1p3beta1.ProductSearchResultsView.BASIC.getNumber()) { - output.writeEnum(4, view_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(productCategory_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, productCategory_); - } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(productSet_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 6, productSet_); } @@ -734,25 +437,6 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(catalogName_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, catalogName_); - } - if (category_ - != com.google.cloud.vision.v1p3beta1.ProductSearchCategory - .PRODUCT_SEARCH_CATEGORY_UNSPECIFIED - .getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, category_); - } - if (normalizedBoundingPoly_ != null) { - size += - com.google.protobuf.CodedOutputStream.computeMessageSize(3, getNormalizedBoundingPoly()); - } - if (view_ != com.google.cloud.vision.v1p3beta1.ProductSearchResultsView.BASIC.getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(4, view_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(productCategory_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, productCategory_); - } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(productSet_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, productSet_); } @@ -786,18 +470,10 @@ public boolean equals(final java.lang.Object obj) { com.google.cloud.vision.v1p3beta1.ProductSearchParams other = (com.google.cloud.vision.v1p3beta1.ProductSearchParams) obj; - if (!getCatalogName().equals(other.getCatalogName())) return false; - if (category_ != other.category_) return false; - if (!getProductCategory().equals(other.getProductCategory())) return false; - if (hasNormalizedBoundingPoly() != other.hasNormalizedBoundingPoly()) return false; - if (hasNormalizedBoundingPoly()) { - if (!getNormalizedBoundingPoly().equals(other.getNormalizedBoundingPoly())) return false; - } if (hasBoundingPoly() != other.hasBoundingPoly()) return false; if (hasBoundingPoly()) { if (!getBoundingPoly().equals(other.getBoundingPoly())) return false; } - if (view_ != other.view_) return false; if (!getProductSet().equals(other.getProductSet())) return false; if (!getProductCategoriesList().equals(other.getProductCategoriesList())) return false; if (!getFilter().equals(other.getFilter())) return false; @@ -812,22 +488,10 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + CATALOG_NAME_FIELD_NUMBER; - hash = (53 * hash) + getCatalogName().hashCode(); - hash = (37 * hash) + CATEGORY_FIELD_NUMBER; - hash = (53 * hash) + category_; - hash = (37 * hash) + PRODUCT_CATEGORY_FIELD_NUMBER; - hash = (53 * hash) + getProductCategory().hashCode(); - if (hasNormalizedBoundingPoly()) { - hash = (37 * hash) + NORMALIZED_BOUNDING_POLY_FIELD_NUMBER; - hash = (53 * hash) + getNormalizedBoundingPoly().hashCode(); - } if (hasBoundingPoly()) { hash = (37 * hash) + BOUNDING_POLY_FIELD_NUMBER; hash = (53 * hash) + getBoundingPoly().hashCode(); } - hash = (37 * hash) + VIEW_FIELD_NUMBER; - hash = (53 * hash) + view_; hash = (37 * hash) + PRODUCT_SET_FIELD_NUMBER; hash = (53 * hash) + getProductSet().hashCode(); if (getProductCategoriesCount() > 0) { @@ -982,26 +646,12 @@ private void maybeForceBuilderInitialization() { @java.lang.Override public Builder clear() { super.clear(); - catalogName_ = ""; - - category_ = 0; - - productCategory_ = ""; - - if (normalizedBoundingPolyBuilder_ == null) { - normalizedBoundingPoly_ = null; - } else { - normalizedBoundingPoly_ = null; - normalizedBoundingPolyBuilder_ = null; - } if (boundingPolyBuilder_ == null) { boundingPoly_ = null; } else { boundingPoly_ = null; boundingPolyBuilder_ = null; } - view_ = 0; - productSet_ = ""; productCategories_ = com.google.protobuf.LazyStringArrayList.EMPTY; @@ -1036,20 +686,11 @@ public com.google.cloud.vision.v1p3beta1.ProductSearchParams buildPartial() { com.google.cloud.vision.v1p3beta1.ProductSearchParams result = new com.google.cloud.vision.v1p3beta1.ProductSearchParams(this); int from_bitField0_ = bitField0_; - result.catalogName_ = catalogName_; - result.category_ = category_; - result.productCategory_ = productCategory_; - if (normalizedBoundingPolyBuilder_ == null) { - result.normalizedBoundingPoly_ = normalizedBoundingPoly_; - } else { - result.normalizedBoundingPoly_ = normalizedBoundingPolyBuilder_.build(); - } if (boundingPolyBuilder_ == null) { result.boundingPoly_ = boundingPoly_; } else { result.boundingPoly_ = boundingPolyBuilder_.build(); } - result.view_ = view_; result.productSet_ = productSet_; if (((bitField0_ & 0x00000001) != 0)) { productCategories_ = productCategories_.getUnmodifiableView(); @@ -1107,26 +748,9 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(com.google.cloud.vision.v1p3beta1.ProductSearchParams other) { if (other == com.google.cloud.vision.v1p3beta1.ProductSearchParams.getDefaultInstance()) return this; - if (!other.getCatalogName().isEmpty()) { - catalogName_ = other.catalogName_; - onChanged(); - } - if (other.category_ != 0) { - setCategoryValue(other.getCategoryValue()); - } - if (!other.getProductCategory().isEmpty()) { - productCategory_ = other.productCategory_; - onChanged(); - } - if (other.hasNormalizedBoundingPoly()) { - mergeNormalizedBoundingPoly(other.getNormalizedBoundingPoly()); - } if (other.hasBoundingPoly()) { mergeBoundingPoly(other.getBoundingPoly()); } - if (other.view_ != 0) { - setViewValue(other.getViewValue()); - } if (!other.getProductSet().isEmpty()) { productSet_ = other.productSet_; onChanged(); @@ -1177,633 +801,80 @@ public Builder mergeFrom( private int bitField0_; - private java.lang.Object catalogName_ = ""; + private com.google.cloud.vision.v1p3beta1.BoundingPoly boundingPoly_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.BoundingPoly, + com.google.cloud.vision.v1p3beta1.BoundingPoly.Builder, + com.google.cloud.vision.v1p3beta1.BoundingPolyOrBuilder> + boundingPolyBuilder_; /** * * *
-     * The resource name of the catalog to search.
-     * Format is: `productSearch/catalogs/CATALOG_NAME`.
+     * The bounding polygon around the area of interest in the image.
+     * If it is not specified, system discretion will be applied.
      * 
* - * string catalog_name = 1; + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; * - * @return The catalogName. + * @return Whether the boundingPoly field is set. */ - public java.lang.String getCatalogName() { - java.lang.Object ref = catalogName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - catalogName_ = s; - return s; - } else { - return (java.lang.String) ref; - } + public boolean hasBoundingPoly() { + return boundingPolyBuilder_ != null || boundingPoly_ != null; } /** * * *
-     * The resource name of the catalog to search.
-     * Format is: `productSearch/catalogs/CATALOG_NAME`.
+     * The bounding polygon around the area of interest in the image.
+     * If it is not specified, system discretion will be applied.
      * 
* - * string catalog_name = 1; + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; * - * @return The bytes for catalogName. + * @return The boundingPoly. */ - public com.google.protobuf.ByteString getCatalogNameBytes() { - java.lang.Object ref = catalogName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - catalogName_ = b; - return b; + public com.google.cloud.vision.v1p3beta1.BoundingPoly getBoundingPoly() { + if (boundingPolyBuilder_ == null) { + return boundingPoly_ == null + ? com.google.cloud.vision.v1p3beta1.BoundingPoly.getDefaultInstance() + : boundingPoly_; } else { - return (com.google.protobuf.ByteString) ref; + return boundingPolyBuilder_.getMessage(); } } /** * * *
-     * The resource name of the catalog to search.
-     * Format is: `productSearch/catalogs/CATALOG_NAME`.
+     * The bounding polygon around the area of interest in the image.
+     * If it is not specified, system discretion will be applied.
      * 
* - * string catalog_name = 1; - * - * @param value The catalogName to set. - * @return This builder for chaining. + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; */ - public Builder setCatalogName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); + public Builder setBoundingPoly(com.google.cloud.vision.v1p3beta1.BoundingPoly value) { + if (boundingPolyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + boundingPoly_ = value; + onChanged(); + } else { + boundingPolyBuilder_.setMessage(value); } - catalogName_ = value; - onChanged(); return this; } /** * * *
-     * The resource name of the catalog to search.
-     * Format is: `productSearch/catalogs/CATALOG_NAME`.
+     * The bounding polygon around the area of interest in the image.
+     * If it is not specified, system discretion will be applied.
      * 
* - * string catalog_name = 1; - * - * @return This builder for chaining. - */ - public Builder clearCatalogName() { - - catalogName_ = getDefaultInstance().getCatalogName(); - onChanged(); - return this; - } - /** - * - * - *
-     * The resource name of the catalog to search.
-     * Format is: `productSearch/catalogs/CATALOG_NAME`.
-     * 
- * - * string catalog_name = 1; - * - * @param value The bytes for catalogName to set. - * @return This builder for chaining. - */ - public Builder setCatalogNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - catalogName_ = value; - onChanged(); - return this; - } - - private int category_ = 0; - /** - * - * - *
-     * The category to search in.
-     * Optional. It is inferred by the system if it is not specified.
-     * [Deprecated] Use `product_category`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 2; - * - * @return The enum numeric value on the wire for category. - */ - @java.lang.Override - public int getCategoryValue() { - return category_; - } - /** - * - * - *
-     * The category to search in.
-     * Optional. It is inferred by the system if it is not specified.
-     * [Deprecated] Use `product_category`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 2; - * - * @param value The enum numeric value on the wire for category to set. - * @return This builder for chaining. - */ - public Builder setCategoryValue(int value) { - - category_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The category to search in.
-     * Optional. It is inferred by the system if it is not specified.
-     * [Deprecated] Use `product_category`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 2; - * - * @return The category. - */ - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchCategory getCategory() { - @SuppressWarnings("deprecation") - com.google.cloud.vision.v1p3beta1.ProductSearchCategory result = - com.google.cloud.vision.v1p3beta1.ProductSearchCategory.valueOf(category_); - return result == null - ? com.google.cloud.vision.v1p3beta1.ProductSearchCategory.UNRECOGNIZED - : result; - } - /** - * - * - *
-     * The category to search in.
-     * Optional. It is inferred by the system if it is not specified.
-     * [Deprecated] Use `product_category`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 2; - * - * @param value The category to set. - * @return This builder for chaining. - */ - public Builder setCategory(com.google.cloud.vision.v1p3beta1.ProductSearchCategory value) { - if (value == null) { - throw new NullPointerException(); - } - - category_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * The category to search in.
-     * Optional. It is inferred by the system if it is not specified.
-     * [Deprecated] Use `product_category`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 2; - * - * @return This builder for chaining. - */ - public Builder clearCategory() { - - category_ = 0; - onChanged(); - return this; - } - - private java.lang.Object productCategory_ = ""; - /** - * - * - *
-     * The product category to search in.
-     * Optional. It is inferred by the system if it is not specified.
-     * Supported values are `bag`, `shoe`, `sunglasses`, `dress`, `outerwear`,
-     * `skirt`, `top`, `shorts`, and `pants`.
-     * 
- * - * string product_category = 5; - * - * @return The productCategory. - */ - public java.lang.String getProductCategory() { - java.lang.Object ref = productCategory_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - productCategory_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The product category to search in.
-     * Optional. It is inferred by the system if it is not specified.
-     * Supported values are `bag`, `shoe`, `sunglasses`, `dress`, `outerwear`,
-     * `skirt`, `top`, `shorts`, and `pants`.
-     * 
- * - * string product_category = 5; - * - * @return The bytes for productCategory. - */ - public com.google.protobuf.ByteString getProductCategoryBytes() { - java.lang.Object ref = productCategory_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - productCategory_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The product category to search in.
-     * Optional. It is inferred by the system if it is not specified.
-     * Supported values are `bag`, `shoe`, `sunglasses`, `dress`, `outerwear`,
-     * `skirt`, `top`, `shorts`, and `pants`.
-     * 
- * - * string product_category = 5; - * - * @param value The productCategory to set. - * @return This builder for chaining. - */ - public Builder setProductCategory(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - productCategory_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The product category to search in.
-     * Optional. It is inferred by the system if it is not specified.
-     * Supported values are `bag`, `shoe`, `sunglasses`, `dress`, `outerwear`,
-     * `skirt`, `top`, `shorts`, and `pants`.
-     * 
- * - * string product_category = 5; - * - * @return This builder for chaining. - */ - public Builder clearProductCategory() { - - productCategory_ = getDefaultInstance().getProductCategory(); - onChanged(); - return this; - } - /** - * - * - *
-     * The product category to search in.
-     * Optional. It is inferred by the system if it is not specified.
-     * Supported values are `bag`, `shoe`, `sunglasses`, `dress`, `outerwear`,
-     * `skirt`, `top`, `shorts`, and `pants`.
-     * 
- * - * string product_category = 5; - * - * @param value The bytes for productCategory to set. - * @return This builder for chaining. - */ - public Builder setProductCategoryBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - productCategory_ = value; - onChanged(); - return this; - } - - private com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalizedBoundingPoly_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly, - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.Builder, - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPolyOrBuilder> - normalizedBoundingPolyBuilder_; - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * [Deprecated] Use `bounding_poly`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - * - * @return Whether the normalizedBoundingPoly field is set. - */ - public boolean hasNormalizedBoundingPoly() { - return normalizedBoundingPolyBuilder_ != null || normalizedBoundingPoly_ != null; - } - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * [Deprecated] Use `bounding_poly`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - * - * @return The normalizedBoundingPoly. - */ - public com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly getNormalizedBoundingPoly() { - if (normalizedBoundingPolyBuilder_ == null) { - return normalizedBoundingPoly_ == null - ? com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.getDefaultInstance() - : normalizedBoundingPoly_; - } else { - return normalizedBoundingPolyBuilder_.getMessage(); - } - } - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * [Deprecated] Use `bounding_poly`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - */ - public Builder setNormalizedBoundingPoly( - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly value) { - if (normalizedBoundingPolyBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - normalizedBoundingPoly_ = value; - onChanged(); - } else { - normalizedBoundingPolyBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * [Deprecated] Use `bounding_poly`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - */ - public Builder setNormalizedBoundingPoly( - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.Builder builderForValue) { - if (normalizedBoundingPolyBuilder_ == null) { - normalizedBoundingPoly_ = builderForValue.build(); - onChanged(); - } else { - normalizedBoundingPolyBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * [Deprecated] Use `bounding_poly`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - */ - public Builder mergeNormalizedBoundingPoly( - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly value) { - if (normalizedBoundingPolyBuilder_ == null) { - if (normalizedBoundingPoly_ != null) { - normalizedBoundingPoly_ = - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.newBuilder( - normalizedBoundingPoly_) - .mergeFrom(value) - .buildPartial(); - } else { - normalizedBoundingPoly_ = value; - } - onChanged(); - } else { - normalizedBoundingPolyBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * [Deprecated] Use `bounding_poly`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - */ - public Builder clearNormalizedBoundingPoly() { - if (normalizedBoundingPolyBuilder_ == null) { - normalizedBoundingPoly_ = null; - onChanged(); - } else { - normalizedBoundingPoly_ = null; - normalizedBoundingPolyBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * [Deprecated] Use `bounding_poly`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - */ - public com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.Builder - getNormalizedBoundingPolyBuilder() { - - onChanged(); - return getNormalizedBoundingPolyFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * [Deprecated] Use `bounding_poly`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - */ - public com.google.cloud.vision.v1p3beta1.NormalizedBoundingPolyOrBuilder - getNormalizedBoundingPolyOrBuilder() { - if (normalizedBoundingPolyBuilder_ != null) { - return normalizedBoundingPolyBuilder_.getMessageOrBuilder(); - } else { - return normalizedBoundingPoly_ == null - ? com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.getDefaultInstance() - : normalizedBoundingPoly_; - } - } - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * [Deprecated] Use `bounding_poly`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly, - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.Builder, - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPolyOrBuilder> - getNormalizedBoundingPolyFieldBuilder() { - if (normalizedBoundingPolyBuilder_ == null) { - normalizedBoundingPolyBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly, - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly.Builder, - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPolyOrBuilder>( - getNormalizedBoundingPoly(), getParentForChildren(), isClean()); - normalizedBoundingPoly_ = null; - } - return normalizedBoundingPolyBuilder_; - } - - private com.google.cloud.vision.v1p3beta1.BoundingPoly boundingPoly_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.BoundingPoly, - com.google.cloud.vision.v1p3beta1.BoundingPoly.Builder, - com.google.cloud.vision.v1p3beta1.BoundingPolyOrBuilder> - boundingPolyBuilder_; - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * 
- * - * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; - * - * @return Whether the boundingPoly field is set. - */ - public boolean hasBoundingPoly() { - return boundingPolyBuilder_ != null || boundingPoly_ != null; - } - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * 
- * - * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; - * - * @return The boundingPoly. - */ - public com.google.cloud.vision.v1p3beta1.BoundingPoly getBoundingPoly() { - if (boundingPolyBuilder_ == null) { - return boundingPoly_ == null - ? com.google.cloud.vision.v1p3beta1.BoundingPoly.getDefaultInstance() - : boundingPoly_; - } else { - return boundingPolyBuilder_.getMessage(); - } - } - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * 
- * - * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; - */ - public Builder setBoundingPoly(com.google.cloud.vision.v1p3beta1.BoundingPoly value) { - if (boundingPolyBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - boundingPoly_ = value; - onChanged(); - } else { - boundingPolyBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
-     * 
- * - * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; */ public Builder setBoundingPoly( com.google.cloud.vision.v1p3beta1.BoundingPoly.Builder builderForValue) { @@ -1821,7 +892,7 @@ public Builder setBoundingPoly( * *
      * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
+     * If it is not specified, system discretion will be applied.
      * 
* * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; @@ -1848,7 +919,7 @@ public Builder mergeBoundingPoly(com.google.cloud.vision.v1p3beta1.BoundingPoly * *
      * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
+     * If it is not specified, system discretion will be applied.
      * 
* * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; @@ -1869,7 +940,7 @@ public Builder clearBoundingPoly() { * *
      * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
+     * If it is not specified, system discretion will be applied.
      * 
* * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; @@ -1884,7 +955,7 @@ public com.google.cloud.vision.v1p3beta1.BoundingPoly.Builder getBoundingPolyBui * *
      * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
+     * If it is not specified, system discretion will be applied.
      * 
* * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; @@ -1903,7 +974,7 @@ public com.google.cloud.vision.v1p3beta1.BoundingPolyOrBuilder getBoundingPolyOr * *
      * The bounding polygon around the area of interest in the image.
-     * Optional. If it is not specified, system discretion will be applied.
+     * If it is not specified, system discretion will be applied.
      * 
* * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; @@ -1925,112 +996,12 @@ public com.google.cloud.vision.v1p3beta1.BoundingPolyOrBuilder getBoundingPolyOr return boundingPolyBuilder_; } - private int view_ = 0; - /** - * - * - *
-     * Specifies the verbosity of the  product search results.
-     * Optional. Defaults to `BASIC`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchResultsView view = 4; - * - * @return The enum numeric value on the wire for view. - */ - @java.lang.Override - public int getViewValue() { - return view_; - } - /** - * - * - *
-     * Specifies the verbosity of the  product search results.
-     * Optional. Defaults to `BASIC`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchResultsView view = 4; - * - * @param value The enum numeric value on the wire for view to set. - * @return This builder for chaining. - */ - public Builder setViewValue(int value) { - - view_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Specifies the verbosity of the  product search results.
-     * Optional. Defaults to `BASIC`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchResultsView view = 4; - * - * @return The view. - */ - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResultsView getView() { - @SuppressWarnings("deprecation") - com.google.cloud.vision.v1p3beta1.ProductSearchResultsView result = - com.google.cloud.vision.v1p3beta1.ProductSearchResultsView.valueOf(view_); - return result == null - ? com.google.cloud.vision.v1p3beta1.ProductSearchResultsView.UNRECOGNIZED - : result; - } - /** - * - * - *
-     * Specifies the verbosity of the  product search results.
-     * Optional. Defaults to `BASIC`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchResultsView view = 4; - * - * @param value The view to set. - * @return This builder for chaining. - */ - public Builder setView(com.google.cloud.vision.v1p3beta1.ProductSearchResultsView value) { - if (value == null) { - throw new NullPointerException(); - } - - view_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * Specifies the verbosity of the  product search results.
-     * Optional. Defaults to `BASIC`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchResultsView view = 4; - * - * @return This builder for chaining. - */ - public Builder clearView() { - - view_ = 0; - onChanged(); - return this; - } - private java.lang.Object productSet_ = ""; /** * * *
-     * The resource name of a
-     * [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for
-     * similar images.
+     * The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images.
      * Format is:
      * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
      * 
@@ -2054,9 +1025,7 @@ public java.lang.String getProductSet() { * * *
-     * The resource name of a
-     * [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for
-     * similar images.
+     * The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images.
      * Format is:
      * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
      * 
@@ -2080,9 +1049,7 @@ public com.google.protobuf.ByteString getProductSetBytes() { * * *
-     * The resource name of a
-     * [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for
-     * similar images.
+     * The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images.
      * Format is:
      * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
      * 
@@ -2105,9 +1072,7 @@ public Builder setProductSet(java.lang.String value) { * * *
-     * The resource name of a
-     * [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for
-     * similar images.
+     * The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images.
      * Format is:
      * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
      * 
@@ -2126,9 +1091,7 @@ public Builder clearProductSet() { * * *
-     * The resource name of a
-     * [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for
-     * similar images.
+     * The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images.
      * Format is:
      * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
      * 
@@ -2163,8 +1126,12 @@ private void ensureProductCategoriesIsMutable() { * *
      * The list of product categories to search in. Currently, we only consider
-     * the first category, and either "homegoods" or "apparel" should be
-     * specified.
+     * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+     * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+     * categories "homegoods", "apparel", and "toys" are still supported but will
+     * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+     * or "toys-v2" for better product search accuracy. It is recommended to
+     * migrate existing products to these categories as well.
      * 
* * repeated string product_categories = 7; @@ -2179,8 +1146,12 @@ public com.google.protobuf.ProtocolStringList getProductCategoriesList() { * *
      * The list of product categories to search in. Currently, we only consider
-     * the first category, and either "homegoods" or "apparel" should be
-     * specified.
+     * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+     * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+     * categories "homegoods", "apparel", and "toys" are still supported but will
+     * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+     * or "toys-v2" for better product search accuracy. It is recommended to
+     * migrate existing products to these categories as well.
      * 
* * repeated string product_categories = 7; @@ -2195,8 +1166,12 @@ public int getProductCategoriesCount() { * *
      * The list of product categories to search in. Currently, we only consider
-     * the first category, and either "homegoods" or "apparel" should be
-     * specified.
+     * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+     * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+     * categories "homegoods", "apparel", and "toys" are still supported but will
+     * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+     * or "toys-v2" for better product search accuracy. It is recommended to
+     * migrate existing products to these categories as well.
      * 
* * repeated string product_categories = 7; @@ -2212,8 +1187,12 @@ public java.lang.String getProductCategories(int index) { * *
      * The list of product categories to search in. Currently, we only consider
-     * the first category, and either "homegoods" or "apparel" should be
-     * specified.
+     * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+     * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+     * categories "homegoods", "apparel", and "toys" are still supported but will
+     * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+     * or "toys-v2" for better product search accuracy. It is recommended to
+     * migrate existing products to these categories as well.
      * 
* * repeated string product_categories = 7; @@ -2229,8 +1208,12 @@ public com.google.protobuf.ByteString getProductCategoriesBytes(int index) { * *
      * The list of product categories to search in. Currently, we only consider
-     * the first category, and either "homegoods" or "apparel" should be
-     * specified.
+     * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+     * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+     * categories "homegoods", "apparel", and "toys" are still supported but will
+     * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+     * or "toys-v2" for better product search accuracy. It is recommended to
+     * migrate existing products to these categories as well.
      * 
* * repeated string product_categories = 7; @@ -2253,8 +1236,12 @@ public Builder setProductCategories(int index, java.lang.String value) { * *
      * The list of product categories to search in. Currently, we only consider
-     * the first category, and either "homegoods" or "apparel" should be
-     * specified.
+     * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+     * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+     * categories "homegoods", "apparel", and "toys" are still supported but will
+     * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+     * or "toys-v2" for better product search accuracy. It is recommended to
+     * migrate existing products to these categories as well.
      * 
* * repeated string product_categories = 7; @@ -2276,8 +1263,12 @@ public Builder addProductCategories(java.lang.String value) { * *
      * The list of product categories to search in. Currently, we only consider
-     * the first category, and either "homegoods" or "apparel" should be
-     * specified.
+     * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+     * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+     * categories "homegoods", "apparel", and "toys" are still supported but will
+     * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+     * or "toys-v2" for better product search accuracy. It is recommended to
+     * migrate existing products to these categories as well.
      * 
* * repeated string product_categories = 7; @@ -2296,8 +1287,12 @@ public Builder addAllProductCategories(java.lang.Iterable valu * *
      * The list of product categories to search in. Currently, we only consider
-     * the first category, and either "homegoods" or "apparel" should be
-     * specified.
+     * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+     * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+     * categories "homegoods", "apparel", and "toys" are still supported but will
+     * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+     * or "toys-v2" for better product search accuracy. It is recommended to
+     * migrate existing products to these categories as well.
      * 
* * repeated string product_categories = 7; @@ -2315,8 +1310,12 @@ public Builder clearProductCategories() { * *
      * The list of product categories to search in. Currently, we only consider
-     * the first category, and either "homegoods" or "apparel" should be
-     * specified.
+     * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+     * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+     * categories "homegoods", "apparel", and "toys" are still supported but will
+     * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+     * or "toys-v2" for better product search accuracy. It is recommended to
+     * migrate existing products to these categories as well.
      * 
* * repeated string product_categories = 7; @@ -2342,9 +1341,11 @@ public Builder addProductCategoriesBytes(com.google.protobuf.ByteString value) { *
      * The filtering expression. This can be used to restrict search results based
      * on Product labels. We currently support an AND of OR of key-value
-     * expressions, where each expression within an OR must have the same key.
+     * expressions, where each expression within an OR must have the same key. An
+     * '=' should be used to connect the key and value.
      * For example, "(color = red OR color = blue) AND brand = Google" is
-     * acceptable, but not "(color = red OR brand = Google)" or "color: red".
+     * acceptable, but "(color = red OR brand = Google)" is not acceptable.
+     * "color: red" is not acceptable because it uses a ':' instead of an '='.
      * 
* * string filter = 8; @@ -2368,9 +1369,11 @@ public java.lang.String getFilter() { *
      * The filtering expression. This can be used to restrict search results based
      * on Product labels. We currently support an AND of OR of key-value
-     * expressions, where each expression within an OR must have the same key.
+     * expressions, where each expression within an OR must have the same key. An
+     * '=' should be used to connect the key and value.
      * For example, "(color = red OR color = blue) AND brand = Google" is
-     * acceptable, but not "(color = red OR brand = Google)" or "color: red".
+     * acceptable, but "(color = red OR brand = Google)" is not acceptable.
+     * "color: red" is not acceptable because it uses a ':' instead of an '='.
      * 
* * string filter = 8; @@ -2394,9 +1397,11 @@ public com.google.protobuf.ByteString getFilterBytes() { *
      * The filtering expression. This can be used to restrict search results based
      * on Product labels. We currently support an AND of OR of key-value
-     * expressions, where each expression within an OR must have the same key.
+     * expressions, where each expression within an OR must have the same key. An
+     * '=' should be used to connect the key and value.
      * For example, "(color = red OR color = blue) AND brand = Google" is
-     * acceptable, but not "(color = red OR brand = Google)" or "color: red".
+     * acceptable, but "(color = red OR brand = Google)" is not acceptable.
+     * "color: red" is not acceptable because it uses a ':' instead of an '='.
      * 
* * string filter = 8; @@ -2419,9 +1424,11 @@ public Builder setFilter(java.lang.String value) { *
      * The filtering expression. This can be used to restrict search results based
      * on Product labels. We currently support an AND of OR of key-value
-     * expressions, where each expression within an OR must have the same key.
+     * expressions, where each expression within an OR must have the same key. An
+     * '=' should be used to connect the key and value.
      * For example, "(color = red OR color = blue) AND brand = Google" is
-     * acceptable, but not "(color = red OR brand = Google)" or "color: red".
+     * acceptable, but "(color = red OR brand = Google)" is not acceptable.
+     * "color: red" is not acceptable because it uses a ':' instead of an '='.
      * 
* * string filter = 8; @@ -2440,9 +1447,11 @@ public Builder clearFilter() { *
      * The filtering expression. This can be used to restrict search results based
      * on Product labels. We currently support an AND of OR of key-value
-     * expressions, where each expression within an OR must have the same key.
+     * expressions, where each expression within an OR must have the same key. An
+     * '=' should be used to connect the key and value.
      * For example, "(color = red OR color = blue) AND brand = Google" is
-     * acceptable, but not "(color = red OR brand = Google)" or "color: red".
+     * acceptable, but "(color = red OR brand = Google)" is not acceptable.
+     * "color: red" is not acceptable because it uses a ':' instead of an '='.
      * 
* * string filter = 8; diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchParamsOrBuilder.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchParamsOrBuilder.java index ed6a7c0fe..e798327c6 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchParamsOrBuilder.java +++ b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchParamsOrBuilder.java @@ -23,144 +23,12 @@ public interface ProductSearchParamsOrBuilder // @@protoc_insertion_point(interface_extends:google.cloud.vision.v1p3beta1.ProductSearchParams) com.google.protobuf.MessageOrBuilder { - /** - * - * - *
-   * The resource name of the catalog to search.
-   * Format is: `productSearch/catalogs/CATALOG_NAME`.
-   * 
- * - * string catalog_name = 1; - * - * @return The catalogName. - */ - java.lang.String getCatalogName(); - /** - * - * - *
-   * The resource name of the catalog to search.
-   * Format is: `productSearch/catalogs/CATALOG_NAME`.
-   * 
- * - * string catalog_name = 1; - * - * @return The bytes for catalogName. - */ - com.google.protobuf.ByteString getCatalogNameBytes(); - - /** - * - * - *
-   * The category to search in.
-   * Optional. It is inferred by the system if it is not specified.
-   * [Deprecated] Use `product_category`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 2; - * - * @return The enum numeric value on the wire for category. - */ - int getCategoryValue(); - /** - * - * - *
-   * The category to search in.
-   * Optional. It is inferred by the system if it is not specified.
-   * [Deprecated] Use `product_category`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 2; - * - * @return The category. - */ - com.google.cloud.vision.v1p3beta1.ProductSearchCategory getCategory(); - - /** - * - * - *
-   * The product category to search in.
-   * Optional. It is inferred by the system if it is not specified.
-   * Supported values are `bag`, `shoe`, `sunglasses`, `dress`, `outerwear`,
-   * `skirt`, `top`, `shorts`, and `pants`.
-   * 
- * - * string product_category = 5; - * - * @return The productCategory. - */ - java.lang.String getProductCategory(); - /** - * - * - *
-   * The product category to search in.
-   * Optional. It is inferred by the system if it is not specified.
-   * Supported values are `bag`, `shoe`, `sunglasses`, `dress`, `outerwear`,
-   * `skirt`, `top`, `shorts`, and `pants`.
-   * 
- * - * string product_category = 5; - * - * @return The bytes for productCategory. - */ - com.google.protobuf.ByteString getProductCategoryBytes(); - - /** - * - * - *
-   * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
-   * [Deprecated] Use `bounding_poly`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - * - * @return Whether the normalizedBoundingPoly field is set. - */ - boolean hasNormalizedBoundingPoly(); /** * * *
    * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
-   * [Deprecated] Use `bounding_poly`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - * - * @return The normalizedBoundingPoly. - */ - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPoly getNormalizedBoundingPoly(); - /** - * - * - *
-   * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
-   * [Deprecated] Use `bounding_poly`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.NormalizedBoundingPoly normalized_bounding_poly = 3; - * - */ - com.google.cloud.vision.v1p3beta1.NormalizedBoundingPolyOrBuilder - getNormalizedBoundingPolyOrBuilder(); - - /** - * - * - *
-   * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
+   * If it is not specified, system discretion will be applied.
    * 
* * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; @@ -173,7 +41,7 @@ public interface ProductSearchParamsOrBuilder * *
    * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
+   * If it is not specified, system discretion will be applied.
    * 
* * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; @@ -186,7 +54,7 @@ public interface ProductSearchParamsOrBuilder * *
    * The bounding polygon around the area of interest in the image.
-   * Optional. If it is not specified, system discretion will be applied.
+   * If it is not specified, system discretion will be applied.
    * 
* * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 9; @@ -197,36 +65,7 @@ public interface ProductSearchParamsOrBuilder * * *
-   * Specifies the verbosity of the  product search results.
-   * Optional. Defaults to `BASIC`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchResultsView view = 4; - * - * @return The enum numeric value on the wire for view. - */ - int getViewValue(); - /** - * - * - *
-   * Specifies the verbosity of the  product search results.
-   * Optional. Defaults to `BASIC`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchResultsView view = 4; - * - * @return The view. - */ - com.google.cloud.vision.v1p3beta1.ProductSearchResultsView getView(); - - /** - * - * - *
-   * The resource name of a
-   * [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for
-   * similar images.
+   * The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images.
    * Format is:
    * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
    * 
@@ -240,9 +79,7 @@ public interface ProductSearchParamsOrBuilder * * *
-   * The resource name of a
-   * [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for
-   * similar images.
+   * The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images.
    * Format is:
    * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
    * 
@@ -258,8 +95,12 @@ public interface ProductSearchParamsOrBuilder * *
    * The list of product categories to search in. Currently, we only consider
-   * the first category, and either "homegoods" or "apparel" should be
-   * specified.
+   * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+   * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+   * categories "homegoods", "apparel", and "toys" are still supported but will
+   * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+   * or "toys-v2" for better product search accuracy. It is recommended to
+   * migrate existing products to these categories as well.
    * 
* * repeated string product_categories = 7; @@ -272,8 +113,12 @@ public interface ProductSearchParamsOrBuilder * *
    * The list of product categories to search in. Currently, we only consider
-   * the first category, and either "homegoods" or "apparel" should be
-   * specified.
+   * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+   * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+   * categories "homegoods", "apparel", and "toys" are still supported but will
+   * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+   * or "toys-v2" for better product search accuracy. It is recommended to
+   * migrate existing products to these categories as well.
    * 
* * repeated string product_categories = 7; @@ -286,8 +131,12 @@ public interface ProductSearchParamsOrBuilder * *
    * The list of product categories to search in. Currently, we only consider
-   * the first category, and either "homegoods" or "apparel" should be
-   * specified.
+   * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+   * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+   * categories "homegoods", "apparel", and "toys" are still supported but will
+   * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+   * or "toys-v2" for better product search accuracy. It is recommended to
+   * migrate existing products to these categories as well.
    * 
* * repeated string product_categories = 7; @@ -301,8 +150,12 @@ public interface ProductSearchParamsOrBuilder * *
    * The list of product categories to search in. Currently, we only consider
-   * the first category, and either "homegoods" or "apparel" should be
-   * specified.
+   * the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
+   * "packagedgoods-v1", or "general-v1" should be specified. The legacy
+   * categories "homegoods", "apparel", and "toys" are still supported but will
+   * be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
+   * or "toys-v2" for better product search accuracy. It is recommended to
+   * migrate existing products to these categories as well.
    * 
* * repeated string product_categories = 7; @@ -318,9 +171,11 @@ public interface ProductSearchParamsOrBuilder *
    * The filtering expression. This can be used to restrict search results based
    * on Product labels. We currently support an AND of OR of key-value
-   * expressions, where each expression within an OR must have the same key.
+   * expressions, where each expression within an OR must have the same key. An
+   * '=' should be used to connect the key and value.
    * For example, "(color = red OR color = blue) AND brand = Google" is
-   * acceptable, but not "(color = red OR brand = Google)" or "color: red".
+   * acceptable, but "(color = red OR brand = Google)" is not acceptable.
+   * "color: red" is not acceptable because it uses a ':' instead of an '='.
    * 
* * string filter = 8; @@ -334,9 +189,11 @@ public interface ProductSearchParamsOrBuilder *
    * The filtering expression. This can be used to restrict search results based
    * on Product labels. We currently support an AND of OR of key-value
-   * expressions, where each expression within an OR must have the same key.
+   * expressions, where each expression within an OR must have the same key. An
+   * '=' should be used to connect the key and value.
    * For example, "(color = red OR color = blue) AND brand = Google" is
-   * acceptable, but not "(color = red OR brand = Google)" or "color: red".
+   * acceptable, but "(color = red OR brand = Google)" is not acceptable.
+   * "color: red" is not acceptable because it uses a ':' instead of an '='.
    * 
* * string filter = 8; diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchProto.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchProto.java index 2a7a4f907..5518a1acc 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchProto.java +++ b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchProto.java @@ -35,14 +35,18 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ProductInfo_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ProductInfo_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ObjectAnnotation_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ObjectAnnotation_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_GroupedResult_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_GroupedResult_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; @@ -54,49 +58,42 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { java.lang.String[] descriptorData = { "\n2google/cloud/vision/v1p3beta1/product_" + "search.proto\022\035google.cloud.vision.v1p3be" - + "ta1\032\034google/api/annotations.proto\032\031googl" - + "e/api/resource.proto\032,google/cloud/visio" - + "n/v1p3beta1/geometry.proto\032:google/cloud" - + "/vision/v1p3beta1/product_search_service" - + ".proto\032\037google/protobuf/timestamp.proto\"" - + "\331\003\n\023ProductSearchParams\022\024\n\014catalog_name\030" - + "\001 \001(\t\022F\n\010category\030\002 \001(\01624.google.cloud.v" - + "ision.v1p3beta1.ProductSearchCategory\022\030\n" - + "\020product_category\030\005 \001(\t\022W\n\030normalized_bo" - + "unding_poly\030\003 \001(\01325.google.cloud.vision." - + "v1p3beta1.NormalizedBoundingPoly\022B\n\rboun" - + "ding_poly\030\t \001(\0132+.google.cloud.vision.v1" - + "p3beta1.BoundingPoly\022E\n\004view\030\004 \001(\01627.goo" - + "gle.cloud.vision.v1p3beta1.ProductSearch" - + "ResultsView\022:\n\013product_set\030\006 \001(\tB%\372A\"\n v" - + "ision.googleapis.com/ProductSet\022\032\n\022produ" - + "ct_categories\030\007 \003(\t\022\016\n\006filter\030\010 \001(\t\"\356\003\n\024" - + "ProductSearchResults\022F\n\010category\030\001 \001(\01624" - + ".google.cloud.vision.v1p3beta1.ProductSe" - + "archCategory\022\030\n\020product_category\030\004 \001(\t\022." - + "\n\nindex_time\030\002 \001(\0132\032.google.protobuf.Tim" - + "estamp\022Q\n\010products\030\003 \003(\0132?.google.cloud." - + "vision.v1p3beta1.ProductSearchResults.Pr" - + "oductInfo\022K\n\007results\030\005 \003(\0132:.google.clou" - + "d.vision.v1p3beta1.ProductSearchResults." - + "Result\032C\n\013ProductInfo\022\022\n\nproduct_id\030\001 \001(" - + "\t\022\021\n\timage_uri\030\002 \001(\t\022\r\n\005score\030\003 \001(\002\032_\n\006R" - + "esult\0227\n\007product\030\001 \001(\0132&.google.cloud.vi" - + "sion.v1p3beta1.Product\022\r\n\005score\030\002 \001(\002\022\r\n" - + "\005image\030\003 \001(\t*U\n\025ProductSearchCategory\022\'\n" - + "#PRODUCT_SEARCH_CATEGORY_UNSPECIFIED\020\000\022\t" - + "\n\005SHOES\020\001\022\010\n\004BAGS\020\002*/\n\030ProductSearchResu" - + "ltsView\022\t\n\005BASIC\020\000\022\010\n\004FULL\020\001B\201\001\n!com.goo" - + "gle.cloud.vision.v1p3beta1B\022ProductSearc" - + "hProtoP\001ZCgoogle.golang.org/genproto/goo" - + "gleapis/cloud/vision/v1p3beta1;vision\370\001\001" - + "b\006proto3" + + "ta1\032\031google/api/resource.proto\032,google/c" + + "loud/vision/v1p3beta1/geometry.proto\032:go" + + "ogle/cloud/vision/v1p3beta1/product_sear" + + "ch_service.proto\032\037google/protobuf/timest" + + "amp.proto\"\301\001\n\023ProductSearchParams\022B\n\rbou" + + "nding_poly\030\t \001(\0132+.google.cloud.vision.v" + + "1p3beta1.BoundingPoly\022:\n\013product_set\030\006 \001" + + "(\tB%\372A\"\n vision.googleapis.com/ProductSe" + + "t\022\032\n\022product_categories\030\007 \003(\t\022\016\n\006filter\030" + + "\010 \001(\t\"\262\005\n\024ProductSearchResults\022.\n\nindex_" + + "time\030\002 \001(\0132\032.google.protobuf.Timestamp\022K" + + "\n\007results\030\005 \003(\0132:.google.cloud.vision.v1" + + "p3beta1.ProductSearchResults.Result\022b\n\027p" + + "roduct_grouped_results\030\006 \003(\0132A.google.cl" + + "oud.vision.v1p3beta1.ProductSearchResult" + + "s.GroupedResult\032_\n\006Result\0227\n\007product\030\001 \001" + + "(\0132&.google.cloud.vision.v1p3beta1.Produ" + + "ct\022\r\n\005score\030\002 \001(\002\022\r\n\005image\030\003 \001(\t\032S\n\020Obje" + + "ctAnnotation\022\013\n\003mid\030\001 \001(\t\022\025\n\rlanguage_co" + + "de\030\002 \001(\t\022\014\n\004name\030\003 \001(\t\022\r\n\005score\030\004 \001(\002\032\202\002" + + "\n\rGroupedResult\022B\n\rbounding_poly\030\001 \001(\0132+" + + ".google.cloud.vision.v1p3beta1.BoundingP" + + "oly\022K\n\007results\030\002 \003(\0132:.google.cloud.visi" + + "on.v1p3beta1.ProductSearchResults.Result" + + "\022`\n\022object_annotations\030\003 \003(\0132D.google.cl" + + "oud.vision.v1p3beta1.ProductSearchResult" + + "s.ObjectAnnotationB\210\001\n!com.google.cloud." + + "vision.v1p3beta1B\022ProductSearchProtoP\001ZC" + + "google.golang.org/genproto/googleapis/cl" + + "oud/vision/v1p3beta1;vision\370\001\001\242\002\004GCVNb\006p" + + "roto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.api.AnnotationsProto.getDescriptor(), com.google.api.ResourceProto.getDescriptor(), com.google.cloud.vision.v1p3beta1.GeometryProto.getDescriptor(), com.google.cloud.vision.v1p3beta1.ProductSearchServiceProto.getDescriptor(), @@ -108,15 +105,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_cloud_vision_v1p3beta1_ProductSearchParams_descriptor, new java.lang.String[] { - "CatalogName", - "Category", - "ProductCategory", - "NormalizedBoundingPoly", - "BoundingPoly", - "View", - "ProductSet", - "ProductCategories", - "Filter", + "BoundingPoly", "ProductSet", "ProductCategories", "Filter", }); internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_descriptor = getDescriptor().getMessageTypes().get(1); @@ -124,34 +113,43 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_descriptor, new java.lang.String[] { - "Category", "ProductCategory", "IndexTime", "Products", "Results", + "IndexTime", "Results", "ProductGroupedResults", }); - internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ProductInfo_descriptor = + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_descriptor = internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_descriptor .getNestedTypes() .get(0); - internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ProductInfo_fieldAccessorTable = + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ProductInfo_descriptor, + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_descriptor, new java.lang.String[] { - "ProductId", "ImageUri", "Score", + "Product", "Score", "Image", }); - internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_descriptor = + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ObjectAnnotation_descriptor = internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_descriptor .getNestedTypes() .get(1); - internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_fieldAccessorTable = + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ObjectAnnotation_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_descriptor, + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ObjectAnnotation_descriptor, new java.lang.String[] { - "Product", "Score", "Image", + "Mid", "LanguageCode", "Name", "Score", + }); + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_GroupedResult_descriptor = + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_descriptor + .getNestedTypes() + .get(2); + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_GroupedResult_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_GroupedResult_descriptor, + new java.lang.String[] { + "BoundingPoly", "Results", "ObjectAnnotations", }); com.google.protobuf.ExtensionRegistry registry = com.google.protobuf.ExtensionRegistry.newInstance(); registry.add(com.google.api.ResourceProto.resourceReference); com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( descriptor, registry); - com.google.api.AnnotationsProto.getDescriptor(); com.google.api.ResourceProto.getDescriptor(); com.google.cloud.vision.v1p3beta1.GeometryProto.getDescriptor(); com.google.cloud.vision.v1p3beta1.ProductSearchServiceProto.getDescriptor(); diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchResults.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchResults.java index 7e4e44a9a..cc0650251 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchResults.java +++ b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchResults.java @@ -38,10 +38,8 @@ private ProductSearchResults(com.google.protobuf.GeneratedMessageV3.Builder b } private ProductSearchResults() { - category_ = 0; - productCategory_ = ""; - products_ = java.util.Collections.emptyList(); results_ = java.util.Collections.emptyList(); + productGroupedResults_ = java.util.Collections.emptyList(); } @java.lang.Override @@ -74,13 +72,6 @@ private ProductSearchResults( case 0: done = true; break; - case 8: - { - int rawValue = input.readEnum(); - - category_ = rawValue; - break; - } case 18: { com.google.protobuf.Timestamp.Builder subBuilder = null; @@ -96,38 +87,31 @@ private ProductSearchResults( break; } - case 26: + case 42: { if (!((mutable_bitField0_ & 0x00000001) != 0)) { - products_ = + results_ = new java.util.ArrayList< - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo>(); + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result>(); mutable_bitField0_ |= 0x00000001; } - products_.add( + results_.add( input.readMessage( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.parser(), + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.parser(), extensionRegistry)); break; } - case 34: - { - java.lang.String s = input.readStringRequireUtf8(); - - productCategory_ = s; - break; - } - case 42: + case 50: { if (!((mutable_bitField0_ & 0x00000002) != 0)) { - results_ = + productGroupedResults_ = new java.util.ArrayList< - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result>(); + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult>(); mutable_bitField0_ |= 0x00000002; } - results_.add( + productGroupedResults_.add( input.readMessage( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.parser(), + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.parser(), extensionRegistry)); break; } @@ -148,10 +132,10 @@ private ProductSearchResults( throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { if (((mutable_bitField0_ & 0x00000001) != 0)) { - products_ = java.util.Collections.unmodifiableList(products_); + results_ = java.util.Collections.unmodifiableList(results_); } if (((mutable_bitField0_ & 0x00000002) != 0)) { - results_ = java.util.Collections.unmodifiableList(results_); + productGroupedResults_ = java.util.Collections.unmodifiableList(productGroupedResults_); } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); @@ -173,80 +157,86 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.cloud.vision.v1p3beta1.ProductSearchResults.Builder.class); } - public interface ProductInfoOrBuilder + public interface ResultOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo) + // @@protoc_insertion_point(interface_extends:google.cloud.vision.v1p3beta1.ProductSearchResults.Result) com.google.protobuf.MessageOrBuilder { /** * * *
-     * Product ID.
+     * The Product.
      * 
* - * string product_id = 1; + * .google.cloud.vision.v1p3beta1.Product product = 1; * - * @return The productId. + * @return Whether the product field is set. */ - java.lang.String getProductId(); + boolean hasProduct(); /** * * *
-     * Product ID.
+     * The Product.
      * 
* - * string product_id = 1; + * .google.cloud.vision.v1p3beta1.Product product = 1; + * + * @return The product. + */ + com.google.cloud.vision.v1p3beta1.Product getProduct(); + /** + * + * + *
+     * The Product.
+     * 
* - * @return The bytes for productId. + * .google.cloud.vision.v1p3beta1.Product product = 1; */ - com.google.protobuf.ByteString getProductIdBytes(); + com.google.cloud.vision.v1p3beta1.ProductOrBuilder getProductOrBuilder(); /** * * *
-     * The URI of the image which matched the query image.
-     * This field is returned only if `view` is set to `FULL` in
-     * the request.
+     * A confidence level on the match, ranging from 0 (no confidence) to
+     * 1 (full confidence).
      * 
* - * string image_uri = 2; + * float score = 2; * - * @return The imageUri. + * @return The score. */ - java.lang.String getImageUri(); + float getScore(); + /** * * *
-     * The URI of the image which matched the query image.
-     * This field is returned only if `view` is set to `FULL` in
-     * the request.
+     * The resource name of the image from the product that is the closest match
+     * to the query.
      * 
* - * string image_uri = 2; + * string image = 3; * - * @return The bytes for imageUri. + * @return The image. */ - com.google.protobuf.ByteString getImageUriBytes(); - + java.lang.String getImage(); /** * * *
-     * A confidence level on the match, ranging from 0 (no confidence) to
-     * 1 (full confidence).
-     * This field is returned only if `view` is set to `FULL` in
-     * the request.
+     * The resource name of the image from the product that is the closest match
+     * to the query.
      * 
* - * float score = 3; + * string image = 3; * - * @return The score. + * @return The bytes for image. */ - float getScore(); + com.google.protobuf.ByteString getImageBytes(); } /** * @@ -255,27 +245,26 @@ public interface ProductInfoOrBuilder * Information about a product. * * - * Protobuf type {@code google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo} + * Protobuf type {@code google.cloud.vision.v1p3beta1.ProductSearchResults.Result} */ - public static final class ProductInfo extends com.google.protobuf.GeneratedMessageV3 + public static final class Result extends com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo) - ProductInfoOrBuilder { + // @@protoc_insertion_point(message_implements:google.cloud.vision.v1p3beta1.ProductSearchResults.Result) + ResultOrBuilder { private static final long serialVersionUID = 0L; - // Use ProductInfo.newBuilder() to construct. - private ProductInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) { + // Use Result.newBuilder() to construct. + private Result(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } - private ProductInfo() { - productId_ = ""; - imageUri_ = ""; + private Result() { + image_ = ""; } @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new ProductInfo(); + return new Result(); } @java.lang.Override @@ -283,7 +272,7 @@ public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; } - private ProductInfo( + private Result( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { @@ -303,21 +292,30 @@ private ProductInfo( break; case 10: { - java.lang.String s = input.readStringRequireUtf8(); + com.google.cloud.vision.v1p3beta1.Product.Builder subBuilder = null; + if (product_ != null) { + subBuilder = product_.toBuilder(); + } + product_ = + input.readMessage( + com.google.cloud.vision.v1p3beta1.Product.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(product_); + product_ = subBuilder.buildPartial(); + } - productId_ = s; break; } - case 18: + case 21: { - java.lang.String s = input.readStringRequireUtf8(); - - imageUri_ = s; + score_ = input.readFloat(); break; } - case 29: + case 26: { - score_ = input.readFloat(); + java.lang.String s = input.readStringRequireUtf8(); + + image_ = s; break; } default: @@ -343,92 +341,109 @@ private ProductInfo( public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return com.google.cloud.vision.v1p3beta1.ProductSearchProto - .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ProductInfo_descriptor; + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.cloud.vision.v1p3beta1.ProductSearchProto - .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ProductInfo_fieldAccessorTable + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_fieldAccessorTable .ensureFieldAccessorsInitialized( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.class, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder.class); + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.class, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder.class); } - public static final int PRODUCT_ID_FIELD_NUMBER = 1; - private volatile java.lang.Object productId_; + public static final int PRODUCT_FIELD_NUMBER = 1; + private com.google.cloud.vision.v1p3beta1.Product product_; /** * * *
-     * Product ID.
+     * The Product.
      * 
* - * string product_id = 1; + * .google.cloud.vision.v1p3beta1.Product product = 1; * - * @return The productId. + * @return Whether the product field is set. */ @java.lang.Override - public java.lang.String getProductId() { - java.lang.Object ref = productId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - productId_ = s; - return s; - } + public boolean hasProduct() { + return product_ != null; } /** * * *
-     * Product ID.
+     * The Product.
      * 
* - * string product_id = 1; + * .google.cloud.vision.v1p3beta1.Product product = 1; * - * @return The bytes for productId. + * @return The product. */ @java.lang.Override - public com.google.protobuf.ByteString getProductIdBytes() { - java.lang.Object ref = productId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - productId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public com.google.cloud.vision.v1p3beta1.Product getProduct() { + return product_ == null + ? com.google.cloud.vision.v1p3beta1.Product.getDefaultInstance() + : product_; + } + /** + * + * + *
+     * The Product.
+     * 
+ * + * .google.cloud.vision.v1p3beta1.Product product = 1; + */ + @java.lang.Override + public com.google.cloud.vision.v1p3beta1.ProductOrBuilder getProductOrBuilder() { + return getProduct(); + } + + public static final int SCORE_FIELD_NUMBER = 2; + private float score_; + /** + * + * + *
+     * A confidence level on the match, ranging from 0 (no confidence) to
+     * 1 (full confidence).
+     * 
+ * + * float score = 2; + * + * @return The score. + */ + @java.lang.Override + public float getScore() { + return score_; } - public static final int IMAGE_URI_FIELD_NUMBER = 2; - private volatile java.lang.Object imageUri_; + public static final int IMAGE_FIELD_NUMBER = 3; + private volatile java.lang.Object image_; /** * * *
-     * The URI of the image which matched the query image.
-     * This field is returned only if `view` is set to `FULL` in
-     * the request.
+     * The resource name of the image from the product that is the closest match
+     * to the query.
      * 
* - * string image_uri = 2; + * string image = 3; * - * @return The imageUri. + * @return The image. */ @java.lang.Override - public java.lang.String getImageUri() { - java.lang.Object ref = imageUri_; + public java.lang.String getImage() { + java.lang.Object ref = image_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - imageUri_ = s; + image_ = s; return s; } } @@ -436,49 +451,27 @@ public java.lang.String getImageUri() { * * *
-     * The URI of the image which matched the query image.
-     * This field is returned only if `view` is set to `FULL` in
-     * the request.
+     * The resource name of the image from the product that is the closest match
+     * to the query.
      * 
* - * string image_uri = 2; + * string image = 3; * - * @return The bytes for imageUri. + * @return The bytes for image. */ @java.lang.Override - public com.google.protobuf.ByteString getImageUriBytes() { - java.lang.Object ref = imageUri_; + public com.google.protobuf.ByteString getImageBytes() { + java.lang.Object ref = image_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - imageUri_ = b; + image_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } - public static final int SCORE_FIELD_NUMBER = 3; - private float score_; - /** - * - * - *
-     * A confidence level on the match, ranging from 0 (no confidence) to
-     * 1 (full confidence).
-     * This field is returned only if `view` is set to `FULL` in
-     * the request.
-     * 
- * - * float score = 3; - * - * @return The score. - */ - @java.lang.Override - public float getScore() { - return score_; - } - private byte memoizedIsInitialized = -1; @java.lang.Override @@ -493,14 +486,14 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(productId_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, productId_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(imageUri_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, imageUri_); + if (product_ != null) { + output.writeMessage(1, getProduct()); } if (java.lang.Float.floatToRawIntBits(score_) != 0) { - output.writeFloat(3, score_); + output.writeFloat(2, score_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(image_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, image_); } unknownFields.writeTo(output); } @@ -511,14 +504,14 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(productId_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, productId_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(imageUri_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, imageUri_); + if (product_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getProduct()); } if (java.lang.Float.floatToRawIntBits(score_) != 0) { - size += com.google.protobuf.CodedOutputStream.computeFloatSize(3, score_); + size += com.google.protobuf.CodedOutputStream.computeFloatSize(2, score_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(image_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, image_); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -530,16 +523,19 @@ public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } - if (!(obj instanceof com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo)) { + if (!(obj instanceof com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result)) { return super.equals(obj); } - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo other = - (com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo) obj; + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result other = + (com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result) obj; - if (!getProductId().equals(other.getProductId())) return false; - if (!getImageUri().equals(other.getImageUri())) return false; + if (hasProduct() != other.hasProduct()) return false; + if (hasProduct()) { + if (!getProduct().equals(other.getProduct())) return false; + } if (java.lang.Float.floatToIntBits(getScore()) != java.lang.Float.floatToIntBits(other.getScore())) return false; + if (!getImage().equals(other.getImage())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -551,83 +547,84 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + PRODUCT_ID_FIELD_NUMBER; - hash = (53 * hash) + getProductId().hashCode(); - hash = (37 * hash) + IMAGE_URI_FIELD_NUMBER; - hash = (53 * hash) + getImageUri().hashCode(); + if (hasProduct()) { + hash = (37 * hash) + PRODUCT_FIELD_NUMBER; + hash = (53 * hash) + getProduct().hashCode(); + } hash = (37 * hash) + SCORE_FIELD_NUMBER; hash = (53 * hash) + java.lang.Float.floatToIntBits(getScore()); + hash = (37 * hash) + IMAGE_FIELD_NUMBER; + hash = (53 * hash) + getImage().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException( PARSER, input, extensionRegistry); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo - parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo - parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( PARSER, input, extensionRegistry); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -645,7 +642,7 @@ public static Builder newBuilder() { } public static Builder newBuilder( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo prototype) { + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } @@ -667,30 +664,29 @@ protected Builder newBuilderForType( * Information about a product. * * - * Protobuf type {@code google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo} + * Protobuf type {@code google.cloud.vision.v1p3beta1.ProductSearchResults.Result} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo) - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfoOrBuilder { + // @@protoc_insertion_point(builder_implements:google.cloud.vision.v1p3beta1.ProductSearchResults.Result) + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return com.google.cloud.vision.v1p3beta1.ProductSearchProto - .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ProductInfo_descriptor; + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.cloud.vision.v1p3beta1.ProductSearchProto - .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ProductInfo_fieldAccessorTable + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_fieldAccessorTable .ensureFieldAccessorsInitialized( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.class, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder.class); + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.class, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder.class); } - // Construct using - // com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.newBuilder() + // Construct using com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -707,31 +703,34 @@ private void maybeForceBuilderInitialization() { @java.lang.Override public Builder clear() { super.clear(); - productId_ = ""; - - imageUri_ = ""; - + if (productBuilder_ == null) { + product_ = null; + } else { + product_ = null; + productBuilder_ = null; + } score_ = 0F; - return this; + image_ = ""; + + return this; } @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return com.google.cloud.vision.v1p3beta1.ProductSearchProto - .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ProductInfo_descriptor; + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_descriptor; } @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result getDefaultInstanceForType() { - return com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo - .getDefaultInstance(); + return com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.getDefaultInstance(); } @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo build() { - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo result = buildPartial(); + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result build() { + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } @@ -739,12 +738,16 @@ public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo build( } @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo buildPartial() { - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo result = - new com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo(this); - result.productId_ = productId_; - result.imageUri_ = imageUri_; + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result buildPartial() { + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result result = + new com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result(this); + if (productBuilder_ == null) { + result.product_ = product_; + } else { + result.product_ = productBuilder_.build(); + } result.score_ = score_; + result.image_ = image_; onBuilt(); return result; } @@ -786,9 +789,8 @@ public Builder addRepeatedField( @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo) { - return mergeFrom( - (com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo) other); + if (other instanceof com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result) { + return mergeFrom((com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result) other); } else { super.mergeFrom(other); return this; @@ -796,21 +798,20 @@ public Builder mergeFrom(com.google.protobuf.Message other) { } public Builder mergeFrom( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo other) { + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result other) { if (other - == com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo - .getDefaultInstance()) return this; - if (!other.getProductId().isEmpty()) { - productId_ = other.productId_; - onChanged(); - } - if (!other.getImageUri().isEmpty()) { - imageUri_ = other.imageUri_; - onChanged(); + == com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.getDefaultInstance()) + return this; + if (other.hasProduct()) { + mergeProduct(other.getProduct()); } if (other.getScore() != 0F) { setScore(other.getScore()); } + if (!other.getImage().isEmpty()) { + image_ = other.image_; + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -826,12 +827,12 @@ public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo parsedMessage = null; + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = - (com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo) + (com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { @@ -842,226 +843,189 @@ public Builder mergeFrom( return this; } - private java.lang.Object productId_ = ""; + private com.google.cloud.vision.v1p3beta1.Product product_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.Product, + com.google.cloud.vision.v1p3beta1.Product.Builder, + com.google.cloud.vision.v1p3beta1.ProductOrBuilder> + productBuilder_; /** * * *
-       * Product ID.
+       * The Product.
        * 
* - * string product_id = 1; + * .google.cloud.vision.v1p3beta1.Product product = 1; * - * @return The productId. + * @return Whether the product field is set. */ - public java.lang.String getProductId() { - java.lang.Object ref = productId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - productId_ = s; - return s; - } else { - return (java.lang.String) ref; - } + public boolean hasProduct() { + return productBuilder_ != null || product_ != null; } /** * * *
-       * Product ID.
+       * The Product.
        * 
* - * string product_id = 1; + * .google.cloud.vision.v1p3beta1.Product product = 1; * - * @return The bytes for productId. + * @return The product. */ - public com.google.protobuf.ByteString getProductIdBytes() { - java.lang.Object ref = productId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - productId_ = b; - return b; + public com.google.cloud.vision.v1p3beta1.Product getProduct() { + if (productBuilder_ == null) { + return product_ == null + ? com.google.cloud.vision.v1p3beta1.Product.getDefaultInstance() + : product_; } else { - return (com.google.protobuf.ByteString) ref; + return productBuilder_.getMessage(); } } /** * * *
-       * Product ID.
+       * The Product.
        * 
* - * string product_id = 1; - * - * @param value The productId to set. - * @return This builder for chaining. + * .google.cloud.vision.v1p3beta1.Product product = 1; */ - public Builder setProductId(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); + public Builder setProduct(com.google.cloud.vision.v1p3beta1.Product value) { + if (productBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + product_ = value; + onChanged(); + } else { + productBuilder_.setMessage(value); } - productId_ = value; - onChanged(); - return this; - } - /** - * - * - *
-       * Product ID.
-       * 
- * - * string product_id = 1; - * - * @return This builder for chaining. - */ - public Builder clearProductId() { - - productId_ = getDefaultInstance().getProductId(); - onChanged(); return this; } /** * * *
-       * Product ID.
+       * The Product.
        * 
* - * string product_id = 1; - * - * @param value The bytes for productId to set. - * @return This builder for chaining. + * .google.cloud.vision.v1p3beta1.Product product = 1; */ - public Builder setProductIdBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); + public Builder setProduct(com.google.cloud.vision.v1p3beta1.Product.Builder builderForValue) { + if (productBuilder_ == null) { + product_ = builderForValue.build(); + onChanged(); + } else { + productBuilder_.setMessage(builderForValue.build()); } - checkByteStringIsUtf8(value); - productId_ = value; - onChanged(); return this; } - - private java.lang.Object imageUri_ = ""; /** * * *
-       * The URI of the image which matched the query image.
-       * This field is returned only if `view` is set to `FULL` in
-       * the request.
+       * The Product.
        * 
* - * string image_uri = 2; - * - * @return The imageUri. + * .google.cloud.vision.v1p3beta1.Product product = 1; */ - public java.lang.String getImageUri() { - java.lang.Object ref = imageUri_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - imageUri_ = s; - return s; + public Builder mergeProduct(com.google.cloud.vision.v1p3beta1.Product value) { + if (productBuilder_ == null) { + if (product_ != null) { + product_ = + com.google.cloud.vision.v1p3beta1.Product.newBuilder(product_) + .mergeFrom(value) + .buildPartial(); + } else { + product_ = value; + } + onChanged(); } else { - return (java.lang.String) ref; + productBuilder_.mergeFrom(value); } + + return this; } /** * * *
-       * The URI of the image which matched the query image.
-       * This field is returned only if `view` is set to `FULL` in
-       * the request.
+       * The Product.
        * 
* - * string image_uri = 2; - * - * @return The bytes for imageUri. + * .google.cloud.vision.v1p3beta1.Product product = 1; */ - public com.google.protobuf.ByteString getImageUriBytes() { - java.lang.Object ref = imageUri_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - imageUri_ = b; - return b; + public Builder clearProduct() { + if (productBuilder_ == null) { + product_ = null; + onChanged(); } else { - return (com.google.protobuf.ByteString) ref; + product_ = null; + productBuilder_ = null; } + + return this; } /** * * *
-       * The URI of the image which matched the query image.
-       * This field is returned only if `view` is set to `FULL` in
-       * the request.
+       * The Product.
        * 
* - * string image_uri = 2; - * - * @param value The imageUri to set. - * @return This builder for chaining. + * .google.cloud.vision.v1p3beta1.Product product = 1; */ - public Builder setImageUri(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } + public com.google.cloud.vision.v1p3beta1.Product.Builder getProductBuilder() { - imageUri_ = value; onChanged(); - return this; + return getProductFieldBuilder().getBuilder(); } /** * * *
-       * The URI of the image which matched the query image.
-       * This field is returned only if `view` is set to `FULL` in
-       * the request.
+       * The Product.
        * 
* - * string image_uri = 2; - * - * @return This builder for chaining. + * .google.cloud.vision.v1p3beta1.Product product = 1; */ - public Builder clearImageUri() { - - imageUri_ = getDefaultInstance().getImageUri(); - onChanged(); - return this; + public com.google.cloud.vision.v1p3beta1.ProductOrBuilder getProductOrBuilder() { + if (productBuilder_ != null) { + return productBuilder_.getMessageOrBuilder(); + } else { + return product_ == null + ? com.google.cloud.vision.v1p3beta1.Product.getDefaultInstance() + : product_; + } } /** * * *
-       * The URI of the image which matched the query image.
-       * This field is returned only if `view` is set to `FULL` in
-       * the request.
+       * The Product.
        * 
* - * string image_uri = 2; - * - * @param value The bytes for imageUri to set. - * @return This builder for chaining. + * .google.cloud.vision.v1p3beta1.Product product = 1; */ - public Builder setImageUriBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.Product, + com.google.cloud.vision.v1p3beta1.Product.Builder, + com.google.cloud.vision.v1p3beta1.ProductOrBuilder> + getProductFieldBuilder() { + if (productBuilder_ == null) { + productBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.Product, + com.google.cloud.vision.v1p3beta1.Product.Builder, + com.google.cloud.vision.v1p3beta1.ProductOrBuilder>( + getProduct(), getParentForChildren(), isClean()); + product_ = null; } - checkByteStringIsUtf8(value); - - imageUri_ = value; - onChanged(); - return this; + return productBuilder_; } private float score_; @@ -1071,11 +1035,9 @@ public Builder setImageUriBytes(com.google.protobuf.ByteString value) { *
        * A confidence level on the match, ranging from 0 (no confidence) to
        * 1 (full confidence).
-       * This field is returned only if `view` is set to `FULL` in
-       * the request.
        * 
* - * float score = 3; + * float score = 2; * * @return The score. */ @@ -1089,11 +1051,9 @@ public float getScore() { *
        * A confidence level on the match, ranging from 0 (no confidence) to
        * 1 (full confidence).
-       * This field is returned only if `view` is set to `FULL` in
-       * the request.
        * 
* - * float score = 3; + * float score = 2; * * @param value The score to set. * @return This builder for chaining. @@ -1110,11 +1070,9 @@ public Builder setScore(float value) { *
        * A confidence level on the match, ranging from 0 (no confidence) to
        * 1 (full confidence).
-       * This field is returned only if `view` is set to `FULL` in
-       * the request.
        * 
* - * float score = 3; + * float score = 2; * * @return This builder for chaining. */ @@ -1125,171 +1083,298 @@ public Builder clearScore() { return this; } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); + private java.lang.Object image_ = ""; + /** + * + * + *
+       * The resource name of the image from the product that is the closest match
+       * to the query.
+       * 
+ * + * string image = 3; + * + * @return The image. + */ + public java.lang.String getImage() { + java.lang.Object ref = image_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + image_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); + /** + * + * + *
+       * The resource name of the image from the product that is the closest match
+       * to the query.
+       * 
+ * + * string image = 3; + * + * @return The bytes for image. + */ + public com.google.protobuf.ByteString getImageBytes() { + java.lang.Object ref = image_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + image_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+       * The resource name of the image from the product that is the closest match
+       * to the query.
+       * 
+ * + * string image = 3; + * + * @param value The image to set. + * @return This builder for chaining. + */ + public Builder setImage(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + image_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * The resource name of the image from the product that is the closest match
+       * to the query.
+       * 
+ * + * string image = 3; + * + * @return This builder for chaining. + */ + public Builder clearImage() { + + image_ = getDefaultInstance().getImage(); + onChanged(); + return this; + } + /** + * + * + *
+       * The resource name of the image from the product that is the closest match
+       * to the query.
+       * 
+ * + * string image = 3; + * + * @param value The bytes for image to set. + * @return This builder for chaining. + */ + public Builder setImageBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + image_ = value; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - // @@protoc_insertion_point(builder_scope:google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo) + // @@protoc_insertion_point(builder_scope:google.cloud.vision.v1p3beta1.ProductSearchResults.Result) } - // @@protoc_insertion_point(class_scope:google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo) - private static final com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo + // @@protoc_insertion_point(class_scope:google.cloud.vision.v1p3beta1.ProductSearchResults.Result) + private static final com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result DEFAULT_INSTANCE; static { - DEFAULT_INSTANCE = new com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo(); + DEFAULT_INSTANCE = new com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result(); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result getDefaultInstance() { return DEFAULT_INSTANCE; } - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { @java.lang.Override - public ProductInfo parsePartialFrom( + public Result parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return new ProductInfo(input, extensionRegistry); + return new Result(input, extensionRegistry); } }; - public static com.google.protobuf.Parser parser() { + public static com.google.protobuf.Parser parser() { return PARSER; } @java.lang.Override - public com.google.protobuf.Parser getParserForType() { + public com.google.protobuf.Parser getParserForType() { return PARSER; } @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result getDefaultInstanceForType() { return DEFAULT_INSTANCE; } } - public interface ResultOrBuilder + public interface ObjectAnnotationOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.cloud.vision.v1p3beta1.ProductSearchResults.Result) + // @@protoc_insertion_point(interface_extends:google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation) com.google.protobuf.MessageOrBuilder { /** * * *
-     * The Product.
+     * Object ID that should align with EntityAnnotation mid.
      * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string mid = 1; * - * @return Whether the product field is set. + * @return The mid. */ - boolean hasProduct(); + java.lang.String getMid(); /** * * *
-     * The Product.
+     * Object ID that should align with EntityAnnotation mid.
      * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string mid = 1; * - * @return The product. + * @return The bytes for mid. */ - com.google.cloud.vision.v1p3beta1.Product getProduct(); + com.google.protobuf.ByteString getMidBytes(); + /** * * *
-     * The Product.
+     * The BCP-47 language code, such as "en-US" or "sr-Latn". For more
+     * information, see
+     * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
      * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string language_code = 2; + * + * @return The languageCode. */ - com.google.cloud.vision.v1p3beta1.ProductOrBuilder getProductOrBuilder(); - + java.lang.String getLanguageCode(); /** * * *
-     * A confidence level on the match, ranging from 0 (no confidence) to
-     * 1 (full confidence).
-     * This field is returned only if `view` is set to `FULL` in
-     * the request.
+     * The BCP-47 language code, such as "en-US" or "sr-Latn". For more
+     * information, see
+     * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
      * 
* - * float score = 2; + * string language_code = 2; * - * @return The score. + * @return The bytes for languageCode. */ - float getScore(); + com.google.protobuf.ByteString getLanguageCodeBytes(); /** * * *
-     * The resource name of the image from the product that is the closest match
-     * to the query.
+     * Object name, expressed in its `language_code` language.
      * 
* - * string image = 3; + * string name = 3; * - * @return The image. + * @return The name. */ - java.lang.String getImage(); + java.lang.String getName(); /** * * *
-     * The resource name of the image from the product that is the closest match
-     * to the query.
+     * Object name, expressed in its `language_code` language.
      * 
* - * string image = 3; + * string name = 3; * - * @return The bytes for image. + * @return The bytes for name. */ - com.google.protobuf.ByteString getImageBytes(); + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+     * Score of the result. Range [0, 1].
+     * 
+ * + * float score = 4; + * + * @return The score. + */ + float getScore(); } /** * * *
-   * Information about a product.
+   * Prediction for what the object in the bounding box is.
    * 
* - * Protobuf type {@code google.cloud.vision.v1p3beta1.ProductSearchResults.Result} + * Protobuf type {@code google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation} */ - public static final class Result extends com.google.protobuf.GeneratedMessageV3 + public static final class ObjectAnnotation extends com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:google.cloud.vision.v1p3beta1.ProductSearchResults.Result) - ResultOrBuilder { + // @@protoc_insertion_point(message_implements:google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation) + ObjectAnnotationOrBuilder { private static final long serialVersionUID = 0L; - // Use Result.newBuilder() to construct. - private Result(com.google.protobuf.GeneratedMessageV3.Builder builder) { + // Use ObjectAnnotation.newBuilder() to construct. + private ObjectAnnotation(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } - private Result() { - image_ = ""; + private ObjectAnnotation() { + mid_ = ""; + languageCode_ = ""; + name_ = ""; } @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new Result(); + return new ObjectAnnotation(); } @java.lang.Override @@ -1297,7 +1382,7 @@ public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; } - private Result( + private ObjectAnnotation( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { @@ -1317,30 +1402,28 @@ private Result( break; case 10: { - com.google.cloud.vision.v1p3beta1.Product.Builder subBuilder = null; - if (product_ != null) { - subBuilder = product_.toBuilder(); - } - product_ = - input.readMessage( - com.google.cloud.vision.v1p3beta1.Product.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(product_); - product_ = subBuilder.buildPartial(); - } + java.lang.String s = input.readStringRequireUtf8(); + mid_ = s; break; } - case 21: + case 18: { - score_ = input.readFloat(); + java.lang.String s = input.readStringRequireUtf8(); + + languageCode_ = s; break; } case 26: { java.lang.String s = input.readStringRequireUtf8(); - image_ = s; + name_ = s; + break; + } + case 37: + { + score_ = input.readFloat(); break; } default: @@ -1366,111 +1449,144 @@ private Result( public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return com.google.cloud.vision.v1p3beta1.ProductSearchProto - .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_descriptor; + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ObjectAnnotation_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.cloud.vision.v1p3beta1.ProductSearchProto - .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_fieldAccessorTable + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ObjectAnnotation_fieldAccessorTable .ensureFieldAccessorsInitialized( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.class, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder.class); + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.class, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder + .class); } - public static final int PRODUCT_FIELD_NUMBER = 1; - private com.google.cloud.vision.v1p3beta1.Product product_; + public static final int MID_FIELD_NUMBER = 1; + private volatile java.lang.Object mid_; /** * * *
-     * The Product.
+     * Object ID that should align with EntityAnnotation mid.
      * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string mid = 1; * - * @return Whether the product field is set. + * @return The mid. */ @java.lang.Override - public boolean hasProduct() { - return product_ != null; + public java.lang.String getMid() { + java.lang.Object ref = mid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + mid_ = s; + return s; + } } /** * * *
-     * The Product.
+     * Object ID that should align with EntityAnnotation mid.
      * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string mid = 1; * - * @return The product. + * @return The bytes for mid. */ @java.lang.Override - public com.google.cloud.vision.v1p3beta1.Product getProduct() { - return product_ == null - ? com.google.cloud.vision.v1p3beta1.Product.getDefaultInstance() - : product_; + public com.google.protobuf.ByteString getMidBytes() { + java.lang.Object ref = mid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + mid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } + + public static final int LANGUAGE_CODE_FIELD_NUMBER = 2; + private volatile java.lang.Object languageCode_; /** * * *
-     * The Product.
+     * The BCP-47 language code, such as "en-US" or "sr-Latn". For more
+     * information, see
+     * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
      * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string language_code = 2; + * + * @return The languageCode. */ @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductOrBuilder getProductOrBuilder() { - return getProduct(); + public java.lang.String getLanguageCode() { + java.lang.Object ref = languageCode_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + languageCode_ = s; + return s; + } } - - public static final int SCORE_FIELD_NUMBER = 2; - private float score_; /** * * *
-     * A confidence level on the match, ranging from 0 (no confidence) to
-     * 1 (full confidence).
-     * This field is returned only if `view` is set to `FULL` in
-     * the request.
+     * The BCP-47 language code, such as "en-US" or "sr-Latn". For more
+     * information, see
+     * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
      * 
* - * float score = 2; + * string language_code = 2; * - * @return The score. + * @return The bytes for languageCode. */ @java.lang.Override - public float getScore() { - return score_; + public com.google.protobuf.ByteString getLanguageCodeBytes() { + java.lang.Object ref = languageCode_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + languageCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - public static final int IMAGE_FIELD_NUMBER = 3; - private volatile java.lang.Object image_; + public static final int NAME_FIELD_NUMBER = 3; + private volatile java.lang.Object name_; /** * * *
-     * The resource name of the image from the product that is the closest match
-     * to the query.
+     * Object name, expressed in its `language_code` language.
      * 
* - * string image = 3; + * string name = 3; * - * @return The image. + * @return The name. */ @java.lang.Override - public java.lang.String getImage() { - java.lang.Object ref = image_; + public java.lang.String getName() { + java.lang.Object ref = name_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - image_ = s; + name_ = s; return s; } } @@ -1478,27 +1594,44 @@ public java.lang.String getImage() { * * *
-     * The resource name of the image from the product that is the closest match
-     * to the query.
+     * Object name, expressed in its `language_code` language.
      * 
* - * string image = 3; + * string name = 3; * - * @return The bytes for image. + * @return The bytes for name. */ @java.lang.Override - public com.google.protobuf.ByteString getImageBytes() { - java.lang.Object ref = image_; + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - image_ = b; + name_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } + public static final int SCORE_FIELD_NUMBER = 4; + private float score_; + /** + * + * + *
+     * Score of the result. Range [0, 1].
+     * 
+ * + * float score = 4; + * + * @return The score. + */ + @java.lang.Override + public float getScore() { + return score_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -1513,14 +1646,17 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (product_ != null) { - output.writeMessage(1, getProduct()); + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(mid_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, mid_); } - if (java.lang.Float.floatToRawIntBits(score_) != 0) { - output.writeFloat(2, score_); + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(languageCode_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, languageCode_); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(image_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, image_); + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, name_); + } + if (java.lang.Float.floatToRawIntBits(score_) != 0) { + output.writeFloat(4, score_); } unknownFields.writeTo(output); } @@ -1531,14 +1667,17 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (product_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getProduct()); + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(mid_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, mid_); } - if (java.lang.Float.floatToRawIntBits(score_) != 0) { - size += com.google.protobuf.CodedOutputStream.computeFloatSize(2, score_); + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(languageCode_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, languageCode_); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(image_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, image_); + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, name_); + } + if (java.lang.Float.floatToRawIntBits(score_) != 0) { + size += com.google.protobuf.CodedOutputStream.computeFloatSize(4, score_); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -1550,19 +1689,18 @@ public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } - if (!(obj instanceof com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result)) { + if (!(obj + instanceof com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation)) { return super.equals(obj); } - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result other = - (com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result) obj; + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation other = + (com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation) obj; - if (hasProduct() != other.hasProduct()) return false; - if (hasProduct()) { - if (!getProduct().equals(other.getProduct())) return false; - } + if (!getMid().equals(other.getMid())) return false; + if (!getLanguageCode().equals(other.getLanguageCode())) return false; + if (!getName().equals(other.getName())) return false; if (java.lang.Float.floatToIntBits(getScore()) != java.lang.Float.floatToIntBits(other.getScore())) return false; - if (!getImage().equals(other.getImage())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -1574,84 +1712,85 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - if (hasProduct()) { - hash = (37 * hash) + PRODUCT_FIELD_NUMBER; - hash = (53 * hash) + getProduct().hashCode(); - } + hash = (37 * hash) + MID_FIELD_NUMBER; + hash = (53 * hash) + getMid().hashCode(); + hash = (37 * hash) + LANGUAGE_CODE_FIELD_NUMBER; + hash = (53 * hash) + getLanguageCode().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + SCORE_FIELD_NUMBER; hash = (53 * hash) + java.lang.Float.floatToIntBits(getScore()); - hash = (37 * hash) + IMAGE_FIELD_NUMBER; - hash = (53 * hash) + getImage().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation parseFrom( byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation parseFrom( java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException( PARSER, input, extensionRegistry); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( PARSER, input, extensionRegistry); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parseFrom( + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -1669,7 +1808,7 @@ public static Builder newBuilder() { } public static Builder newBuilder( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result prototype) { + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } @@ -1688,32 +1827,34 @@ protected Builder newBuilderForType( * * *
-     * Information about a product.
+     * Prediction for what the object in the bounding box is.
      * 
* - * Protobuf type {@code google.cloud.vision.v1p3beta1.ProductSearchResults.Result} + * Protobuf type {@code google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:google.cloud.vision.v1p3beta1.ProductSearchResults.Result) - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder { + // @@protoc_insertion_point(builder_implements:google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation) + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotationOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return com.google.cloud.vision.v1p3beta1.ProductSearchProto - .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_descriptor; + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ObjectAnnotation_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.cloud.vision.v1p3beta1.ProductSearchProto - .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_fieldAccessorTable + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ObjectAnnotation_fieldAccessorTable .ensureFieldAccessorsInitialized( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.class, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder.class); + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.class, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder + .class); } - // Construct using com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.newBuilder() + // Construct using + // com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -1730,15 +1871,13 @@ private void maybeForceBuilderInitialization() { @java.lang.Override public Builder clear() { super.clear(); - if (productBuilder_ == null) { - product_ = null; - } else { - product_ = null; - productBuilder_ = null; - } - score_ = 0F; + mid_ = ""; - image_ = ""; + languageCode_ = ""; + + name_ = ""; + + score_ = 0F; return this; } @@ -1746,18 +1885,20 @@ public Builder clear() { @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return com.google.cloud.vision.v1p3beta1.ProductSearchProto - .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_Result_descriptor; + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_ObjectAnnotation_descriptor; } @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation getDefaultInstanceForType() { - return com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.getDefaultInstance(); + return com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation + .getDefaultInstance(); } @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result build() { - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result result = buildPartial(); + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation build() { + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation result = + buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } @@ -1765,16 +1906,14 @@ public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result build() { } @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result buildPartial() { - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result result = - new com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result(this); - if (productBuilder_ == null) { - result.product_ = product_; - } else { - result.product_ = productBuilder_.build(); - } + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation + buildPartial() { + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation result = + new com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation(this); + result.mid_ = mid_; + result.languageCode_ = languageCode_; + result.name_ = name_; result.score_ = score_; - result.image_ = image_; onBuilt(); return result; } @@ -1816,8 +1955,10 @@ public Builder addRepeatedField( @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result) { - return mergeFrom((com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result) other); + if (other + instanceof com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation) { + return mergeFrom( + (com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation) other); } else { super.mergeFrom(other); return this; @@ -1825,20 +1966,25 @@ public Builder mergeFrom(com.google.protobuf.Message other) { } public Builder mergeFrom( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result other) { + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation other) { if (other - == com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.getDefaultInstance()) - return this; - if (other.hasProduct()) { - mergeProduct(other.getProduct()); + == com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation + .getDefaultInstance()) return this; + if (!other.getMid().isEmpty()) { + mid_ = other.mid_; + onChanged(); } - if (other.getScore() != 0F) { - setScore(other.getScore()); + if (!other.getLanguageCode().isEmpty()) { + languageCode_ = other.languageCode_; + onChanged(); } - if (!other.getImage().isEmpty()) { - image_ = other.image_; + if (!other.getName().isEmpty()) { + name_ = other.name_; onChanged(); } + if (other.getScore() != 0F) { + setScore(other.getScore()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -1854,12 +2000,13 @@ public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result parsedMessage = null; + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation parsedMessage = + null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = - (com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result) + (com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { @@ -1870,228 +2017,200 @@ public Builder mergeFrom( return this; } - private com.google.cloud.vision.v1p3beta1.Product product_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.Product, - com.google.cloud.vision.v1p3beta1.Product.Builder, - com.google.cloud.vision.v1p3beta1.ProductOrBuilder> - productBuilder_; + private java.lang.Object mid_ = ""; /** * * *
-       * The Product.
+       * Object ID that should align with EntityAnnotation mid.
        * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string mid = 1; * - * @return Whether the product field is set. + * @return The mid. */ - public boolean hasProduct() { - return productBuilder_ != null || product_ != null; + public java.lang.String getMid() { + java.lang.Object ref = mid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + mid_ = s; + return s; + } else { + return (java.lang.String) ref; + } } /** * * *
-       * The Product.
+       * Object ID that should align with EntityAnnotation mid.
        * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string mid = 1; * - * @return The product. + * @return The bytes for mid. */ - public com.google.cloud.vision.v1p3beta1.Product getProduct() { - if (productBuilder_ == null) { - return product_ == null - ? com.google.cloud.vision.v1p3beta1.Product.getDefaultInstance() - : product_; + public com.google.protobuf.ByteString getMidBytes() { + java.lang.Object ref = mid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + mid_ = b; + return b; } else { - return productBuilder_.getMessage(); + return (com.google.protobuf.ByteString) ref; } } /** * * *
-       * The Product.
+       * Object ID that should align with EntityAnnotation mid.
        * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string mid = 1; + * + * @param value The mid to set. + * @return This builder for chaining. */ - public Builder setProduct(com.google.cloud.vision.v1p3beta1.Product value) { - if (productBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - product_ = value; - onChanged(); - } else { - productBuilder_.setMessage(value); + public Builder setMid(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); } + mid_ = value; + onChanged(); return this; } /** * * *
-       * The Product.
+       * Object ID that should align with EntityAnnotation mid.
        * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string mid = 1; + * + * @return This builder for chaining. */ - public Builder setProduct(com.google.cloud.vision.v1p3beta1.Product.Builder builderForValue) { - if (productBuilder_ == null) { - product_ = builderForValue.build(); - onChanged(); - } else { - productBuilder_.setMessage(builderForValue.build()); - } + public Builder clearMid() { + mid_ = getDefaultInstance().getMid(); + onChanged(); return this; } /** * * *
-       * The Product.
+       * Object ID that should align with EntityAnnotation mid.
        * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string mid = 1; + * + * @param value The bytes for mid to set. + * @return This builder for chaining. */ - public Builder mergeProduct(com.google.cloud.vision.v1p3beta1.Product value) { - if (productBuilder_ == null) { - if (product_ != null) { - product_ = - com.google.cloud.vision.v1p3beta1.Product.newBuilder(product_) - .mergeFrom(value) - .buildPartial(); - } else { - product_ = value; - } - onChanged(); - } else { - productBuilder_.mergeFrom(value); + public Builder setMidBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); } + checkByteStringIsUtf8(value); + mid_ = value; + onChanged(); return this; } + + private java.lang.Object languageCode_ = ""; /** * * *
-       * The Product.
+       * The BCP-47 language code, such as "en-US" or "sr-Latn". For more
+       * information, see
+       * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
        * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string language_code = 2; + * + * @return The languageCode. */ - public Builder clearProduct() { - if (productBuilder_ == null) { - product_ = null; - onChanged(); + public java.lang.String getLanguageCode() { + java.lang.Object ref = languageCode_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + languageCode_ = s; + return s; } else { - product_ = null; - productBuilder_ = null; + return (java.lang.String) ref; } - - return this; } /** * * *
-       * The Product.
+       * The BCP-47 language code, such as "en-US" or "sr-Latn". For more
+       * information, see
+       * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
        * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; - */ - public com.google.cloud.vision.v1p3beta1.Product.Builder getProductBuilder() { - - onChanged(); - return getProductFieldBuilder().getBuilder(); - } - /** - * - * - *
-       * The Product.
-       * 
+ * string language_code = 2; * - * .google.cloud.vision.v1p3beta1.Product product = 1; + * @return The bytes for languageCode. */ - public com.google.cloud.vision.v1p3beta1.ProductOrBuilder getProductOrBuilder() { - if (productBuilder_ != null) { - return productBuilder_.getMessageOrBuilder(); + public com.google.protobuf.ByteString getLanguageCodeBytes() { + java.lang.Object ref = languageCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + languageCode_ = b; + return b; } else { - return product_ == null - ? com.google.cloud.vision.v1p3beta1.Product.getDefaultInstance() - : product_; + return (com.google.protobuf.ByteString) ref; } } /** * * *
-       * The Product.
+       * The BCP-47 language code, such as "en-US" or "sr-Latn". For more
+       * information, see
+       * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
        * 
* - * .google.cloud.vision.v1p3beta1.Product product = 1; + * string language_code = 2; + * + * @param value The languageCode to set. + * @return This builder for chaining. */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.Product, - com.google.cloud.vision.v1p3beta1.Product.Builder, - com.google.cloud.vision.v1p3beta1.ProductOrBuilder> - getProductFieldBuilder() { - if (productBuilder_ == null) { - productBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.Product, - com.google.cloud.vision.v1p3beta1.Product.Builder, - com.google.cloud.vision.v1p3beta1.ProductOrBuilder>( - getProduct(), getParentForChildren(), isClean()); - product_ = null; + public Builder setLanguageCode(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); } - return productBuilder_; - } - private float score_; + languageCode_ = value; + onChanged(); + return this; + } /** * * *
-       * A confidence level on the match, ranging from 0 (no confidence) to
-       * 1 (full confidence).
-       * This field is returned only if `view` is set to `FULL` in
-       * the request.
+       * The BCP-47 language code, such as "en-US" or "sr-Latn". For more
+       * information, see
+       * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
        * 
* - * float score = 2; - * - * @return The score. - */ - @java.lang.Override - public float getScore() { - return score_; - } - /** - * - * - *
-       * A confidence level on the match, ranging from 0 (no confidence) to
-       * 1 (full confidence).
-       * This field is returned only if `view` is set to `FULL` in
-       * the request.
-       * 
- * - * float score = 2; + * string language_code = 2; * - * @param value The score to set. * @return This builder for chaining. */ - public Builder setScore(float value) { + public Builder clearLanguageCode() { - score_ = value; + languageCode_ = getDefaultInstance().getLanguageCode(); onChanged(); return this; } @@ -2099,42 +2218,45 @@ public Builder setScore(float value) { * * *
-       * A confidence level on the match, ranging from 0 (no confidence) to
-       * 1 (full confidence).
-       * This field is returned only if `view` is set to `FULL` in
-       * the request.
+       * The BCP-47 language code, such as "en-US" or "sr-Latn". For more
+       * information, see
+       * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
        * 
* - * float score = 2; + * string language_code = 2; * + * @param value The bytes for languageCode to set. * @return This builder for chaining. */ - public Builder clearScore() { + public Builder setLanguageCodeBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); - score_ = 0F; + languageCode_ = value; onChanged(); return this; } - private java.lang.Object image_ = ""; + private java.lang.Object name_ = ""; /** * * *
-       * The resource name of the image from the product that is the closest match
-       * to the query.
+       * Object name, expressed in its `language_code` language.
        * 
* - * string image = 3; + * string name = 3; * - * @return The image. + * @return The name. */ - public java.lang.String getImage() { - java.lang.Object ref = image_; + public java.lang.String getName() { + java.lang.Object ref = name_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - image_ = s; + name_ = s; return s; } else { return (java.lang.String) ref; @@ -2144,20 +2266,19 @@ public java.lang.String getImage() { * * *
-       * The resource name of the image from the product that is the closest match
-       * to the query.
+       * Object name, expressed in its `language_code` language.
        * 
* - * string image = 3; + * string name = 3; * - * @return The bytes for image. + * @return The bytes for name. */ - public com.google.protobuf.ByteString getImageBytes() { - java.lang.Object ref = image_; + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - image_ = b; + name_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; @@ -2167,21 +2288,20 @@ public com.google.protobuf.ByteString getImageBytes() { * * *
-       * The resource name of the image from the product that is the closest match
-       * to the query.
+       * Object name, expressed in its `language_code` language.
        * 
* - * string image = 3; + * string name = 3; * - * @param value The image to set. + * @param value The name to set. * @return This builder for chaining. */ - public Builder setImage(java.lang.String value) { + public Builder setName(java.lang.String value) { if (value == null) { throw new NullPointerException(); } - image_ = value; + name_ = value; onChanged(); return this; } @@ -2189,17 +2309,16 @@ public Builder setImage(java.lang.String value) { * * *
-       * The resource name of the image from the product that is the closest match
-       * to the query.
+       * Object name, expressed in its `language_code` language.
        * 
* - * string image = 3; + * string name = 3; * * @return This builder for chaining. */ - public Builder clearImage() { + public Builder clearName() { - image_ = getDefaultInstance().getImage(); + name_ = getDefaultInstance().getName(); onChanged(); return this; } @@ -2207,22 +2326,73 @@ public Builder clearImage() { * * *
-       * The resource name of the image from the product that is the closest match
-       * to the query.
+       * Object name, expressed in its `language_code` language.
        * 
* - * string image = 3; + * string name = 3; * - * @param value The bytes for image to set. + * @param value The bytes for name to set. * @return This builder for chaining. */ - public Builder setImageBytes(com.google.protobuf.ByteString value) { + public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - image_ = value; + name_ = value; + onChanged(); + return this; + } + + private float score_; + /** + * + * + *
+       * Score of the result. Range [0, 1].
+       * 
+ * + * float score = 4; + * + * @return The score. + */ + @java.lang.Override + public float getScore() { + return score_; + } + /** + * + * + *
+       * Score of the result. Range [0, 1].
+       * 
+ * + * float score = 4; + * + * @param value The score to set. + * @return This builder for chaining. + */ + public Builder setScore(float value) { + + score_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Score of the result. Range [0, 1].
+       * 
+ * + * float score = 4; + * + * @return This builder for chaining. + */ + public Builder clearScore() { + + score_ = 0F; onChanged(); return this; } @@ -2239,139 +2409,2059 @@ public final Builder mergeUnknownFields( return super.mergeUnknownFields(unknownFields); } - // @@protoc_insertion_point(builder_scope:google.cloud.vision.v1p3beta1.ProductSearchResults.Result) + // @@protoc_insertion_point(builder_scope:google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation) } - // @@protoc_insertion_point(class_scope:google.cloud.vision.v1p3beta1.ProductSearchResults.Result) - private static final com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result + // @@protoc_insertion_point(class_scope:google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation) + private static final com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation DEFAULT_INSTANCE; static { - DEFAULT_INSTANCE = new com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result(); + DEFAULT_INSTANCE = + new com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation(); } - public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation getDefaultInstance() { return DEFAULT_INSTANCE; } - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { @java.lang.Override - public Result parsePartialFrom( + public ObjectAnnotation parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return new Result(input, extensionRegistry); + return new ObjectAnnotation(input, extensionRegistry); } }; - public static com.google.protobuf.Parser parser() { + public static com.google.protobuf.Parser parser() { return PARSER; } @java.lang.Override - public com.google.protobuf.Parser getParserForType() { + public com.google.protobuf.Parser getParserForType() { return PARSER; } @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation getDefaultInstanceForType() { return DEFAULT_INSTANCE; } } - public static final int CATEGORY_FIELD_NUMBER = 1; - private int category_; - /** - * - * - *
-   * Product category.
-   * [Deprecated] Use `product_category`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 1; - * - * @return The enum numeric value on the wire for category. - */ - @java.lang.Override - public int getCategoryValue() { - return category_; + public interface GroupedResultOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The bounding polygon around the product detected in the query image.
+     * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + * + * @return Whether the boundingPoly field is set. + */ + boolean hasBoundingPoly(); + /** + * + * + *
+     * The bounding polygon around the product detected in the query image.
+     * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + * + * @return The boundingPoly. + */ + com.google.cloud.vision.v1p3beta1.BoundingPoly getBoundingPoly(); + /** + * + * + *
+     * The bounding polygon around the product detected in the query image.
+     * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + */ + com.google.cloud.vision.v1p3beta1.BoundingPolyOrBuilder getBoundingPolyOrBuilder(); + + /** + * + * + *
+     * List of results, one for each product match.
+     * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + */ + java.util.List getResultsList(); + /** + * + * + *
+     * List of results, one for each product match.
+     * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + */ + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result getResults(int index); + /** + * + * + *
+     * List of results, one for each product match.
+     * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + */ + int getResultsCount(); + /** + * + * + *
+     * List of results, one for each product match.
+     * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + */ + java.util.List + getResultsOrBuilderList(); + /** + * + * + *
+     * List of results, one for each product match.
+     * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + */ + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder getResultsOrBuilder( + int index); + + /** + * + * + *
+     * List of generic predictions for the object in the bounding box.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + java.util.List + getObjectAnnotationsList(); + /** + * + * + *
+     * List of generic predictions for the object in the bounding box.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation getObjectAnnotations( + int index); + /** + * + * + *
+     * List of generic predictions for the object in the bounding box.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + int getObjectAnnotationsCount(); + /** + * + * + *
+     * List of generic predictions for the object in the bounding box.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + java.util.List< + ? extends + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotationOrBuilder> + getObjectAnnotationsOrBuilderList(); + /** + * + * + *
+     * List of generic predictions for the object in the bounding box.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotationOrBuilder + getObjectAnnotationsOrBuilder(int index); } /** * * *
-   * Product category.
-   * [Deprecated] Use `product_category`.
+   * Information about the products similar to a single product in a query
+   * image.
    * 
* - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 1; - * - * @return The category. + * Protobuf type {@code google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult} */ - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchCategory getCategory() { - @SuppressWarnings("deprecation") - com.google.cloud.vision.v1p3beta1.ProductSearchCategory result = - com.google.cloud.vision.v1p3beta1.ProductSearchCategory.valueOf(category_); - return result == null - ? com.google.cloud.vision.v1p3beta1.ProductSearchCategory.UNRECOGNIZED - : result; - } + public static final class GroupedResult extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult) + GroupedResultOrBuilder { + private static final long serialVersionUID = 0L; + // Use GroupedResult.newBuilder() to construct. + private GroupedResult(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } - public static final int PRODUCT_CATEGORY_FIELD_NUMBER = 4; - private volatile java.lang.Object productCategory_; - /** - * - * - *
-   * Product category.
-   * Supported values are `bag` and `shoe`.
-   * [Deprecated] `product_category` is provided in each Product.
-   * 
- * - * string product_category = 4; - * - * @return The productCategory. - */ - @java.lang.Override - public java.lang.String getProductCategory() { - java.lang.Object ref = productCategory_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - productCategory_ = s; - return s; + private GroupedResult() { + results_ = java.util.Collections.emptyList(); + objectAnnotations_ = java.util.Collections.emptyList(); } - } - /** - * - * - *
-   * Product category.
-   * Supported values are `bag` and `shoe`.
-   * [Deprecated] `product_category` is provided in each Product.
-   * 
- * - * string product_category = 4; - * - * @return The bytes for productCategory. - */ - @java.lang.Override - public com.google.protobuf.ByteString getProductCategoryBytes() { - java.lang.Object ref = productCategory_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - productCategory_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GroupedResult(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private GroupedResult( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.cloud.vision.v1p3beta1.BoundingPoly.Builder subBuilder = null; + if (boundingPoly_ != null) { + subBuilder = boundingPoly_.toBuilder(); + } + boundingPoly_ = + input.readMessage( + com.google.cloud.vision.v1p3beta1.BoundingPoly.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(boundingPoly_); + boundingPoly_ = subBuilder.buildPartial(); + } + + break; + } + case 18: + { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + results_ = + new java.util.ArrayList< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result>(); + mutable_bitField0_ |= 0x00000001; + } + results_.add( + input.readMessage( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.parser(), + extensionRegistry)); + break; + } + case 26: + { + if (!((mutable_bitField0_ & 0x00000002) != 0)) { + objectAnnotations_ = + new java.util.ArrayList< + com.google.cloud.vision.v1p3beta1.ProductSearchResults + .ObjectAnnotation>(); + mutable_bitField0_ |= 0x00000002; + } + objectAnnotations_.add( + input.readMessage( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation + .parser(), + extensionRegistry)); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + results_ = java.util.Collections.unmodifiableList(results_); + } + if (((mutable_bitField0_ & 0x00000002) != 0)) { + objectAnnotations_ = java.util.Collections.unmodifiableList(objectAnnotations_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.vision.v1p3beta1.ProductSearchProto + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_GroupedResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.vision.v1p3beta1.ProductSearchProto + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_GroupedResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.class, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder.class); + } + + public static final int BOUNDING_POLY_FIELD_NUMBER = 1; + private com.google.cloud.vision.v1p3beta1.BoundingPoly boundingPoly_; + /** + * + * + *
+     * The bounding polygon around the product detected in the query image.
+     * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + * + * @return Whether the boundingPoly field is set. + */ + @java.lang.Override + public boolean hasBoundingPoly() { + return boundingPoly_ != null; + } + /** + * + * + *
+     * The bounding polygon around the product detected in the query image.
+     * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + * + * @return The boundingPoly. + */ + @java.lang.Override + public com.google.cloud.vision.v1p3beta1.BoundingPoly getBoundingPoly() { + return boundingPoly_ == null + ? com.google.cloud.vision.v1p3beta1.BoundingPoly.getDefaultInstance() + : boundingPoly_; + } + /** + * + * + *
+     * The bounding polygon around the product detected in the query image.
+     * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + */ + @java.lang.Override + public com.google.cloud.vision.v1p3beta1.BoundingPolyOrBuilder getBoundingPolyOrBuilder() { + return getBoundingPoly(); + } + + public static final int RESULTS_FIELD_NUMBER = 2; + private java.util.List results_; + /** + * + * + *
+     * List of results, one for each product match.
+     * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + */ + @java.lang.Override + public java.util.List + getResultsList() { + return results_; + } + /** + * + * + *
+     * List of results, one for each product match.
+     * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + */ + @java.lang.Override + public java.util.List< + ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder> + getResultsOrBuilderList() { + return results_; + } + /** + * + * + *
+     * List of results, one for each product match.
+     * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + */ + @java.lang.Override + public int getResultsCount() { + return results_.size(); + } + /** + * + * + *
+     * List of results, one for each product match.
+     * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + */ + @java.lang.Override + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result getResults(int index) { + return results_.get(index); + } + /** + * + * + *
+     * List of results, one for each product match.
+     * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + */ + @java.lang.Override + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder + getResultsOrBuilder(int index) { + return results_.get(index); + } + + public static final int OBJECT_ANNOTATIONS_FIELD_NUMBER = 3; + private java.util.List + objectAnnotations_; + /** + * + * + *
+     * List of generic predictions for the object in the bounding box.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + @java.lang.Override + public java.util.List + getObjectAnnotationsList() { + return objectAnnotations_; + } + /** + * + * + *
+     * List of generic predictions for the object in the bounding box.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + @java.lang.Override + public java.util.List< + ? extends + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotationOrBuilder> + getObjectAnnotationsOrBuilderList() { + return objectAnnotations_; + } + /** + * + * + *
+     * List of generic predictions for the object in the bounding box.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + @java.lang.Override + public int getObjectAnnotationsCount() { + return objectAnnotations_.size(); + } + /** + * + * + *
+     * List of generic predictions for the object in the bounding box.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + @java.lang.Override + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation + getObjectAnnotations(int index) { + return objectAnnotations_.get(index); + } + /** + * + * + *
+     * List of generic predictions for the object in the bounding box.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + @java.lang.Override + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotationOrBuilder + getObjectAnnotationsOrBuilder(int index) { + return objectAnnotations_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (boundingPoly_ != null) { + output.writeMessage(1, getBoundingPoly()); + } + for (int i = 0; i < results_.size(); i++) { + output.writeMessage(2, results_.get(i)); + } + for (int i = 0; i < objectAnnotations_.size(); i++) { + output.writeMessage(3, objectAnnotations_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (boundingPoly_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getBoundingPoly()); + } + for (int i = 0; i < results_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, results_.get(i)); + } + for (int i = 0; i < objectAnnotations_.size(); i++) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize(3, objectAnnotations_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult)) { + return super.equals(obj); + } + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult other = + (com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult) obj; + + if (hasBoundingPoly() != other.hasBoundingPoly()) return false; + if (hasBoundingPoly()) { + if (!getBoundingPoly().equals(other.getBoundingPoly())) return false; + } + if (!getResultsList().equals(other.getResultsList())) return false; + if (!getObjectAnnotationsList().equals(other.getObjectAnnotationsList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasBoundingPoly()) { + hash = (37 * hash) + BOUNDING_POLY_FIELD_NUMBER; + hash = (53 * hash) + getBoundingPoly().hashCode(); + } + if (getResultsCount() > 0) { + hash = (37 * hash) + RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getResultsList().hashCode(); + } + if (getObjectAnnotationsCount() > 0) { + hash = (37 * hash) + OBJECT_ANNOTATIONS_FIELD_NUMBER; + hash = (53 * hash) + getObjectAnnotationsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+     * Information about the products similar to a single product in a query
+     * image.
+     * 
+ * + * Protobuf type {@code google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult) + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.vision.v1p3beta1.ProductSearchProto + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_GroupedResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.vision.v1p3beta1.ProductSearchProto + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_GroupedResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.class, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder.class); + } + + // Construct using + // com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getResultsFieldBuilder(); + getObjectAnnotationsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + if (boundingPolyBuilder_ == null) { + boundingPoly_ = null; + } else { + boundingPoly_ = null; + boundingPolyBuilder_ = null; + } + if (resultsBuilder_ == null) { + results_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + resultsBuilder_.clear(); + } + if (objectAnnotationsBuilder_ == null) { + objectAnnotations_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + objectAnnotationsBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.vision.v1p3beta1.ProductSearchProto + .internal_static_google_cloud_vision_v1p3beta1_ProductSearchResults_GroupedResult_descriptor; + } + + @java.lang.Override + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + getDefaultInstanceForType() { + return com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult build() { + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult buildPartial() { + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult result = + new com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult(this); + int from_bitField0_ = bitField0_; + if (boundingPolyBuilder_ == null) { + result.boundingPoly_ = boundingPoly_; + } else { + result.boundingPoly_ = boundingPolyBuilder_.build(); + } + if (resultsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + results_ = java.util.Collections.unmodifiableList(results_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.results_ = results_; + } else { + result.results_ = resultsBuilder_.build(); + } + if (objectAnnotationsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + objectAnnotations_ = java.util.Collections.unmodifiableList(objectAnnotations_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.objectAnnotations_ = objectAnnotations_; + } else { + result.objectAnnotations_ = objectAnnotationsBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult) { + return mergeFrom( + (com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult other) { + if (other + == com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + .getDefaultInstance()) return this; + if (other.hasBoundingPoly()) { + mergeBoundingPoly(other.getBoundingPoly()); + } + if (resultsBuilder_ == null) { + if (!other.results_.isEmpty()) { + if (results_.isEmpty()) { + results_ = other.results_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureResultsIsMutable(); + results_.addAll(other.results_); + } + onChanged(); + } + } else { + if (!other.results_.isEmpty()) { + if (resultsBuilder_.isEmpty()) { + resultsBuilder_.dispose(); + resultsBuilder_ = null; + results_ = other.results_; + bitField0_ = (bitField0_ & ~0x00000001); + resultsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getResultsFieldBuilder() + : null; + } else { + resultsBuilder_.addAllMessages(other.results_); + } + } + } + if (objectAnnotationsBuilder_ == null) { + if (!other.objectAnnotations_.isEmpty()) { + if (objectAnnotations_.isEmpty()) { + objectAnnotations_ = other.objectAnnotations_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureObjectAnnotationsIsMutable(); + objectAnnotations_.addAll(other.objectAnnotations_); + } + onChanged(); + } + } else { + if (!other.objectAnnotations_.isEmpty()) { + if (objectAnnotationsBuilder_.isEmpty()) { + objectAnnotationsBuilder_.dispose(); + objectAnnotationsBuilder_ = null; + objectAnnotations_ = other.objectAnnotations_; + bitField0_ = (bitField0_ & ~0x00000002); + objectAnnotationsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getObjectAnnotationsFieldBuilder() + : null; + } else { + objectAnnotationsBuilder_.addAllMessages(other.objectAnnotations_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult) + e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private com.google.cloud.vision.v1p3beta1.BoundingPoly boundingPoly_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.BoundingPoly, + com.google.cloud.vision.v1p3beta1.BoundingPoly.Builder, + com.google.cloud.vision.v1p3beta1.BoundingPolyOrBuilder> + boundingPolyBuilder_; + /** + * + * + *
+       * The bounding polygon around the product detected in the query image.
+       * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + * + * @return Whether the boundingPoly field is set. + */ + public boolean hasBoundingPoly() { + return boundingPolyBuilder_ != null || boundingPoly_ != null; + } + /** + * + * + *
+       * The bounding polygon around the product detected in the query image.
+       * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + * + * @return The boundingPoly. + */ + public com.google.cloud.vision.v1p3beta1.BoundingPoly getBoundingPoly() { + if (boundingPolyBuilder_ == null) { + return boundingPoly_ == null + ? com.google.cloud.vision.v1p3beta1.BoundingPoly.getDefaultInstance() + : boundingPoly_; + } else { + return boundingPolyBuilder_.getMessage(); + } + } + /** + * + * + *
+       * The bounding polygon around the product detected in the query image.
+       * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + */ + public Builder setBoundingPoly(com.google.cloud.vision.v1p3beta1.BoundingPoly value) { + if (boundingPolyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + boundingPoly_ = value; + onChanged(); + } else { + boundingPolyBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+       * The bounding polygon around the product detected in the query image.
+       * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + */ + public Builder setBoundingPoly( + com.google.cloud.vision.v1p3beta1.BoundingPoly.Builder builderForValue) { + if (boundingPolyBuilder_ == null) { + boundingPoly_ = builderForValue.build(); + onChanged(); + } else { + boundingPolyBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+       * The bounding polygon around the product detected in the query image.
+       * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + */ + public Builder mergeBoundingPoly(com.google.cloud.vision.v1p3beta1.BoundingPoly value) { + if (boundingPolyBuilder_ == null) { + if (boundingPoly_ != null) { + boundingPoly_ = + com.google.cloud.vision.v1p3beta1.BoundingPoly.newBuilder(boundingPoly_) + .mergeFrom(value) + .buildPartial(); + } else { + boundingPoly_ = value; + } + onChanged(); + } else { + boundingPolyBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+       * The bounding polygon around the product detected in the query image.
+       * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + */ + public Builder clearBoundingPoly() { + if (boundingPolyBuilder_ == null) { + boundingPoly_ = null; + onChanged(); + } else { + boundingPoly_ = null; + boundingPolyBuilder_ = null; + } + + return this; + } + /** + * + * + *
+       * The bounding polygon around the product detected in the query image.
+       * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + */ + public com.google.cloud.vision.v1p3beta1.BoundingPoly.Builder getBoundingPolyBuilder() { + + onChanged(); + return getBoundingPolyFieldBuilder().getBuilder(); + } + /** + * + * + *
+       * The bounding polygon around the product detected in the query image.
+       * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + */ + public com.google.cloud.vision.v1p3beta1.BoundingPolyOrBuilder getBoundingPolyOrBuilder() { + if (boundingPolyBuilder_ != null) { + return boundingPolyBuilder_.getMessageOrBuilder(); + } else { + return boundingPoly_ == null + ? com.google.cloud.vision.v1p3beta1.BoundingPoly.getDefaultInstance() + : boundingPoly_; + } + } + /** + * + * + *
+       * The bounding polygon around the product detected in the query image.
+       * 
+ * + * .google.cloud.vision.v1p3beta1.BoundingPoly bounding_poly = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.BoundingPoly, + com.google.cloud.vision.v1p3beta1.BoundingPoly.Builder, + com.google.cloud.vision.v1p3beta1.BoundingPolyOrBuilder> + getBoundingPolyFieldBuilder() { + if (boundingPolyBuilder_ == null) { + boundingPolyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.BoundingPoly, + com.google.cloud.vision.v1p3beta1.BoundingPoly.Builder, + com.google.cloud.vision.v1p3beta1.BoundingPolyOrBuilder>( + getBoundingPoly(), getParentForChildren(), isClean()); + boundingPoly_ = null; + } + return boundingPolyBuilder_; + } + + private java.util.List + results_ = java.util.Collections.emptyList(); + + private void ensureResultsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + results_ = + new java.util.ArrayList< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result>(results_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder> + resultsBuilder_; + + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public java.util.List + getResultsList() { + if (resultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(results_); + } else { + return resultsBuilder_.getMessageList(); + } + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public int getResultsCount() { + if (resultsBuilder_ == null) { + return results_.size(); + } else { + return resultsBuilder_.getCount(); + } + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result getResults(int index) { + if (resultsBuilder_ == null) { + return results_.get(index); + } else { + return resultsBuilder_.getMessage(index); + } + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public Builder setResults( + int index, com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result value) { + if (resultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureResultsIsMutable(); + results_.set(index, value); + onChanged(); + } else { + resultsBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public Builder setResults( + int index, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder builderForValue) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.set(index, builderForValue.build()); + onChanged(); + } else { + resultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public Builder addResults( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result value) { + if (resultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureResultsIsMutable(); + results_.add(value); + onChanged(); + } else { + resultsBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public Builder addResults( + int index, com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result value) { + if (resultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureResultsIsMutable(); + results_.add(index, value); + onChanged(); + } else { + resultsBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public Builder addResults( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder builderForValue) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.add(builderForValue.build()); + onChanged(); + } else { + resultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public Builder addResults( + int index, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder builderForValue) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.add(index, builderForValue.build()); + onChanged(); + } else { + resultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public Builder addAllResults( + java.lang.Iterable< + ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result> + values) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, results_); + onChanged(); + } else { + resultsBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public Builder clearResults() { + if (resultsBuilder_ == null) { + results_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + resultsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public Builder removeResults(int index) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.remove(index); + onChanged(); + } else { + resultsBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder + getResultsBuilder(int index) { + return getResultsFieldBuilder().getBuilder(index); + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder + getResultsOrBuilder(int index) { + if (resultsBuilder_ == null) { + return results_.get(index); + } else { + return resultsBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public java.util.List< + ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder> + getResultsOrBuilderList() { + if (resultsBuilder_ != null) { + return resultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(results_); + } + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder + addResultsBuilder() { + return getResultsFieldBuilder() + .addBuilder( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.getDefaultInstance()); + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder + addResultsBuilder(int index) { + return getResultsFieldBuilder() + .addBuilder( + index, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.getDefaultInstance()); + } + /** + * + * + *
+       * List of results, one for each product match.
+       * 
+ * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 2; + * + */ + public java.util.List + getResultsBuilderList() { + return getResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder> + getResultsFieldBuilder() { + if (resultsBuilder_ == null) { + resultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder>( + results_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + results_ = null; + } + return resultsBuilder_; + } + + private java.util.List< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation> + objectAnnotations_ = java.util.Collections.emptyList(); + + private void ensureObjectAnnotationsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + objectAnnotations_ = + new java.util.ArrayList< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation>( + objectAnnotations_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotationOrBuilder> + objectAnnotationsBuilder_; + + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public java.util.List + getObjectAnnotationsList() { + if (objectAnnotationsBuilder_ == null) { + return java.util.Collections.unmodifiableList(objectAnnotations_); + } else { + return objectAnnotationsBuilder_.getMessageList(); + } + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public int getObjectAnnotationsCount() { + if (objectAnnotationsBuilder_ == null) { + return objectAnnotations_.size(); + } else { + return objectAnnotationsBuilder_.getCount(); + } + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation + getObjectAnnotations(int index) { + if (objectAnnotationsBuilder_ == null) { + return objectAnnotations_.get(index); + } else { + return objectAnnotationsBuilder_.getMessage(index); + } + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public Builder setObjectAnnotations( + int index, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation value) { + if (objectAnnotationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureObjectAnnotationsIsMutable(); + objectAnnotations_.set(index, value); + onChanged(); + } else { + objectAnnotationsBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public Builder setObjectAnnotations( + int index, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder + builderForValue) { + if (objectAnnotationsBuilder_ == null) { + ensureObjectAnnotationsIsMutable(); + objectAnnotations_.set(index, builderForValue.build()); + onChanged(); + } else { + objectAnnotationsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public Builder addObjectAnnotations( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation value) { + if (objectAnnotationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureObjectAnnotationsIsMutable(); + objectAnnotations_.add(value); + onChanged(); + } else { + objectAnnotationsBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public Builder addObjectAnnotations( + int index, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation value) { + if (objectAnnotationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureObjectAnnotationsIsMutable(); + objectAnnotations_.add(index, value); + onChanged(); + } else { + objectAnnotationsBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public Builder addObjectAnnotations( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder + builderForValue) { + if (objectAnnotationsBuilder_ == null) { + ensureObjectAnnotationsIsMutable(); + objectAnnotations_.add(builderForValue.build()); + onChanged(); + } else { + objectAnnotationsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public Builder addObjectAnnotations( + int index, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder + builderForValue) { + if (objectAnnotationsBuilder_ == null) { + ensureObjectAnnotationsIsMutable(); + objectAnnotations_.add(index, builderForValue.build()); + onChanged(); + } else { + objectAnnotationsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public Builder addAllObjectAnnotations( + java.lang.Iterable< + ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation> + values) { + if (objectAnnotationsBuilder_ == null) { + ensureObjectAnnotationsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, objectAnnotations_); + onChanged(); + } else { + objectAnnotationsBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public Builder clearObjectAnnotations() { + if (objectAnnotationsBuilder_ == null) { + objectAnnotations_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + objectAnnotationsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public Builder removeObjectAnnotations(int index) { + if (objectAnnotationsBuilder_ == null) { + ensureObjectAnnotationsIsMutable(); + objectAnnotations_.remove(index); + onChanged(); + } else { + objectAnnotationsBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder + getObjectAnnotationsBuilder(int index) { + return getObjectAnnotationsFieldBuilder().getBuilder(index); + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotationOrBuilder + getObjectAnnotationsOrBuilder(int index) { + if (objectAnnotationsBuilder_ == null) { + return objectAnnotations_.get(index); + } else { + return objectAnnotationsBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public java.util.List< + ? extends + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotationOrBuilder> + getObjectAnnotationsOrBuilderList() { + if (objectAnnotationsBuilder_ != null) { + return objectAnnotationsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(objectAnnotations_); + } + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder + addObjectAnnotationsBuilder() { + return getObjectAnnotationsFieldBuilder() + .addBuilder( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation + .getDefaultInstance()); + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder + addObjectAnnotationsBuilder(int index) { + return getObjectAnnotationsFieldBuilder() + .addBuilder( + index, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation + .getDefaultInstance()); + } + /** + * + * + *
+       * List of generic predictions for the object in the bounding box.
+       * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation object_annotations = 3; + * + */ + public java.util.List< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder> + getObjectAnnotationsBuilderList() { + return getObjectAnnotationsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotationOrBuilder> + getObjectAnnotationsFieldBuilder() { + if (objectAnnotationsBuilder_ == null) { + objectAnnotationsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotation.Builder, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ObjectAnnotationOrBuilder>( + objectAnnotations_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + objectAnnotations_ = null; + } + return objectAnnotationsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult) + } + + // @@protoc_insertion_point(class_scope:google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult) + private static final com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult(); + } + + public static com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GroupedResult parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new GroupedResult(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; } } @@ -2381,8 +4471,9 @@ public com.google.protobuf.ByteString getProductCategoryBytes() { * * *
-   * Timestamp of the index which provided these results. Changes made after
-   * this time are not reflected in the current results.
+   * Timestamp of the index which provided these results. Products added to the
+   * product set and products removed from the product set after this time are
+   * not reflected in the current results.
    * 
* * .google.protobuf.Timestamp index_time = 2; @@ -2397,8 +4488,9 @@ public boolean hasIndexTime() { * * *
-   * Timestamp of the index which provided these results. Changes made after
-   * this time are not reflected in the current results.
+   * Timestamp of the index which provided these results. Products added to the
+   * product set and products removed from the product set after this time are
+   * not reflected in the current results.
    * 
* * .google.protobuf.Timestamp index_time = 2; @@ -2413,8 +4505,9 @@ public com.google.protobuf.Timestamp getIndexTime() { * * *
-   * Timestamp of the index which provided these results. Changes made after
-   * this time are not reflected in the current results.
+   * Timestamp of the index which provided these results. Products added to the
+   * product set and products removed from the product set after this time are
+   * not reflected in the current results.
    * 
* * .google.protobuf.Timestamp index_time = 2; @@ -2424,154 +4517,175 @@ public com.google.protobuf.TimestampOrBuilder getIndexTimeOrBuilder() { return getIndexTime(); } - public static final int PRODUCTS_FIELD_NUMBER = 3; - private java.util.List - products_; + public static final int RESULTS_FIELD_NUMBER = 5; + private java.util.List results_; /** * * *
-   * List of detected products.
+   * List of results, one for each product match.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; */ @java.lang.Override - public java.util.List - getProductsList() { - return products_; + public java.util.List + getResultsList() { + return results_; } /** * * *
-   * List of detected products.
+   * List of results, one for each product match.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; */ @java.lang.Override public java.util.List< - ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfoOrBuilder> - getProductsOrBuilderList() { - return products_; + ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder> + getResultsOrBuilderList() { + return results_; } /** * * *
-   * List of detected products.
+   * List of results, one for each product match.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; */ @java.lang.Override - public int getProductsCount() { - return products_.size(); + public int getResultsCount() { + return results_.size(); } /** * * *
-   * List of detected products.
+   * List of results, one for each product match.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; */ @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo getProducts(int index) { - return products_.get(index); + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result getResults(int index) { + return results_.get(index); } /** * * *
-   * List of detected products.
+   * List of results, one for each product match.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; */ @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfoOrBuilder - getProductsOrBuilder(int index) { - return products_.get(index); + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder getResultsOrBuilder( + int index) { + return results_.get(index); } - public static final int RESULTS_FIELD_NUMBER = 5; - private java.util.List results_; + public static final int PRODUCT_GROUPED_RESULTS_FIELD_NUMBER = 6; + private java.util.List + productGroupedResults_; /** * * *
-   * List of results, one for each product match.
+   * List of results grouped by products detected in the query image. Each entry
+   * corresponds to one bounding polygon in the query image, and contains the
+   * matching products specific to that region. There may be duplicate product
+   * matches in the union of all the per-product results.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * */ @java.lang.Override - public java.util.List - getResultsList() { - return results_; + public java.util.List + getProductGroupedResultsList() { + return productGroupedResults_; } /** * * *
-   * List of results, one for each product match.
+   * List of results grouped by products detected in the query image. Each entry
+   * corresponds to one bounding polygon in the query image, and contains the
+   * matching products specific to that region. There may be duplicate product
+   * matches in the union of all the per-product results.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * */ @java.lang.Override public java.util.List< - ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder> - getResultsOrBuilderList() { - return results_; + ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResultOrBuilder> + getProductGroupedResultsOrBuilderList() { + return productGroupedResults_; } /** * * *
-   * List of results, one for each product match.
+   * List of results grouped by products detected in the query image. Each entry
+   * corresponds to one bounding polygon in the query image, and contains the
+   * matching products specific to that region. There may be duplicate product
+   * matches in the union of all the per-product results.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * */ @java.lang.Override - public int getResultsCount() { - return results_.size(); + public int getProductGroupedResultsCount() { + return productGroupedResults_.size(); } /** * * *
-   * List of results, one for each product match.
+   * List of results grouped by products detected in the query image. Each entry
+   * corresponds to one bounding polygon in the query image, and contains the
+   * matching products specific to that region. There may be duplicate product
+   * matches in the union of all the per-product results.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * */ @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result getResults(int index) { - return results_.get(index); + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + getProductGroupedResults(int index) { + return productGroupedResults_.get(index); } /** * * *
-   * List of results, one for each product match.
+   * List of results grouped by products detected in the query image. Each entry
+   * corresponds to one bounding polygon in the query image, and contains the
+   * matching products specific to that region. There may be duplicate product
+   * matches in the union of all the per-product results.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * */ @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder getResultsOrBuilder( - int index) { - return results_.get(index); + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResultOrBuilder + getProductGroupedResultsOrBuilder(int index) { + return productGroupedResults_.get(index); } private byte memoizedIsInitialized = -1; @@ -2588,24 +4702,15 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (category_ - != com.google.cloud.vision.v1p3beta1.ProductSearchCategory - .PRODUCT_SEARCH_CATEGORY_UNSPECIFIED - .getNumber()) { - output.writeEnum(1, category_); - } if (indexTime_ != null) { output.writeMessage(2, getIndexTime()); } - for (int i = 0; i < products_.size(); i++) { - output.writeMessage(3, products_.get(i)); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(productCategory_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, productCategory_); - } for (int i = 0; i < results_.size(); i++) { output.writeMessage(5, results_.get(i)); } + for (int i = 0; i < productGroupedResults_.size(); i++) { + output.writeMessage(6, productGroupedResults_.get(i)); + } unknownFields.writeTo(output); } @@ -2615,24 +4720,17 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (category_ - != com.google.cloud.vision.v1p3beta1.ProductSearchCategory - .PRODUCT_SEARCH_CATEGORY_UNSPECIFIED - .getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, category_); - } if (indexTime_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getIndexTime()); } - for (int i = 0; i < products_.size(); i++) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, products_.get(i)); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(productCategory_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, productCategory_); - } for (int i = 0; i < results_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, results_.get(i)); } + for (int i = 0; i < productGroupedResults_.size(); i++) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, productGroupedResults_.get(i)); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -2649,14 +4747,12 @@ public boolean equals(final java.lang.Object obj) { com.google.cloud.vision.v1p3beta1.ProductSearchResults other = (com.google.cloud.vision.v1p3beta1.ProductSearchResults) obj; - if (category_ != other.category_) return false; - if (!getProductCategory().equals(other.getProductCategory())) return false; if (hasIndexTime() != other.hasIndexTime()) return false; if (hasIndexTime()) { if (!getIndexTime().equals(other.getIndexTime())) return false; } - if (!getProductsList().equals(other.getProductsList())) return false; if (!getResultsList().equals(other.getResultsList())) return false; + if (!getProductGroupedResultsList().equals(other.getProductGroupedResultsList())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -2668,22 +4764,18 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + CATEGORY_FIELD_NUMBER; - hash = (53 * hash) + category_; - hash = (37 * hash) + PRODUCT_CATEGORY_FIELD_NUMBER; - hash = (53 * hash) + getProductCategory().hashCode(); if (hasIndexTime()) { hash = (37 * hash) + INDEX_TIME_FIELD_NUMBER; hash = (53 * hash) + getIndexTime().hashCode(); } - if (getProductsCount() > 0) { - hash = (37 * hash) + PRODUCTS_FIELD_NUMBER; - hash = (53 * hash) + getProductsList().hashCode(); - } if (getResultsCount() > 0) { hash = (37 * hash) + RESULTS_FIELD_NUMBER; hash = (53 * hash) + getResultsList().hashCode(); } + if (getProductGroupedResultsCount() > 0) { + hash = (37 * hash) + PRODUCT_GROUPED_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getProductGroupedResultsList().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -2825,35 +4917,31 @@ private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { - getProductsFieldBuilder(); getResultsFieldBuilder(); + getProductGroupedResultsFieldBuilder(); } } @java.lang.Override public Builder clear() { super.clear(); - category_ = 0; - - productCategory_ = ""; - if (indexTimeBuilder_ == null) { indexTime_ = null; } else { indexTime_ = null; indexTimeBuilder_ = null; } - if (productsBuilder_ == null) { - products_ = java.util.Collections.emptyList(); + if (resultsBuilder_ == null) { + results_ = java.util.Collections.emptyList(); bitField0_ = (bitField0_ & ~0x00000001); } else { - productsBuilder_.clear(); + resultsBuilder_.clear(); } - if (resultsBuilder_ == null) { - results_ = java.util.Collections.emptyList(); + if (productGroupedResultsBuilder_ == null) { + productGroupedResults_ = java.util.Collections.emptyList(); bitField0_ = (bitField0_ & ~0x00000002); } else { - resultsBuilder_.clear(); + productGroupedResultsBuilder_.clear(); } return this; } @@ -2883,30 +4971,28 @@ public com.google.cloud.vision.v1p3beta1.ProductSearchResults buildPartial() { com.google.cloud.vision.v1p3beta1.ProductSearchResults result = new com.google.cloud.vision.v1p3beta1.ProductSearchResults(this); int from_bitField0_ = bitField0_; - result.category_ = category_; - result.productCategory_ = productCategory_; if (indexTimeBuilder_ == null) { result.indexTime_ = indexTime_; } else { result.indexTime_ = indexTimeBuilder_.build(); } - if (productsBuilder_ == null) { + if (resultsBuilder_ == null) { if (((bitField0_ & 0x00000001) != 0)) { - products_ = java.util.Collections.unmodifiableList(products_); + results_ = java.util.Collections.unmodifiableList(results_); bitField0_ = (bitField0_ & ~0x00000001); } - result.products_ = products_; + result.results_ = results_; } else { - result.products_ = productsBuilder_.build(); + result.results_ = resultsBuilder_.build(); } - if (resultsBuilder_ == null) { + if (productGroupedResultsBuilder_ == null) { if (((bitField0_ & 0x00000002) != 0)) { - results_ = java.util.Collections.unmodifiableList(results_); + productGroupedResults_ = java.util.Collections.unmodifiableList(productGroupedResults_); bitField0_ = (bitField0_ & ~0x00000002); } - result.results_ = results_; + result.productGroupedResults_ = productGroupedResults_; } else { - result.results_ = resultsBuilder_.build(); + result.productGroupedResults_ = productGroupedResultsBuilder_.build(); } onBuilt(); return result; @@ -2958,67 +5044,60 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(com.google.cloud.vision.v1p3beta1.ProductSearchResults other) { if (other == com.google.cloud.vision.v1p3beta1.ProductSearchResults.getDefaultInstance()) return this; - if (other.category_ != 0) { - setCategoryValue(other.getCategoryValue()); - } - if (!other.getProductCategory().isEmpty()) { - productCategory_ = other.productCategory_; - onChanged(); - } if (other.hasIndexTime()) { mergeIndexTime(other.getIndexTime()); } - if (productsBuilder_ == null) { - if (!other.products_.isEmpty()) { - if (products_.isEmpty()) { - products_ = other.products_; + if (resultsBuilder_ == null) { + if (!other.results_.isEmpty()) { + if (results_.isEmpty()) { + results_ = other.results_; bitField0_ = (bitField0_ & ~0x00000001); } else { - ensureProductsIsMutable(); - products_.addAll(other.products_); + ensureResultsIsMutable(); + results_.addAll(other.results_); } onChanged(); } } else { - if (!other.products_.isEmpty()) { - if (productsBuilder_.isEmpty()) { - productsBuilder_.dispose(); - productsBuilder_ = null; - products_ = other.products_; + if (!other.results_.isEmpty()) { + if (resultsBuilder_.isEmpty()) { + resultsBuilder_.dispose(); + resultsBuilder_ = null; + results_ = other.results_; bitField0_ = (bitField0_ & ~0x00000001); - productsBuilder_ = + resultsBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders - ? getProductsFieldBuilder() + ? getResultsFieldBuilder() : null; } else { - productsBuilder_.addAllMessages(other.products_); + resultsBuilder_.addAllMessages(other.results_); } } } - if (resultsBuilder_ == null) { - if (!other.results_.isEmpty()) { - if (results_.isEmpty()) { - results_ = other.results_; + if (productGroupedResultsBuilder_ == null) { + if (!other.productGroupedResults_.isEmpty()) { + if (productGroupedResults_.isEmpty()) { + productGroupedResults_ = other.productGroupedResults_; bitField0_ = (bitField0_ & ~0x00000002); } else { - ensureResultsIsMutable(); - results_.addAll(other.results_); + ensureProductGroupedResultsIsMutable(); + productGroupedResults_.addAll(other.productGroupedResults_); } onChanged(); } } else { - if (!other.results_.isEmpty()) { - if (resultsBuilder_.isEmpty()) { - resultsBuilder_.dispose(); - resultsBuilder_ = null; - results_ = other.results_; + if (!other.productGroupedResults_.isEmpty()) { + if (productGroupedResultsBuilder_.isEmpty()) { + productGroupedResultsBuilder_.dispose(); + productGroupedResultsBuilder_ = null; + productGroupedResults_ = other.productGroupedResults_; bitField0_ = (bitField0_ & ~0x00000002); - resultsBuilder_ = + productGroupedResultsBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders - ? getResultsFieldBuilder() + ? getProductGroupedResultsFieldBuilder() : null; } else { - resultsBuilder_.addAllMessages(other.results_); + productGroupedResultsBuilder_.addAllMessages(other.productGroupedResults_); } } } @@ -3051,222 +5130,8 @@ public Builder mergeFrom( } return this; } - - private int bitField0_; - - private int category_ = 0; - /** - * - * - *
-     * Product category.
-     * [Deprecated] Use `product_category`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 1; - * - * @return The enum numeric value on the wire for category. - */ - @java.lang.Override - public int getCategoryValue() { - return category_; - } - /** - * - * - *
-     * Product category.
-     * [Deprecated] Use `product_category`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 1; - * - * @param value The enum numeric value on the wire for category to set. - * @return This builder for chaining. - */ - public Builder setCategoryValue(int value) { - - category_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Product category.
-     * [Deprecated] Use `product_category`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 1; - * - * @return The category. - */ - @java.lang.Override - public com.google.cloud.vision.v1p3beta1.ProductSearchCategory getCategory() { - @SuppressWarnings("deprecation") - com.google.cloud.vision.v1p3beta1.ProductSearchCategory result = - com.google.cloud.vision.v1p3beta1.ProductSearchCategory.valueOf(category_); - return result == null - ? com.google.cloud.vision.v1p3beta1.ProductSearchCategory.UNRECOGNIZED - : result; - } - /** - * - * - *
-     * Product category.
-     * [Deprecated] Use `product_category`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 1; - * - * @param value The category to set. - * @return This builder for chaining. - */ - public Builder setCategory(com.google.cloud.vision.v1p3beta1.ProductSearchCategory value) { - if (value == null) { - throw new NullPointerException(); - } - - category_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * Product category.
-     * [Deprecated] Use `product_category`.
-     * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 1; - * - * @return This builder for chaining. - */ - public Builder clearCategory() { - - category_ = 0; - onChanged(); - return this; - } - - private java.lang.Object productCategory_ = ""; - /** - * - * - *
-     * Product category.
-     * Supported values are `bag` and `shoe`.
-     * [Deprecated] `product_category` is provided in each Product.
-     * 
- * - * string product_category = 4; - * - * @return The productCategory. - */ - public java.lang.String getProductCategory() { - java.lang.Object ref = productCategory_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - productCategory_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Product category.
-     * Supported values are `bag` and `shoe`.
-     * [Deprecated] `product_category` is provided in each Product.
-     * 
- * - * string product_category = 4; - * - * @return The bytes for productCategory. - */ - public com.google.protobuf.ByteString getProductCategoryBytes() { - java.lang.Object ref = productCategory_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - productCategory_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Product category.
-     * Supported values are `bag` and `shoe`.
-     * [Deprecated] `product_category` is provided in each Product.
-     * 
- * - * string product_category = 4; - * - * @param value The productCategory to set. - * @return This builder for chaining. - */ - public Builder setProductCategory(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - productCategory_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Product category.
-     * Supported values are `bag` and `shoe`.
-     * [Deprecated] `product_category` is provided in each Product.
-     * 
- * - * string product_category = 4; - * - * @return This builder for chaining. - */ - public Builder clearProductCategory() { - - productCategory_ = getDefaultInstance().getProductCategory(); - onChanged(); - return this; - } - /** - * - * - *
-     * Product category.
-     * Supported values are `bag` and `shoe`.
-     * [Deprecated] `product_category` is provided in each Product.
-     * 
- * - * string product_category = 4; - * - * @param value The bytes for productCategory to set. - * @return This builder for chaining. - */ - public Builder setProductCategoryBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - productCategory_ = value; - onChanged(); - return this; - } + + private int bitField0_; private com.google.protobuf.Timestamp indexTime_; private com.google.protobuf.SingleFieldBuilderV3< @@ -3278,8 +5143,9 @@ public Builder setProductCategoryBytes(com.google.protobuf.ByteString value) { * * *
-     * Timestamp of the index which provided these results. Changes made after
-     * this time are not reflected in the current results.
+     * Timestamp of the index which provided these results. Products added to the
+     * product set and products removed from the product set after this time are
+     * not reflected in the current results.
      * 
* * .google.protobuf.Timestamp index_time = 2; @@ -3293,8 +5159,9 @@ public boolean hasIndexTime() { * * *
-     * Timestamp of the index which provided these results. Changes made after
-     * this time are not reflected in the current results.
+     * Timestamp of the index which provided these results. Products added to the
+     * product set and products removed from the product set after this time are
+     * not reflected in the current results.
      * 
* * .google.protobuf.Timestamp index_time = 2; @@ -3312,8 +5179,9 @@ public com.google.protobuf.Timestamp getIndexTime() { * * *
-     * Timestamp of the index which provided these results. Changes made after
-     * this time are not reflected in the current results.
+     * Timestamp of the index which provided these results. Products added to the
+     * product set and products removed from the product set after this time are
+     * not reflected in the current results.
      * 
* * .google.protobuf.Timestamp index_time = 2; @@ -3335,8 +5203,9 @@ public Builder setIndexTime(com.google.protobuf.Timestamp value) { * * *
-     * Timestamp of the index which provided these results. Changes made after
-     * this time are not reflected in the current results.
+     * Timestamp of the index which provided these results. Products added to the
+     * product set and products removed from the product set after this time are
+     * not reflected in the current results.
      * 
* * .google.protobuf.Timestamp index_time = 2; @@ -3355,8 +5224,9 @@ public Builder setIndexTime(com.google.protobuf.Timestamp.Builder builderForValu * * *
-     * Timestamp of the index which provided these results. Changes made after
-     * this time are not reflected in the current results.
+     * Timestamp of the index which provided these results. Products added to the
+     * product set and products removed from the product set after this time are
+     * not reflected in the current results.
      * 
* * .google.protobuf.Timestamp index_time = 2; @@ -3380,8 +5250,9 @@ public Builder mergeIndexTime(com.google.protobuf.Timestamp value) { * * *
-     * Timestamp of the index which provided these results. Changes made after
-     * this time are not reflected in the current results.
+     * Timestamp of the index which provided these results. Products added to the
+     * product set and products removed from the product set after this time are
+     * not reflected in the current results.
      * 
* * .google.protobuf.Timestamp index_time = 2; @@ -3401,8 +5272,9 @@ public Builder clearIndexTime() { * * *
-     * Timestamp of the index which provided these results. Changes made after
-     * this time are not reflected in the current results.
+     * Timestamp of the index which provided these results. Products added to the
+     * product set and products removed from the product set after this time are
+     * not reflected in the current results.
      * 
* * .google.protobuf.Timestamp index_time = 2; @@ -3416,8 +5288,9 @@ public com.google.protobuf.Timestamp.Builder getIndexTimeBuilder() { * * *
-     * Timestamp of the index which provided these results. Changes made after
-     * this time are not reflected in the current results.
+     * Timestamp of the index which provided these results. Products added to the
+     * product set and products removed from the product set after this time are
+     * not reflected in the current results.
      * 
* * .google.protobuf.Timestamp index_time = 2; @@ -3433,8 +5306,9 @@ public com.google.protobuf.TimestampOrBuilder getIndexTimeOrBuilder() { * * *
-     * Timestamp of the index which provided these results. Changes made after
-     * this time are not reflected in the current results.
+     * Timestamp of the index which provided these results. Products added to the
+     * product set and products removed from the product set after this time are
+     * not reflected in the current results.
      * 
* * .google.protobuf.Timestamp index_time = 2; @@ -3449,415 +5323,22 @@ public com.google.protobuf.TimestampOrBuilder getIndexTimeOrBuilder() { new com.google.protobuf.SingleFieldBuilderV3< com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getIndexTime(), getParentForChildren(), isClean()); - indexTime_ = null; - } - return indexTimeBuilder_; - } - - private java.util.List - products_ = java.util.Collections.emptyList(); - - private void ensureProductsIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - products_ = - new java.util.ArrayList< - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo>(products_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfoOrBuilder> - productsBuilder_; - - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public java.util.List - getProductsList() { - if (productsBuilder_ == null) { - return java.util.Collections.unmodifiableList(products_); - } else { - return productsBuilder_.getMessageList(); - } - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public int getProductsCount() { - if (productsBuilder_ == null) { - return products_.size(); - } else { - return productsBuilder_.getCount(); - } - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo getProducts( - int index) { - if (productsBuilder_ == null) { - return products_.get(index); - } else { - return productsBuilder_.getMessage(index); - } - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public Builder setProducts( - int index, com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo value) { - if (productsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureProductsIsMutable(); - products_.set(index, value); - onChanged(); - } else { - productsBuilder_.setMessage(index, value); - } - return this; - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public Builder setProducts( - int index, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder - builderForValue) { - if (productsBuilder_ == null) { - ensureProductsIsMutable(); - products_.set(index, builderForValue.build()); - onChanged(); - } else { - productsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public Builder addProducts( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo value) { - if (productsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureProductsIsMutable(); - products_.add(value); - onChanged(); - } else { - productsBuilder_.addMessage(value); - } - return this; - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public Builder addProducts( - int index, com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo value) { - if (productsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureProductsIsMutable(); - products_.add(index, value); - onChanged(); - } else { - productsBuilder_.addMessage(index, value); - } - return this; - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public Builder addProducts( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder - builderForValue) { - if (productsBuilder_ == null) { - ensureProductsIsMutable(); - products_.add(builderForValue.build()); - onChanged(); - } else { - productsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public Builder addProducts( - int index, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder - builderForValue) { - if (productsBuilder_ == null) { - ensureProductsIsMutable(); - products_.add(index, builderForValue.build()); - onChanged(); - } else { - productsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public Builder addAllProducts( - java.lang.Iterable< - ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo> - values) { - if (productsBuilder_ == null) { - ensureProductsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll(values, products_); - onChanged(); - } else { - productsBuilder_.addAllMessages(values); - } - return this; - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public Builder clearProducts() { - if (productsBuilder_ == null) { - products_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - productsBuilder_.clear(); - } - return this; - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public Builder removeProducts(int index) { - if (productsBuilder_ == null) { - ensureProductsIsMutable(); - products_.remove(index); - onChanged(); - } else { - productsBuilder_.remove(index); - } - return this; - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder - getProductsBuilder(int index) { - return getProductsFieldBuilder().getBuilder(index); - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfoOrBuilder - getProductsOrBuilder(int index) { - if (productsBuilder_ == null) { - return products_.get(index); - } else { - return productsBuilder_.getMessageOrBuilder(index); - } - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public java.util.List< - ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfoOrBuilder> - getProductsOrBuilderList() { - if (productsBuilder_ != null) { - return productsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(products_); - } - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder - addProductsBuilder() { - return getProductsFieldBuilder() - .addBuilder( - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo - .getDefaultInstance()); - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder - addProductsBuilder(int index) { - return getProductsFieldBuilder() - .addBuilder( - index, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo - .getDefaultInstance()); - } - /** - * - * - *
-     * List of detected products.
-     * 
- * - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * - */ - public java.util.List< - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder> - getProductsBuilderList() { - return getProductsFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfoOrBuilder> - getProductsFieldBuilder() { - if (productsBuilder_ == null) { - productsBuilder_ = - new com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo.Builder, - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfoOrBuilder>( - products_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); - products_ = null; + com.google.protobuf.TimestampOrBuilder>( + getIndexTime(), getParentForChildren(), isClean()); + indexTime_ = null; } - return productsBuilder_; + return indexTimeBuilder_; } private java.util.List results_ = java.util.Collections.emptyList(); private void ensureResultsIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { results_ = new java.util.ArrayList( results_); - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000001; } } @@ -4079,7 +5560,7 @@ public Builder addAllResults( public Builder clearResults() { if (resultsBuilder_ == null) { results_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); } else { resultsBuilder_.clear(); @@ -4209,12 +5690,481 @@ public com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder add com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result, com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result.Builder, com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder>( - results_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + results_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); results_ = null; } return resultsBuilder_; } + private java.util.List + productGroupedResults_ = java.util.Collections.emptyList(); + + private void ensureProductGroupedResultsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + productGroupedResults_ = + new java.util.ArrayList< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult>( + productGroupedResults_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResultOrBuilder> + productGroupedResultsBuilder_; + + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public java.util.List + getProductGroupedResultsList() { + if (productGroupedResultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(productGroupedResults_); + } else { + return productGroupedResultsBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public int getProductGroupedResultsCount() { + if (productGroupedResultsBuilder_ == null) { + return productGroupedResults_.size(); + } else { + return productGroupedResultsBuilder_.getCount(); + } + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + getProductGroupedResults(int index) { + if (productGroupedResultsBuilder_ == null) { + return productGroupedResults_.get(index); + } else { + return productGroupedResultsBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public Builder setProductGroupedResults( + int index, com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult value) { + if (productGroupedResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProductGroupedResultsIsMutable(); + productGroupedResults_.set(index, value); + onChanged(); + } else { + productGroupedResultsBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public Builder setProductGroupedResults( + int index, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder + builderForValue) { + if (productGroupedResultsBuilder_ == null) { + ensureProductGroupedResultsIsMutable(); + productGroupedResults_.set(index, builderForValue.build()); + onChanged(); + } else { + productGroupedResultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public Builder addProductGroupedResults( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult value) { + if (productGroupedResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProductGroupedResultsIsMutable(); + productGroupedResults_.add(value); + onChanged(); + } else { + productGroupedResultsBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public Builder addProductGroupedResults( + int index, com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult value) { + if (productGroupedResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProductGroupedResultsIsMutable(); + productGroupedResults_.add(index, value); + onChanged(); + } else { + productGroupedResultsBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public Builder addProductGroupedResults( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder + builderForValue) { + if (productGroupedResultsBuilder_ == null) { + ensureProductGroupedResultsIsMutable(); + productGroupedResults_.add(builderForValue.build()); + onChanged(); + } else { + productGroupedResultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public Builder addProductGroupedResults( + int index, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder + builderForValue) { + if (productGroupedResultsBuilder_ == null) { + ensureProductGroupedResultsIsMutable(); + productGroupedResults_.add(index, builderForValue.build()); + onChanged(); + } else { + productGroupedResultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public Builder addAllProductGroupedResults( + java.lang.Iterable< + ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult> + values) { + if (productGroupedResultsBuilder_ == null) { + ensureProductGroupedResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, productGroupedResults_); + onChanged(); + } else { + productGroupedResultsBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public Builder clearProductGroupedResults() { + if (productGroupedResultsBuilder_ == null) { + productGroupedResults_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + productGroupedResultsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public Builder removeProductGroupedResults(int index) { + if (productGroupedResultsBuilder_ == null) { + ensureProductGroupedResultsIsMutable(); + productGroupedResults_.remove(index); + onChanged(); + } else { + productGroupedResultsBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder + getProductGroupedResultsBuilder(int index) { + return getProductGroupedResultsFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResultOrBuilder + getProductGroupedResultsOrBuilder(int index) { + if (productGroupedResultsBuilder_ == null) { + return productGroupedResults_.get(index); + } else { + return productGroupedResultsBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public java.util.List< + ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResultOrBuilder> + getProductGroupedResultsOrBuilderList() { + if (productGroupedResultsBuilder_ != null) { + return productGroupedResultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(productGroupedResults_); + } + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder + addProductGroupedResultsBuilder() { + return getProductGroupedResultsFieldBuilder() + .addBuilder( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + .getDefaultInstance()); + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder + addProductGroupedResultsBuilder(int index) { + return getProductGroupedResultsFieldBuilder() + .addBuilder( + index, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult + .getDefaultInstance()); + } + /** + * + * + *
+     * List of results grouped by products detected in the query image. Each entry
+     * corresponds to one bounding polygon in the query image, and contains the
+     * matching products specific to that region. There may be duplicate product
+     * matches in the union of all the per-product results.
+     * 
+ * + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * + */ + public java.util.List< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder> + getProductGroupedResultsBuilderList() { + return getProductGroupedResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResultOrBuilder> + getProductGroupedResultsFieldBuilder() { + if (productGroupedResultsBuilder_ == null) { + productGroupedResultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult.Builder, + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResultOrBuilder>( + productGroupedResults_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + productGroupedResults_ = null; + } + return productGroupedResultsBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchResultsOrBuilder.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchResultsOrBuilder.java index 23dd456e5..6802c4873 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchResultsOrBuilder.java +++ b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchResultsOrBuilder.java @@ -27,64 +27,9 @@ public interface ProductSearchResultsOrBuilder * * *
-   * Product category.
-   * [Deprecated] Use `product_category`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 1; - * - * @return The enum numeric value on the wire for category. - */ - int getCategoryValue(); - /** - * - * - *
-   * Product category.
-   * [Deprecated] Use `product_category`.
-   * 
- * - * .google.cloud.vision.v1p3beta1.ProductSearchCategory category = 1; - * - * @return The category. - */ - com.google.cloud.vision.v1p3beta1.ProductSearchCategory getCategory(); - - /** - * - * - *
-   * Product category.
-   * Supported values are `bag` and `shoe`.
-   * [Deprecated] `product_category` is provided in each Product.
-   * 
- * - * string product_category = 4; - * - * @return The productCategory. - */ - java.lang.String getProductCategory(); - /** - * - * - *
-   * Product category.
-   * Supported values are `bag` and `shoe`.
-   * [Deprecated] `product_category` is provided in each Product.
-   * 
- * - * string product_category = 4; - * - * @return The bytes for productCategory. - */ - com.google.protobuf.ByteString getProductCategoryBytes(); - - /** - * - * - *
-   * Timestamp of the index which provided these results. Changes made after
-   * this time are not reflected in the current results.
+   * Timestamp of the index which provided these results. Products added to the
+   * product set and products removed from the product set after this time are
+   * not reflected in the current results.
    * 
* * .google.protobuf.Timestamp index_time = 2; @@ -96,8 +41,9 @@ public interface ProductSearchResultsOrBuilder * * *
-   * Timestamp of the index which provided these results. Changes made after
-   * this time are not reflected in the current results.
+   * Timestamp of the index which provided these results. Products added to the
+   * product set and products removed from the product set after this time are
+   * not reflected in the current results.
    * 
* * .google.protobuf.Timestamp index_time = 2; @@ -109,8 +55,9 @@ public interface ProductSearchResultsOrBuilder * * *
-   * Timestamp of the index which provided these results. Changes made after
-   * this time are not reflected in the current results.
+   * Timestamp of the index which provided these results. Products added to the
+   * product set and products removed from the product set after this time are
+   * not reflected in the current results.
    * 
* * .google.protobuf.Timestamp index_time = 2; @@ -121,112 +68,133 @@ public interface ProductSearchResultsOrBuilder * * *
-   * List of detected products.
+   * List of results, one for each product match.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; */ - java.util.List - getProductsList(); + java.util.List getResultsList(); /** * * *
-   * List of detected products.
+   * List of results, one for each product match.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; */ - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo getProducts(int index); + com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result getResults(int index); /** * * *
-   * List of detected products.
+   * List of results, one for each product match.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; */ - int getProductsCount(); + int getResultsCount(); /** * * *
-   * List of detected products.
+   * List of results, one for each product match.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; */ - java.util.List< - ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfoOrBuilder> - getProductsOrBuilderList(); + java.util.List + getResultsOrBuilderList(); /** * * *
-   * List of detected products.
+   * List of results, one for each product match.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfo products = 3; - * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; */ - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ProductInfoOrBuilder getProductsOrBuilder( + com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder getResultsOrBuilder( int index); /** * * *
-   * List of results, one for each product match.
+   * List of results grouped by products detected in the query image. Each entry
+   * corresponds to one bounding polygon in the query image, and contains the
+   * matching products specific to that region. There may be duplicate product
+   * matches in the union of all the per-product results.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * */ - java.util.List getResultsList(); + java.util.List + getProductGroupedResultsList(); /** * * *
-   * List of results, one for each product match.
+   * List of results grouped by products detected in the query image. Each entry
+   * corresponds to one bounding polygon in the query image, and contains the
+   * matching products specific to that region. There may be duplicate product
+   * matches in the union of all the per-product results.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * */ - com.google.cloud.vision.v1p3beta1.ProductSearchResults.Result getResults(int index); + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult getProductGroupedResults( + int index); /** * * *
-   * List of results, one for each product match.
+   * List of results grouped by products detected in the query image. Each entry
+   * corresponds to one bounding polygon in the query image, and contains the
+   * matching products specific to that region. There may be duplicate product
+   * matches in the union of all the per-product results.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * */ - int getResultsCount(); + int getProductGroupedResultsCount(); /** * * *
-   * List of results, one for each product match.
+   * List of results grouped by products detected in the query image. Each entry
+   * corresponds to one bounding polygon in the query image, and contains the
+   * matching products specific to that region. There may be duplicate product
+   * matches in the union of all the per-product results.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * */ - java.util.List - getResultsOrBuilderList(); + java.util.List< + ? extends com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResultOrBuilder> + getProductGroupedResultsOrBuilderList(); /** * * *
-   * List of results, one for each product match.
+   * List of results grouped by products detected in the query image. Each entry
+   * corresponds to one bounding polygon in the query image, and contains the
+   * matching products specific to that region. There may be duplicate product
+   * matches in the union of all the per-product results.
    * 
* - * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.Result results = 5; + * + * repeated .google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResult product_grouped_results = 6; + * */ - com.google.cloud.vision.v1p3beta1.ProductSearchResults.ResultOrBuilder getResultsOrBuilder( - int index); + com.google.cloud.vision.v1p3beta1.ProductSearchResults.GroupedResultOrBuilder + getProductGroupedResultsOrBuilder(int index); } diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchResultsView.java b/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchResultsView.java deleted file mode 100644 index ab57fea60..000000000 --- a/proto-google-cloud-vision-v1p3beta1/src/main/java/com/google/cloud/vision/v1p3beta1/ProductSearchResultsView.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/vision/v1p3beta1/product_search.proto - -package com.google.cloud.vision.v1p3beta1; - -/** - * - * - *
- * Specifies the fields to include in product search results.
- * 
- * - * Protobuf enum {@code google.cloud.vision.v1p3beta1.ProductSearchResultsView} - */ -public enum ProductSearchResultsView implements com.google.protobuf.ProtocolMessageEnum { - /** - * - * - *
-   * Product search results contain only `product_category` and `product_id`.
-   * Default value.
-   * 
- * - * BASIC = 0; - */ - BASIC(0), - /** - * - * - *
-   * Product search results contain `product_category`, `product_id`,
-   * `image_uri`, and `score`.
-   * 
- * - * FULL = 1; - */ - FULL(1), - UNRECOGNIZED(-1), - ; - - /** - * - * - *
-   * Product search results contain only `product_category` and `product_id`.
-   * Default value.
-   * 
- * - * BASIC = 0; - */ - public static final int BASIC_VALUE = 0; - /** - * - * - *
-   * Product search results contain `product_category`, `product_id`,
-   * `image_uri`, and `score`.
-   * 
- * - * FULL = 1; - */ - public static final int FULL_VALUE = 1; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static ProductSearchResultsView valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static ProductSearchResultsView forNumber(int value) { - switch (value) { - case 0: - return BASIC; - case 1: - return FULL; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - - private static final com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public ProductSearchResultsView findValueByNumber(int number) { - return ProductSearchResultsView.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return com.google.cloud.vision.v1p3beta1.ProductSearchProto.getDescriptor() - .getEnumTypes() - .get(1); - } - - private static final ProductSearchResultsView[] VALUES = values(); - - public static ProductSearchResultsView valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private ProductSearchResultsView(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:google.cloud.vision.v1p3beta1.ProductSearchResultsView) -} diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/geometry.proto b/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/geometry.proto index 28b768eaa..c2c524fb5 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/geometry.proto +++ b/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/geometry.proto @@ -1,4 +1,4 @@ -// Copyright 2018 Google Inc. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,13 +16,12 @@ syntax = "proto3"; package google.cloud.vision.v1p3beta1; -import "google/api/annotations.proto"; - option cc_enable_arenas = true; option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; option java_multiple_files = true; option java_outer_classname = "GeometryProto"; option java_package = "com.google.cloud.vision.v1p3beta1"; +option objc_class_prefix = "GCVN"; // A vertex represents a 2D point in the image. // NOTE: the vertex coordinates are in the same scale as the original image. @@ -54,12 +53,6 @@ message BoundingPoly { repeated NormalizedVertex normalized_vertices = 2; } -// A normalized bounding polygon around a portion of an image. -message NormalizedBoundingPoly { - // Normalized vertices of the bounding polygon. - repeated NormalizedVertex vertices = 1; -} - // A 3D position in the image, used primarily for Face detection landmarks. // A valid Position must have both x and y coordinates. // The position coordinates are in the same scale as the original image. diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/image_annotator.proto b/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/image_annotator.proto index c865ff53d..5f2111784 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/image_annotator.proto +++ b/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/image_annotator.proto @@ -677,7 +677,7 @@ message AnnotateFileResponse { // Multiple image annotation requests are batched into a single service call. message BatchAnnotateImagesRequest { // Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1; + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; } // Response to a batch image annotation request. diff --git a/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/product_search.proto b/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/product_search.proto index 6dde477c3..86ea1a064 100644 --- a/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/product_search.proto +++ b/proto-google-cloud-vision-v1p3beta1/src/main/proto/google/cloud/vision/v1p3beta1/product_search.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,13 +11,11 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; package google.cloud.vision.v1p3beta1; -import "google/api/annotations.proto"; import "google/api/resource.proto"; import "google/cloud/vision/v1p3beta1/geometry.proto"; import "google/cloud/vision/v1p3beta1/product_search_service.proto"; @@ -28,41 +26,15 @@ option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta option java_multiple_files = true; option java_outer_classname = "ProductSearchProto"; option java_package = "com.google.cloud.vision.v1p3beta1"; +option objc_class_prefix = "GCVN"; // Parameters for a product search request. message ProductSearchParams { - // The resource name of the catalog to search. - // - // Format is: `productSearch/catalogs/CATALOG_NAME`. - string catalog_name = 1; - - // The category to search in. - // Optional. It is inferred by the system if it is not specified. - // [Deprecated] Use `product_category`. - ProductSearchCategory category = 2; - - // The product category to search in. - // Optional. It is inferred by the system if it is not specified. - // Supported values are `bag`, `shoe`, `sunglasses`, `dress`, `outerwear`, - // `skirt`, `top`, `shorts`, and `pants`. - string product_category = 5; - - // The bounding polygon around the area of interest in the image. - // Optional. If it is not specified, system discretion will be applied. - // [Deprecated] Use `bounding_poly`. - NormalizedBoundingPoly normalized_bounding_poly = 3; - // The bounding polygon around the area of interest in the image. - // Optional. If it is not specified, system discretion will be applied. + // If it is not specified, system discretion will be applied. BoundingPoly bounding_poly = 9; - // Specifies the verbosity of the product search results. - // Optional. Defaults to `BASIC`. - ProductSearchResultsView view = 4; - - // The resource name of a - // [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for - // similar images. + // The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images. // // Format is: // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. @@ -71,40 +43,27 @@ message ProductSearchParams { }]; // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods" or "apparel" should be - // specified. + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. repeated string product_categories = 7; // The filtering expression. This can be used to restrict search results based // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. // // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but not "(color = red OR brand = Google)" or "color: red". + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. string filter = 8; } // Results for a product search request. message ProductSearchResults { - // Information about a product. - message ProductInfo { - // Product ID. - string product_id = 1; - - // The URI of the image which matched the query image. - // - // This field is returned only if `view` is set to `FULL` in - // the request. - string image_uri = 2; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - // - // This field is returned only if `view` is set to `FULL` in - // the request. - float score = 3; - } - // Information about a product. message Result { // The Product. @@ -112,9 +71,6 @@ message ProductSearchResults { // A confidence level on the match, ranging from 0 (no confidence) to // 1 (full confidence). - // - // This field is returned only if `view` is set to `FULL` in - // the request. float score = 2; // The resource name of the image from the product that is the closest match @@ -122,45 +78,47 @@ message ProductSearchResults { string image = 3; } - // Product category. - // [Deprecated] Use `product_category`. - ProductSearchCategory category = 1; + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; - // Product category. - // Supported values are `bag` and `shoe`. - // [Deprecated] `product_category` is provided in each Product. - string product_category = 4; + // The BCP-47 language code, such as "en-US" or "sr-Latn". For more + // information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; - // Timestamp of the index which provided these results. Changes made after - // this time are not reflected in the current results. - google.protobuf.Timestamp index_time = 2; + // Object name, expressed in its `language_code` language. + string name = 3; - // List of detected products. - repeated ProductInfo products = 3; + // Score of the result. Range [0, 1]. + float score = 4; + } - // List of results, one for each product match. - repeated Result results = 5; -} + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; -// Supported product search categories. -enum ProductSearchCategory { - // Default value used when a category is not specified. - PRODUCT_SEARCH_CATEGORY_UNSPECIFIED = 0; + // List of results, one for each product match. + repeated Result results = 2; - // Shoes category. - SHOES = 1; + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } - // Bags category. - BAGS = 2; -} + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; -// Specifies the fields to include in product search results. -enum ProductSearchResultsView { - // Product search results contain only `product_category` and `product_id`. - // Default value. - BASIC = 0; + // List of results, one for each product match. + repeated Result results = 5; - // Product search results contain `product_category`, `product_id`, - // `image_uri`, and `score`. - FULL = 1; + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; } diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java new file mode 100644 index 000000000..a4aef8ae7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_asyncbatchannotatefiles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateFiles(); + } + + public static void asyncAsyncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + ApiFuture future = + imageAnnotatorClient.asyncBatchAnnotateFilesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END vision_v1_generated_imageannotatorclient_asyncbatchannotatefiles_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java new file mode 100644 index 000000000..52d1aacd6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_asyncbatchannotatefiles_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.vision.v1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import com.google.cloud.vision.v1.OperationMetadata; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateFilesLRO { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateFilesLRO(); + } + + public static void asyncAsyncBatchAnnotateFilesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + OperationFuture future = + imageAnnotatorClient.asyncBatchAnnotateFilesOperationCallable().futureCall(request); + // Do something. + AsyncBatchAnnotateFilesResponse response = future.get(); + } + } +} +// [END vision_v1_generated_imageannotatorclient_asyncbatchannotatefiles_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java new file mode 100644 index 000000000..de69fa9eb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_asyncbatchannotatefiles_sync] +import com.google.cloud.vision.v1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class SyncAsyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateFiles(); + } + + public static void syncAsyncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + AsyncBatchAnnotateFilesResponse response = + imageAnnotatorClient.asyncBatchAnnotateFilesAsync(request).get(); + } + } +} +// [END vision_v1_generated_imageannotatorclient_asyncbatchannotatefiles_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java new file mode 100644 index 000000000..fa6ebccea --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_imageannotatorclient_asyncbatchannotatefiles_listasyncannotatefilerequest_sync] +import com.google.cloud.vision.v1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateFilesListasyncannotatefilerequest(); + } + + public static void syncAsyncBatchAnnotateFilesListasyncannotatefilerequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + AsyncBatchAnnotateFilesResponse response = + imageAnnotatorClient.asyncBatchAnnotateFilesAsync(requests).get(); + } + } +} +// [END +// vision_v1_generated_imageannotatorclient_asyncbatchannotatefiles_listasyncannotatefilerequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImages.java new file mode 100644 index 000000000..a45c8455c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImages.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_asyncbatchannotateimages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.AnnotateImageRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import com.google.cloud.vision.v1.OutputConfig; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateImages(); + } + + public static void asyncAsyncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateImagesRequest request = + AsyncBatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .setParent("parent-995424086") + .build(); + ApiFuture future = + imageAnnotatorClient.asyncBatchAnnotateImagesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END vision_v1_generated_imageannotatorclient_asyncbatchannotateimages_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImagesLRO.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImagesLRO.java new file mode 100644 index 000000000..9511ad288 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImagesLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_asyncbatchannotateimages_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.vision.v1.AnnotateImageRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import com.google.cloud.vision.v1.OperationMetadata; +import com.google.cloud.vision.v1.OutputConfig; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateImagesLRO { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateImagesLRO(); + } + + public static void asyncAsyncBatchAnnotateImagesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateImagesRequest request = + AsyncBatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .setParent("parent-995424086") + .build(); + OperationFuture future = + imageAnnotatorClient.asyncBatchAnnotateImagesOperationCallable().futureCall(request); + // Do something. + AsyncBatchAnnotateImagesResponse response = future.get(); + } + } +} +// [END vision_v1_generated_imageannotatorclient_asyncbatchannotateimages_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImages.java new file mode 100644 index 000000000..7c049a765 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImages.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_asyncbatchannotateimages_sync] +import com.google.cloud.vision.v1.AnnotateImageRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import com.google.cloud.vision.v1.OutputConfig; +import java.util.ArrayList; + +public class SyncAsyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateImages(); + } + + public static void syncAsyncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateImagesRequest request = + AsyncBatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .setParent("parent-995424086") + .build(); + AsyncBatchAnnotateImagesResponse response = + imageAnnotatorClient.asyncBatchAnnotateImagesAsync(request).get(); + } + } +} +// [END vision_v1_generated_imageannotatorclient_asyncbatchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig.java new file mode 100644 index 000000000..35bbea966 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_imageannotatorclient_asyncbatchannotateimages_listannotateimagerequestoutputconfig_sync] +import com.google.cloud.vision.v1.AnnotateImageRequest; +import com.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import com.google.cloud.vision.v1.OutputConfig; +import java.util.ArrayList; +import java.util.List; + +public class SyncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig(); + } + + public static void syncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + AsyncBatchAnnotateImagesResponse response = + imageAnnotatorClient.asyncBatchAnnotateImagesAsync(requests, outputConfig).get(); + } + } +} +// [END +// vision_v1_generated_imageannotatorclient_asyncbatchannotateimages_listannotateimagerequestoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotatefiles/AsyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotatefiles/AsyncBatchAnnotateFiles.java new file mode 100644 index 000000000..df52d7f45 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotatefiles/AsyncBatchAnnotateFiles.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_batchannotatefiles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.AnnotateFileRequest; +import com.google.cloud.vision.v1.BatchAnnotateFilesRequest; +import com.google.cloud.vision.v1.BatchAnnotateFilesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class AsyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + asyncBatchAnnotateFiles(); + } + + public static void asyncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateFilesRequest request = + BatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + ApiFuture future = + imageAnnotatorClient.batchAnnotateFilesCallable().futureCall(request); + // Do something. + BatchAnnotateFilesResponse response = future.get(); + } + } +} +// [END vision_v1_generated_imageannotatorclient_batchannotatefiles_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFiles.java new file mode 100644 index 000000000..9a0e8719f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFiles.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_batchannotatefiles_sync] +import com.google.cloud.vision.v1.AnnotateFileRequest; +import com.google.cloud.vision.v1.BatchAnnotateFilesRequest; +import com.google.cloud.vision.v1.BatchAnnotateFilesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class SyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateFiles(); + } + + public static void syncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateFilesRequest request = + BatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + BatchAnnotateFilesResponse response = imageAnnotatorClient.batchAnnotateFiles(request); + } + } +} +// [END vision_v1_generated_imageannotatorclient_batchannotatefiles_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFilesListannotatefilerequest.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFilesListannotatefilerequest.java new file mode 100644 index 000000000..9348eb2d0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFilesListannotatefilerequest.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_batchannotatefiles_listannotatefilerequest_sync] +import com.google.cloud.vision.v1.AnnotateFileRequest; +import com.google.cloud.vision.v1.BatchAnnotateFilesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchAnnotateFilesListannotatefilerequest { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateFilesListannotatefilerequest(); + } + + public static void syncBatchAnnotateFilesListannotatefilerequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + BatchAnnotateFilesResponse response = imageAnnotatorClient.batchAnnotateFiles(requests); + } + } +} +// [END vision_v1_generated_imageannotatorclient_batchannotatefiles_listannotatefilerequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java new file mode 100644 index 000000000..8978b510d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_batchannotateimages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.AnnotateImageRequest; +import com.google.cloud.vision.v1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class AsyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + asyncBatchAnnotateImages(); + } + + public static void asyncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateImagesRequest request = + BatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + ApiFuture future = + imageAnnotatorClient.batchAnnotateImagesCallable().futureCall(request); + // Do something. + BatchAnnotateImagesResponse response = future.get(); + } + } +} +// [END vision_v1_generated_imageannotatorclient_batchannotateimages_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..293db9dd5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_batchannotateimages_sync] +import com.google.cloud.vision.v1.AnnotateImageRequest; +import com.google.cloud.vision.v1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateImagesRequest request = + BatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setParent("parent-995424086") + .build(); + BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(request); + } + } +} +// [END vision_v1_generated_imageannotatorclient_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java new file mode 100644 index 000000000..2eb2706cf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_imageannotatorclient_batchannotateimages_listannotateimagerequest_sync] +import com.google.cloud.vision.v1.AnnotateImageRequest; +import com.google.cloud.vision.v1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchAnnotateImagesListannotateimagerequest { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImagesListannotateimagerequest(); + } + + public static void syncBatchAnnotateImagesListannotateimagerequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(requests); + } + } +} +// [END vision_v1_generated_imageannotatorclient_batchannotateimages_listannotateimagerequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..a31661de4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import com.google.cloud.vision.v1.ImageAnnotatorSettings; +import com.google.cloud.vision.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1_generated_imageannotatorclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..5a455ad1f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_create_setcredentialsprovider1_sync] +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import com.google.cloud.vision.v1.ImageAnnotatorSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder() + .setTransportChannelProvider( + ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1_generated_imageannotatorclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..e62f89156 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorclient_create_setendpoint_sync] +import com.google.cloud.vision.v1.ImageAnnotatorClient; +import com.google.cloud.vision.v1.ImageAnnotatorSettings; +import com.google.cloud.vision.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder().setEndpoint(myEndpoint).build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1_generated_imageannotatorclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..21c2183f4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_imageannotatorsettings_batchannotateimages_sync] +import com.google.cloud.vision.v1.ImageAnnotatorSettings; +import java.time.Duration; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings.Builder imageAnnotatorSettingsBuilder = + ImageAnnotatorSettings.newBuilder(); + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .setRetrySettings( + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageAnnotatorSettings imageAnnotatorSettings = imageAnnotatorSettingsBuilder.build(); + } +} +// [END vision_v1_generated_imageannotatorsettings_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/AsyncAddProductToProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/AsyncAddProductToProductSet.java new file mode 100644 index 000000000..512c59685 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/AsyncAddProductToProductSet.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_addproducttoproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.AddProductToProductSetRequest; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; +import com.google.protobuf.Empty; + +public class AsyncAddProductToProductSet { + + public static void main(String[] args) throws Exception { + asyncAddProductToProductSet(); + } + + public static void asyncAddProductToProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + AddProductToProductSetRequest request = + AddProductToProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = + productSearchClient.addProductToProductSetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_addproducttoproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSet.java new file mode 100644 index 000000000..2d1219663 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSet.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_addproducttoproductset_sync] +import com.google.cloud.vision.v1.AddProductToProductSetRequest; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncAddProductToProductSet { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSet(); + } + + public static void syncAddProductToProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + AddProductToProductSetRequest request = + AddProductToProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + productSearchClient.addProductToProductSet(request); + } + } +} +// [END vision_v1_generated_productsearchclient_addproducttoproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameProductname.java new file mode 100644 index 000000000..46bc25494 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameProductname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_productsearchclient_addproducttoproductset_productsetnameproductname_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncAddProductToProductSetProductsetnameProductname { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetProductsetnameProductname(); + } + + public static void syncAddProductToProductSetProductsetnameProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END +// vision_v1_generated_productsearchclient_addproducttoproductset_productsetnameproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameString.java new file mode 100644 index 000000000..394790781 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_addproducttoproductset_productsetnamestring_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncAddProductToProductSetProductsetnameString { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetProductsetnameString(); + } + + public static void syncAddProductToProductSetProductsetnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END vision_v1_generated_productsearchclient_addproducttoproductset_productsetnamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringProductname.java new file mode 100644 index 000000000..cb719705c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringProductname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_addproducttoproductset_stringproductname_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncAddProductToProductSetStringProductname { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetStringProductname(); + } + + public static void syncAddProductToProductSetStringProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END vision_v1_generated_productsearchclient_addproducttoproductset_stringproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringString.java new file mode 100644 index 000000000..f504be803 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_addproducttoproductset_stringstring_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncAddProductToProductSetStringString { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetStringString(); + } + + public static void syncAddProductToProductSetStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END vision_v1_generated_productsearchclient_addproducttoproductset_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..8c58a07b8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSearchSettings; +import com.google.cloud.vision.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings productSearchSettings = + ProductSearchSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); + } +} +// [END vision_v1_generated_productsearchclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..dfc5e5475 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_create_setcredentialsprovider1_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSearchSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings productSearchSettings = + ProductSearchSettings.newBuilder() + .setTransportChannelProvider( + ProductSearchSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); + } +} +// [END vision_v1_generated_productsearchclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..b92eefe90 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_create_setendpoint_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSearchSettings; +import com.google.cloud.vision.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings productSearchSettings = + ProductSearchSettings.newBuilder().setEndpoint(myEndpoint).build(); + ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); + } +} +// [END vision_v1_generated_productsearchclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/AsyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/AsyncCreateProduct.java new file mode 100644 index 000000000..67d691713 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/AsyncCreateProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_createproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.CreateProductRequest; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class AsyncCreateProduct { + + public static void main(String[] args) throws Exception { + asyncCreateProduct(); + } + + public static void asyncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + ApiFuture future = productSearchClient.createProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_createproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000..5687fb2e5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/SyncCreateProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_createproduct_sync] +import com.google.cloud.vision.v1.CreateProductRequest; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + Product response = productSearchClient.createProduct(request); + } + } +} +// [END vision_v1_generated_productsearchclient_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/SyncCreateProductLocationnameProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/SyncCreateProductLocationnameProductString.java new file mode 100644 index 000000000..d94cf7283 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/SyncCreateProductLocationnameProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_createproduct_locationnameproductstring_sync] +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncCreateProductLocationnameProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductLocationnameProductString(); + } + + public static void syncCreateProductLocationnameProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productSearchClient.createProduct(parent, product, productId); + } + } +} +// [END vision_v1_generated_productsearchclient_createproduct_locationnameproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/SyncCreateProductStringProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/SyncCreateProductStringProductString.java new file mode 100644 index 000000000..e7ea74db2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproduct/SyncCreateProductStringProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_createproduct_stringproductstring_sync] +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncCreateProductStringProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductStringProductString(); + } + + public static void syncCreateProductStringProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productSearchClient.createProduct(parent, product, productId); + } + } +} +// [END vision_v1_generated_productsearchclient_createproduct_stringproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/AsyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/AsyncCreateProductSet.java new file mode 100644 index 000000000..cf7cb3657 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/AsyncCreateProductSet.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_createproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.CreateProductSetRequest; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; + +public class AsyncCreateProductSet { + + public static void main(String[] args) throws Exception { + asyncCreateProductSet(); + } + + public static void asyncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductSetRequest request = + CreateProductSetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProductSet(ProductSet.newBuilder().build()) + .setProductSetId("productSetId1003042158") + .build(); + ApiFuture future = + productSearchClient.createProductSetCallable().futureCall(request); + // Do something. + ProductSet response = future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_createproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/SyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/SyncCreateProductSet.java new file mode 100644 index 000000000..3820e6eb0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/SyncCreateProductSet.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_createproductset_sync] +import com.google.cloud.vision.v1.CreateProductSetRequest; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; + +public class SyncCreateProductSet { + + public static void main(String[] args) throws Exception { + syncCreateProductSet(); + } + + public static void syncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductSetRequest request = + CreateProductSetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProductSet(ProductSet.newBuilder().build()) + .setProductSetId("productSetId1003042158") + .build(); + ProductSet response = productSearchClient.createProductSet(request); + } + } +} +// [END vision_v1_generated_productsearchclient_createproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/SyncCreateProductSetLocationnameProductsetString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/SyncCreateProductSetLocationnameProductsetString.java new file mode 100644 index 000000000..430d92237 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/SyncCreateProductSetLocationnameProductsetString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_productsearchclient_createproductset_locationnameproductsetstring_sync] +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; + +public class SyncCreateProductSetLocationnameProductsetString { + + public static void main(String[] args) throws Exception { + syncCreateProductSetLocationnameProductsetString(); + } + + public static void syncCreateProductSetLocationnameProductsetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + ProductSet response = productSearchClient.createProductSet(parent, productSet, productSetId); + } + } +} +// [END vision_v1_generated_productsearchclient_createproductset_locationnameproductsetstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/SyncCreateProductSetStringProductsetString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/SyncCreateProductSetStringProductsetString.java new file mode 100644 index 000000000..8562337d6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createproductset/SyncCreateProductSetStringProductsetString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_createproductset_stringproductsetstring_sync] +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; + +public class SyncCreateProductSetStringProductsetString { + + public static void main(String[] args) throws Exception { + syncCreateProductSetStringProductsetString(); + } + + public static void syncCreateProductSetStringProductsetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + ProductSet response = productSearchClient.createProductSet(parent, productSet, productSetId); + } + } +} +// [END vision_v1_generated_productsearchclient_createproductset_stringproductsetstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/AsyncCreateReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/AsyncCreateReferenceImage.java new file mode 100644 index 000000000..a46507f38 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/AsyncCreateReferenceImage.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_createreferenceimage_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.CreateReferenceImageRequest; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; + +public class AsyncCreateReferenceImage { + + public static void main(String[] args) throws Exception { + asyncCreateReferenceImage(); + } + + public static void asyncCreateReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateReferenceImageRequest request = + CreateReferenceImageRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setReferenceImage(ReferenceImage.newBuilder().build()) + .setReferenceImageId("referenceImageId1224107531") + .build(); + ApiFuture future = + productSearchClient.createReferenceImageCallable().futureCall(request); + // Do something. + ReferenceImage response = future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_createreferenceimage_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/SyncCreateReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/SyncCreateReferenceImage.java new file mode 100644 index 000000000..e00d8582d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/SyncCreateReferenceImage.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_createreferenceimage_sync] +import com.google.cloud.vision.v1.CreateReferenceImageRequest; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; + +public class SyncCreateReferenceImage { + + public static void main(String[] args) throws Exception { + syncCreateReferenceImage(); + } + + public static void syncCreateReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateReferenceImageRequest request = + CreateReferenceImageRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setReferenceImage(ReferenceImage.newBuilder().build()) + .setReferenceImageId("referenceImageId1224107531") + .build(); + ReferenceImage response = productSearchClient.createReferenceImage(request); + } + } +} +// [END vision_v1_generated_productsearchclient_createreferenceimage_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/SyncCreateReferenceImageProductnameReferenceimageString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/SyncCreateReferenceImageProductnameReferenceimageString.java new file mode 100644 index 000000000..47a5e1e30 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/SyncCreateReferenceImageProductnameReferenceimageString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_productsearchclient_createreferenceimage_productnamereferenceimagestring_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; + +public class SyncCreateReferenceImageProductnameReferenceimageString { + + public static void main(String[] args) throws Exception { + syncCreateReferenceImageProductnameReferenceimageString(); + } + + public static void syncCreateReferenceImageProductnameReferenceimageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + ReferenceImage response = + productSearchClient.createReferenceImage(parent, referenceImage, referenceImageId); + } + } +} +// [END +// vision_v1_generated_productsearchclient_createreferenceimage_productnamereferenceimagestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/SyncCreateReferenceImageStringReferenceimageString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/SyncCreateReferenceImageStringReferenceimageString.java new file mode 100644 index 000000000..29441ca4c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/createreferenceimage/SyncCreateReferenceImageStringReferenceimageString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_productsearchclient_createreferenceimage_stringreferenceimagestring_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; + +public class SyncCreateReferenceImageStringReferenceimageString { + + public static void main(String[] args) throws Exception { + syncCreateReferenceImageStringReferenceimageString(); + } + + public static void syncCreateReferenceImageStringReferenceimageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + ReferenceImage response = + productSearchClient.createReferenceImage(parent, referenceImage, referenceImageId); + } + } +} +// [END +// vision_v1_generated_productsearchclient_createreferenceimage_stringreferenceimagestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/AsyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/AsyncDeleteProduct.java new file mode 100644 index 000000000..2d34960e9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/AsyncDeleteProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deleteproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.DeleteProductRequest; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteProduct { + + public static void main(String[] args) throws Exception { + asyncDeleteProduct(); + } + + public static void asyncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = productSearchClient.deleteProductCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_deleteproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/SyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/SyncDeleteProduct.java new file mode 100644 index 000000000..6b7b833f8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/SyncDeleteProduct.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deleteproduct_sync] +import com.google.cloud.vision.v1.DeleteProductRequest; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncDeleteProduct { + + public static void main(String[] args) throws Exception { + syncDeleteProduct(); + } + + public static void syncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + productSearchClient.deleteProduct(request); + } + } +} +// [END vision_v1_generated_productsearchclient_deleteproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/SyncDeleteProductProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/SyncDeleteProductProductname.java new file mode 100644 index 000000000..7b275f83c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/SyncDeleteProductProductname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deleteproduct_productname_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncDeleteProductProductname { + + public static void main(String[] args) throws Exception { + syncDeleteProductProductname(); + } + + public static void syncDeleteProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.deleteProduct(name); + } + } +} +// [END vision_v1_generated_productsearchclient_deleteproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/SyncDeleteProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/SyncDeleteProductString.java new file mode 100644 index 000000000..6fa96db52 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproduct/SyncDeleteProductString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deleteproduct_string_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncDeleteProductString { + + public static void main(String[] args) throws Exception { + syncDeleteProductString(); + } + + public static void syncDeleteProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.deleteProduct(name); + } + } +} +// [END vision_v1_generated_productsearchclient_deleteproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/AsyncDeleteProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/AsyncDeleteProductSet.java new file mode 100644 index 000000000..6e8c0d0a5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/AsyncDeleteProductSet.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deleteproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.DeleteProductSetRequest; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; +import com.google.protobuf.Empty; + +public class AsyncDeleteProductSet { + + public static void main(String[] args) throws Exception { + asyncDeleteProductSet(); + } + + public static void asyncDeleteProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductSetRequest request = + DeleteProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + ApiFuture future = productSearchClient.deleteProductSetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_deleteproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/SyncDeleteProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/SyncDeleteProductSet.java new file mode 100644 index 000000000..c52da465f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/SyncDeleteProductSet.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deleteproductset_sync] +import com.google.cloud.vision.v1.DeleteProductSetRequest; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncDeleteProductSet { + + public static void main(String[] args) throws Exception { + syncDeleteProductSet(); + } + + public static void syncDeleteProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductSetRequest request = + DeleteProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + productSearchClient.deleteProductSet(request); + } + } +} +// [END vision_v1_generated_productsearchclient_deleteproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/SyncDeleteProductSetProductsetname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/SyncDeleteProductSetProductsetname.java new file mode 100644 index 000000000..5868f9d07 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/SyncDeleteProductSetProductsetname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deleteproductset_productsetname_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncDeleteProductSetProductsetname { + + public static void main(String[] args) throws Exception { + syncDeleteProductSetProductsetname(); + } + + public static void syncDeleteProductSetProductsetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + productSearchClient.deleteProductSet(name); + } + } +} +// [END vision_v1_generated_productsearchclient_deleteproductset_productsetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/SyncDeleteProductSetString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/SyncDeleteProductSetString.java new file mode 100644 index 000000000..894d5847c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deleteproductset/SyncDeleteProductSetString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deleteproductset_string_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncDeleteProductSetString { + + public static void main(String[] args) throws Exception { + syncDeleteProductSetString(); + } + + public static void syncDeleteProductSetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + productSearchClient.deleteProductSet(name); + } + } +} +// [END vision_v1_generated_productsearchclient_deleteproductset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/AsyncDeleteReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/AsyncDeleteReferenceImage.java new file mode 100644 index 000000000..4fee52749 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/AsyncDeleteReferenceImage.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deletereferenceimage_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.DeleteReferenceImageRequest; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImageName; +import com.google.protobuf.Empty; + +public class AsyncDeleteReferenceImage { + + public static void main(String[] args) throws Exception { + asyncDeleteReferenceImage(); + } + + public static void asyncDeleteReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteReferenceImageRequest request = + DeleteReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + ApiFuture future = + productSearchClient.deleteReferenceImageCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_deletereferenceimage_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImage.java new file mode 100644 index 000000000..c7cab3e26 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImage.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deletereferenceimage_sync] +import com.google.cloud.vision.v1.DeleteReferenceImageRequest; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImageName; + +public class SyncDeleteReferenceImage { + + public static void main(String[] args) throws Exception { + syncDeleteReferenceImage(); + } + + public static void syncDeleteReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteReferenceImageRequest request = + DeleteReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + productSearchClient.deleteReferenceImage(request); + } + } +} +// [END vision_v1_generated_productsearchclient_deletereferenceimage_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageReferenceimagename.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageReferenceimagename.java new file mode 100644 index 000000000..33162818f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageReferenceimagename.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deletereferenceimage_referenceimagename_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImageName; + +public class SyncDeleteReferenceImageReferenceimagename { + + public static void main(String[] args) throws Exception { + syncDeleteReferenceImageReferenceimagename(); + } + + public static void syncDeleteReferenceImageReferenceimagename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + productSearchClient.deleteReferenceImage(name); + } + } +} +// [END vision_v1_generated_productsearchclient_deletereferenceimage_referenceimagename_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageString.java new file mode 100644 index 000000000..76c405299 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_deletereferenceimage_string_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImageName; + +public class SyncDeleteReferenceImageString { + + public static void main(String[] args) throws Exception { + syncDeleteReferenceImageString(); + } + + public static void syncDeleteReferenceImageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString(); + productSearchClient.deleteReferenceImage(name); + } + } +} +// [END vision_v1_generated_productsearchclient_deletereferenceimage_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/AsyncGetProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/AsyncGetProduct.java new file mode 100644 index 000000000..ee1a6875a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/AsyncGetProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.GetProductRequest; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class AsyncGetProduct { + + public static void main(String[] args) throws Exception { + asyncGetProduct(); + } + + public static void asyncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = productSearchClient.getProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_getproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/SyncGetProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/SyncGetProduct.java new file mode 100644 index 000000000..7233cf100 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/SyncGetProduct.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getproduct_sync] +import com.google.cloud.vision.v1.GetProductRequest; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncGetProduct { + + public static void main(String[] args) throws Exception { + syncGetProduct(); + } + + public static void syncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + Product response = productSearchClient.getProduct(request); + } + } +} +// [END vision_v1_generated_productsearchclient_getproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/SyncGetProductProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/SyncGetProductProductname.java new file mode 100644 index 000000000..0c5fad9de --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/SyncGetProductProductname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getproduct_productname_sync] +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncGetProductProductname { + + public static void main(String[] args) throws Exception { + syncGetProductProductname(); + } + + public static void syncGetProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + Product response = productSearchClient.getProduct(name); + } + } +} +// [END vision_v1_generated_productsearchclient_getproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/SyncGetProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/SyncGetProductString.java new file mode 100644 index 000000000..129cabcdc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproduct/SyncGetProductString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getproduct_string_sync] +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncGetProductString { + + public static void main(String[] args) throws Exception { + syncGetProductString(); + } + + public static void syncGetProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + Product response = productSearchClient.getProduct(name); + } + } +} +// [END vision_v1_generated_productsearchclient_getproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/AsyncGetProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/AsyncGetProductSet.java new file mode 100644 index 000000000..ef7ecb8db --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/AsyncGetProductSet.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.GetProductSetRequest; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; +import com.google.cloud.vision.v1.ProductSetName; + +public class AsyncGetProductSet { + + public static void main(String[] args) throws Exception { + asyncGetProductSet(); + } + + public static void asyncGetProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductSetRequest request = + GetProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + ApiFuture future = + productSearchClient.getProductSetCallable().futureCall(request); + // Do something. + ProductSet response = future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_getproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/SyncGetProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/SyncGetProductSet.java new file mode 100644 index 000000000..05794be71 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/SyncGetProductSet.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getproductset_sync] +import com.google.cloud.vision.v1.GetProductSetRequest; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncGetProductSet { + + public static void main(String[] args) throws Exception { + syncGetProductSet(); + } + + public static void syncGetProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductSetRequest request = + GetProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + ProductSet response = productSearchClient.getProductSet(request); + } + } +} +// [END vision_v1_generated_productsearchclient_getproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/SyncGetProductSetProductsetname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/SyncGetProductSetProductsetname.java new file mode 100644 index 000000000..f2454728e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/SyncGetProductSetProductsetname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getproductset_productsetname_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncGetProductSetProductsetname { + + public static void main(String[] args) throws Exception { + syncGetProductSetProductsetname(); + } + + public static void syncGetProductSetProductsetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductSet response = productSearchClient.getProductSet(name); + } + } +} +// [END vision_v1_generated_productsearchclient_getproductset_productsetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/SyncGetProductSetString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/SyncGetProductSetString.java new file mode 100644 index 000000000..908b3d5eb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getproductset/SyncGetProductSetString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getproductset_string_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncGetProductSetString { + + public static void main(String[] args) throws Exception { + syncGetProductSetString(); + } + + public static void syncGetProductSetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + ProductSet response = productSearchClient.getProductSet(name); + } + } +} +// [END vision_v1_generated_productsearchclient_getproductset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/AsyncGetReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/AsyncGetReferenceImage.java new file mode 100644 index 000000000..2b8e4d952 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/AsyncGetReferenceImage.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getreferenceimage_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.GetReferenceImageRequest; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; +import com.google.cloud.vision.v1.ReferenceImageName; + +public class AsyncGetReferenceImage { + + public static void main(String[] args) throws Exception { + asyncGetReferenceImage(); + } + + public static void asyncGetReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetReferenceImageRequest request = + GetReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + ApiFuture future = + productSearchClient.getReferenceImageCallable().futureCall(request); + // Do something. + ReferenceImage response = future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_getreferenceimage_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/SyncGetReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/SyncGetReferenceImage.java new file mode 100644 index 000000000..27ff47128 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/SyncGetReferenceImage.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getreferenceimage_sync] +import com.google.cloud.vision.v1.GetReferenceImageRequest; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; +import com.google.cloud.vision.v1.ReferenceImageName; + +public class SyncGetReferenceImage { + + public static void main(String[] args) throws Exception { + syncGetReferenceImage(); + } + + public static void syncGetReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetReferenceImageRequest request = + GetReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + ReferenceImage response = productSearchClient.getReferenceImage(request); + } + } +} +// [END vision_v1_generated_productsearchclient_getreferenceimage_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/SyncGetReferenceImageReferenceimagename.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/SyncGetReferenceImageReferenceimagename.java new file mode 100644 index 000000000..90845e0ad --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/SyncGetReferenceImageReferenceimagename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getreferenceimage_referenceimagename_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; +import com.google.cloud.vision.v1.ReferenceImageName; + +public class SyncGetReferenceImageReferenceimagename { + + public static void main(String[] args) throws Exception { + syncGetReferenceImageReferenceimagename(); + } + + public static void syncGetReferenceImageReferenceimagename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + ReferenceImage response = productSearchClient.getReferenceImage(name); + } + } +} +// [END vision_v1_generated_productsearchclient_getreferenceimage_referenceimagename_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/SyncGetReferenceImageString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/SyncGetReferenceImageString.java new file mode 100644 index 000000000..0d25acb0b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/getreferenceimage/SyncGetReferenceImageString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_getreferenceimage_string_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; +import com.google.cloud.vision.v1.ReferenceImageName; + +public class SyncGetReferenceImageString { + + public static void main(String[] args) throws Exception { + syncGetReferenceImageString(); + } + + public static void syncGetReferenceImageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString(); + ReferenceImage response = productSearchClient.getReferenceImage(name); + } + } +} +// [END vision_v1_generated_productsearchclient_getreferenceimage_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/AsyncImportProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/AsyncImportProductSets.java new file mode 100644 index 000000000..d3deb4993 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/AsyncImportProductSets.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_importproductsets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1.ImportProductSetsRequest; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.longrunning.Operation; + +public class AsyncImportProductSets { + + public static void main(String[] args) throws Exception { + asyncImportProductSets(); + } + + public static void asyncImportProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ImportProductSetsRequest request = + ImportProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) + .build(); + ApiFuture future = + productSearchClient.importProductSetsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_importproductsets_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/AsyncImportProductSetsLRO.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/AsyncImportProductSetsLRO.java new file mode 100644 index 000000000..8c831ec57 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/AsyncImportProductSetsLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_importproductsets_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.vision.v1.BatchOperationMetadata; +import com.google.cloud.vision.v1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1.ImportProductSetsRequest; +import com.google.cloud.vision.v1.ImportProductSetsResponse; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class AsyncImportProductSetsLRO { + + public static void main(String[] args) throws Exception { + asyncImportProductSetsLRO(); + } + + public static void asyncImportProductSetsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ImportProductSetsRequest request = + ImportProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) + .build(); + OperationFuture future = + productSearchClient.importProductSetsOperationCallable().futureCall(request); + // Do something. + ImportProductSetsResponse response = future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_importproductsets_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/SyncImportProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/SyncImportProductSets.java new file mode 100644 index 000000000..eb9fcafef --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/SyncImportProductSets.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_importproductsets_sync] +import com.google.cloud.vision.v1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1.ImportProductSetsRequest; +import com.google.cloud.vision.v1.ImportProductSetsResponse; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncImportProductSets { + + public static void main(String[] args) throws Exception { + syncImportProductSets(); + } + + public static void syncImportProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ImportProductSetsRequest request = + ImportProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) + .build(); + ImportProductSetsResponse response = + productSearchClient.importProductSetsAsync(request).get(); + } + } +} +// [END vision_v1_generated_productsearchclient_importproductsets_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/SyncImportProductSetsLocationnameImportproductsetsinputconfig.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/SyncImportProductSetsLocationnameImportproductsetsinputconfig.java new file mode 100644 index 000000000..6fa5967f1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/SyncImportProductSetsLocationnameImportproductsetsinputconfig.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_productsearchclient_importproductsets_locationnameimportproductsetsinputconfig_sync] +import com.google.cloud.vision.v1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1.ImportProductSetsResponse; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncImportProductSetsLocationnameImportproductsetsinputconfig { + + public static void main(String[] args) throws Exception { + syncImportProductSetsLocationnameImportproductsetsinputconfig(); + } + + public static void syncImportProductSetsLocationnameImportproductsetsinputconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + ImportProductSetsResponse response = + productSearchClient.importProductSetsAsync(parent, inputConfig).get(); + } + } +} +// [END +// vision_v1_generated_productsearchclient_importproductsets_locationnameimportproductsetsinputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/SyncImportProductSetsStringImportproductsetsinputconfig.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/SyncImportProductSetsStringImportproductsetsinputconfig.java new file mode 100644 index 000000000..c24df2aef --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/importproductsets/SyncImportProductSetsStringImportproductsetsinputconfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_productsearchclient_importproductsets_stringimportproductsetsinputconfig_sync] +import com.google.cloud.vision.v1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1.ImportProductSetsResponse; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncImportProductSetsStringImportproductsetsinputconfig { + + public static void main(String[] args) throws Exception { + syncImportProductSetsStringImportproductsetsinputconfig(); + } + + public static void syncImportProductSetsStringImportproductsetsinputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + ImportProductSetsResponse response = + productSearchClient.importProductSetsAsync(parent, inputConfig).get(); + } + } +} +// [END +// vision_v1_generated_productsearchclient_importproductsets_stringimportproductsetsinputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/AsyncListProducts.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/AsyncListProducts.java new file mode 100644 index 000000000..a4427b4f2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/AsyncListProducts.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.ListProductsRequest; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class AsyncListProducts { + + public static void main(String[] args) throws Exception { + asyncListProducts(); + } + + public static void asyncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listProductsPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/AsyncListProductsPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/AsyncListProductsPaged.java new file mode 100644 index 000000000..6eb2e35c8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/AsyncListProductsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproducts_paged_async] +import com.google.cloud.vision.v1.ListProductsRequest; +import com.google.cloud.vision.v1.ListProductsResponse; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.common.base.Strings; + +public class AsyncListProductsPaged { + + public static void main(String[] args) throws Exception { + asyncListProductsPaged(); + } + + public static void asyncListProductsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListProductsResponse response = productSearchClient.listProductsCallable().call(request); + for (Product element : response.getProductsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproducts_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/SyncListProducts.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/SyncListProducts.java new file mode 100644 index 000000000..45f89f53e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/SyncListProducts.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproducts_sync] +import com.google.cloud.vision.v1.ListProductsRequest; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncListProducts { + + public static void main(String[] args) throws Exception { + syncListProducts(); + } + + public static void syncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Product element : productSearchClient.listProducts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/SyncListProductsLocationname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/SyncListProductsLocationname.java new file mode 100644 index 000000000..b0392dc72 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/SyncListProductsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproducts_locationname_sync] +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncListProductsLocationname { + + public static void main(String[] args) throws Exception { + syncListProductsLocationname(); + } + + public static void syncListProductsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Product element : productSearchClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproducts_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/SyncListProductsString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/SyncListProductsString.java new file mode 100644 index 000000000..0b8b39de1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproducts/SyncListProductsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproducts_string_sync] +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncListProductsString { + + public static void main(String[] args) throws Exception { + syncListProductsString(); + } + + public static void syncListProductsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Product element : productSearchClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproducts_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/AsyncListProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/AsyncListProductSets.java new file mode 100644 index 000000000..70d845ba4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/AsyncListProductSets.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproductsets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.ListProductSetsRequest; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; + +public class AsyncListProductSets { + + public static void main(String[] args) throws Exception { + asyncListProductSets(); + } + + public static void asyncListProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductSetsRequest request = + ListProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listProductSetsPagedCallable().futureCall(request); + // Do something. + for (ProductSet element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproductsets_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/AsyncListProductSetsPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/AsyncListProductSetsPaged.java new file mode 100644 index 000000000..6dd46a906 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/AsyncListProductSetsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproductsets_paged_async] +import com.google.cloud.vision.v1.ListProductSetsRequest; +import com.google.cloud.vision.v1.ListProductSetsResponse; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; +import com.google.common.base.Strings; + +public class AsyncListProductSetsPaged { + + public static void main(String[] args) throws Exception { + asyncListProductSetsPaged(); + } + + public static void asyncListProductSetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductSetsRequest request = + ListProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListProductSetsResponse response = + productSearchClient.listProductSetsCallable().call(request); + for (ProductSet element : response.getProductSetsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproductsets_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/SyncListProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/SyncListProductSets.java new file mode 100644 index 000000000..088a0417c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/SyncListProductSets.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproductsets_sync] +import com.google.cloud.vision.v1.ListProductSetsRequest; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; + +public class SyncListProductSets { + + public static void main(String[] args) throws Exception { + syncListProductSets(); + } + + public static void syncListProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductSetsRequest request = + ListProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ProductSet element : productSearchClient.listProductSets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproductsets_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/SyncListProductSetsLocationname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/SyncListProductSetsLocationname.java new file mode 100644 index 000000000..c0157b379 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/SyncListProductSetsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproductsets_locationname_sync] +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; + +public class SyncListProductSetsLocationname { + + public static void main(String[] args) throws Exception { + syncListProductSetsLocationname(); + } + + public static void syncListProductSetsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (ProductSet element : productSearchClient.listProductSets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproductsets_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/SyncListProductSetsString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/SyncListProductSetsString.java new file mode 100644 index 000000000..829544fbf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsets/SyncListProductSetsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproductsets_string_sync] +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; + +public class SyncListProductSetsString { + + public static void main(String[] args) throws Exception { + syncListProductSetsString(); + } + + public static void syncListProductSetsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (ProductSet element : productSearchClient.listProductSets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproductsets_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSet.java new file mode 100644 index 000000000..efddae86a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSet.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproductsinproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class AsyncListProductsInProductSet { + + public static void main(String[] args) throws Exception { + asyncListProductsInProductSet(); + } + + public static void asyncListProductsInProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsInProductSetRequest request = + ListProductsInProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listProductsInProductSetPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproductsinproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSetPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSetPaged.java new file mode 100644 index 000000000..dffd39c0b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSetPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproductsinproductset_paged_async] +import com.google.cloud.vision.v1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1.ListProductsInProductSetResponse; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; +import com.google.common.base.Strings; + +public class AsyncListProductsInProductSetPaged { + + public static void main(String[] args) throws Exception { + asyncListProductsInProductSetPaged(); + } + + public static void asyncListProductsInProductSetPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsInProductSetRequest request = + ListProductsInProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListProductsInProductSetResponse response = + productSearchClient.listProductsInProductSetCallable().call(request); + for (Product element : response.getProductsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproductsinproductset_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/SyncListProductsInProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/SyncListProductsInProductSet.java new file mode 100644 index 000000000..8e16c45bc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/SyncListProductsInProductSet.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproductsinproductset_sync] +import com.google.cloud.vision.v1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncListProductsInProductSet { + + public static void main(String[] args) throws Exception { + syncListProductsInProductSet(); + } + + public static void syncListProductsInProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsInProductSetRequest request = + ListProductsInProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Product element : productSearchClient.listProductsInProductSet(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproductsinproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetProductsetname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetProductsetname.java new file mode 100644 index 000000000..1a612f1d7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetProductsetname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproductsinproductset_productsetname_sync] +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncListProductsInProductSetProductsetname { + + public static void main(String[] args) throws Exception { + syncListProductsInProductSetProductsetname(); + } + + public static void syncListProductsInProductSetProductsetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + for (Product element : productSearchClient.listProductsInProductSet(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproductsinproductset_productsetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetString.java new file mode 100644 index 000000000..2976a0d19 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listproductsinproductset_string_sync] +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncListProductsInProductSetString { + + public static void main(String[] args) throws Exception { + syncListProductsInProductSetString(); + } + + public static void syncListProductsInProductSetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + for (Product element : productSearchClient.listProductsInProductSet(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listproductsinproductset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/AsyncListReferenceImages.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/AsyncListReferenceImages.java new file mode 100644 index 000000000..38a18d098 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/AsyncListReferenceImages.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listreferenceimages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; + +public class AsyncListReferenceImages { + + public static void main(String[] args) throws Exception { + asyncListReferenceImages(); + } + + public static void asyncListReferenceImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListReferenceImagesRequest request = + ListReferenceImagesRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listReferenceImagesPagedCallable().futureCall(request); + // Do something. + for (ReferenceImage element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listreferenceimages_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/AsyncListReferenceImagesPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/AsyncListReferenceImagesPaged.java new file mode 100644 index 000000000..47ae86633 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/AsyncListReferenceImagesPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listreferenceimages_paged_async] +import com.google.cloud.vision.v1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1.ListReferenceImagesResponse; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; +import com.google.common.base.Strings; + +public class AsyncListReferenceImagesPaged { + + public static void main(String[] args) throws Exception { + asyncListReferenceImagesPaged(); + } + + public static void asyncListReferenceImagesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListReferenceImagesRequest request = + ListReferenceImagesRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListReferenceImagesResponse response = + productSearchClient.listReferenceImagesCallable().call(request); + for (ReferenceImage element : response.getReferenceImagesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1_generated_productsearchclient_listreferenceimages_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/SyncListReferenceImages.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/SyncListReferenceImages.java new file mode 100644 index 000000000..3ce717e67 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/SyncListReferenceImages.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listreferenceimages_sync] +import com.google.cloud.vision.v1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; + +public class SyncListReferenceImages { + + public static void main(String[] args) throws Exception { + syncListReferenceImages(); + } + + public static void syncListReferenceImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListReferenceImagesRequest request = + ListReferenceImagesRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ReferenceImage element : productSearchClient.listReferenceImages(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listreferenceimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/SyncListReferenceImagesProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/SyncListReferenceImagesProductname.java new file mode 100644 index 000000000..e16bc90d0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/SyncListReferenceImagesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listreferenceimages_productname_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; + +public class SyncListReferenceImagesProductname { + + public static void main(String[] args) throws Exception { + syncListReferenceImagesProductname(); + } + + public static void syncListReferenceImagesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + for (ReferenceImage element : productSearchClient.listReferenceImages(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listreferenceimages_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/SyncListReferenceImagesString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/SyncListReferenceImagesString.java new file mode 100644 index 000000000..81d179eb9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/listreferenceimages/SyncListReferenceImagesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_listreferenceimages_string_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ReferenceImage; + +public class SyncListReferenceImagesString { + + public static void main(String[] args) throws Exception { + syncListReferenceImagesString(); + } + + public static void syncListReferenceImagesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + for (ReferenceImage element : productSearchClient.listReferenceImages(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1_generated_productsearchclient_listreferenceimages_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/AsyncPurgeProducts.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/AsyncPurgeProducts.java new file mode 100644 index 000000000..7b37a7cd2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/AsyncPurgeProducts.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_purgeproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.PurgeProductsRequest; +import com.google.longrunning.Operation; + +public class AsyncPurgeProducts { + + public static void main(String[] args) throws Exception { + asyncPurgeProducts(); + } + + public static void asyncPurgeProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setForce(true) + .build(); + ApiFuture future = productSearchClient.purgeProductsCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_purgeproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/AsyncPurgeProductsLRO.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/AsyncPurgeProductsLRO.java new file mode 100644 index 000000000..169569b37 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/AsyncPurgeProductsLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_purgeproducts_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.vision.v1.BatchOperationMetadata; +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.PurgeProductsRequest; +import com.google.protobuf.Empty; + +public class AsyncPurgeProductsLRO { + + public static void main(String[] args) throws Exception { + asyncPurgeProductsLRO(); + } + + public static void asyncPurgeProductsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setForce(true) + .build(); + OperationFuture future = + productSearchClient.purgeProductsOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_purgeproducts_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/SyncPurgeProducts.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/SyncPurgeProducts.java new file mode 100644 index 000000000..44153e164 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/SyncPurgeProducts.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_purgeproducts_sync] +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.PurgeProductsRequest; + +public class SyncPurgeProducts { + + public static void main(String[] args) throws Exception { + syncPurgeProducts(); + } + + public static void syncPurgeProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setForce(true) + .build(); + productSearchClient.purgeProductsAsync(request).get(); + } + } +} +// [END vision_v1_generated_productsearchclient_purgeproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/SyncPurgeProductsLocationname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/SyncPurgeProductsLocationname.java new file mode 100644 index 000000000..84e592594 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/SyncPurgeProductsLocationname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_purgeproducts_locationname_sync] +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncPurgeProductsLocationname { + + public static void main(String[] args) throws Exception { + syncPurgeProductsLocationname(); + } + + public static void syncPurgeProductsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + productSearchClient.purgeProductsAsync(parent).get(); + } + } +} +// [END vision_v1_generated_productsearchclient_purgeproducts_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/SyncPurgeProductsString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/SyncPurgeProductsString.java new file mode 100644 index 000000000..91950a97d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/purgeproducts/SyncPurgeProductsString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_purgeproducts_string_sync] +import com.google.cloud.vision.v1.LocationName; +import com.google.cloud.vision.v1.ProductSearchClient; + +public class SyncPurgeProductsString { + + public static void main(String[] args) throws Exception { + syncPurgeProductsString(); + } + + public static void syncPurgeProductsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + productSearchClient.purgeProductsAsync(parent).get(); + } + } +} +// [END vision_v1_generated_productsearchclient_purgeproducts_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/AsyncRemoveProductFromProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/AsyncRemoveProductFromProductSet.java new file mode 100644 index 000000000..c4ea922f6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/AsyncRemoveProductFromProductSet.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_removeproductfromproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; +import com.google.cloud.vision.v1.RemoveProductFromProductSetRequest; +import com.google.protobuf.Empty; + +public class AsyncRemoveProductFromProductSet { + + public static void main(String[] args) throws Exception { + asyncRemoveProductFromProductSet(); + } + + public static void asyncRemoveProductFromProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + RemoveProductFromProductSetRequest request = + RemoveProductFromProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = + productSearchClient.removeProductFromProductSetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_removeproductfromproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSet.java new file mode 100644 index 000000000..cec0e738d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSet.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_removeproductfromproductset_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; +import com.google.cloud.vision.v1.RemoveProductFromProductSetRequest; + +public class SyncRemoveProductFromProductSet { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSet(); + } + + public static void syncRemoveProductFromProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + RemoveProductFromProductSetRequest request = + RemoveProductFromProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + productSearchClient.removeProductFromProductSet(request); + } + } +} +// [END vision_v1_generated_productsearchclient_removeproductfromproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameProductname.java new file mode 100644 index 000000000..24c3db840 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameProductname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_productsearchclient_removeproductfromproductset_productsetnameproductname_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncRemoveProductFromProductSetProductsetnameProductname { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetProductsetnameProductname(); + } + + public static void syncRemoveProductFromProductSetProductsetnameProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END +// vision_v1_generated_productsearchclient_removeproductfromproductset_productsetnameproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameString.java new file mode 100644 index 000000000..30c9d31af --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_productsearchclient_removeproductfromproductset_productsetnamestring_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncRemoveProductFromProductSetProductsetnameString { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetProductsetnameString(); + } + + public static void syncRemoveProductFromProductSetProductsetnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END +// vision_v1_generated_productsearchclient_removeproductfromproductset_productsetnamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringProductname.java new file mode 100644 index 000000000..e42100b70 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START +// vision_v1_generated_productsearchclient_removeproductfromproductset_stringproductname_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncRemoveProductFromProductSetStringProductname { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetStringProductname(); + } + + public static void syncRemoveProductFromProductSetStringProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END vision_v1_generated_productsearchclient_removeproductfromproductset_stringproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringString.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringString.java new file mode 100644 index 000000000..adcd731ef --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_removeproductfromproductset_stringstring_sync] +import com.google.cloud.vision.v1.ProductName; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSetName; + +public class SyncRemoveProductFromProductSetStringString { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetStringString(); + } + + public static void syncRemoveProductFromProductSetStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END vision_v1_generated_productsearchclient_removeproductfromproductset_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproduct/AsyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproduct/AsyncUpdateProduct.java new file mode 100644 index 000000000..d15be7863 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproduct/AsyncUpdateProduct.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_updateproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateProduct { + + public static void main(String[] args) throws Exception { + asyncUpdateProduct(); + } + + public static void asyncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = productSearchClient.updateProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_updateproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproduct/SyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproduct/SyncUpdateProduct.java new file mode 100644 index 000000000..560011b9f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproduct/SyncUpdateProduct.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_updateproduct_sync] +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProduct { + + public static void main(String[] args) throws Exception { + syncUpdateProduct(); + } + + public static void syncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Product response = productSearchClient.updateProduct(request); + } + } +} +// [END vision_v1_generated_productsearchclient_updateproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproduct/SyncUpdateProductProductFieldmask.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproduct/SyncUpdateProductProductFieldmask.java new file mode 100644 index 000000000..d3837c0ed --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproduct/SyncUpdateProductProductFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_updateproduct_productfieldmask_sync] +import com.google.cloud.vision.v1.Product; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductProductFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateProductProductFieldmask(); + } + + public static void syncUpdateProductProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + Product product = Product.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Product response = productSearchClient.updateProduct(product, updateMask); + } + } +} +// [END vision_v1_generated_productsearchclient_updateproduct_productfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproductset/AsyncUpdateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproductset/AsyncUpdateProductSet.java new file mode 100644 index 000000000..2188ed961 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproductset/AsyncUpdateProductSet.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_updateproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; +import com.google.cloud.vision.v1.UpdateProductSetRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateProductSet { + + public static void main(String[] args) throws Exception { + asyncUpdateProductSet(); + } + + public static void asyncUpdateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductSetRequest request = + UpdateProductSetRequest.newBuilder() + .setProductSet(ProductSet.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + productSearchClient.updateProductSetCallable().futureCall(request); + // Do something. + ProductSet response = future.get(); + } + } +} +// [END vision_v1_generated_productsearchclient_updateproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproductset/SyncUpdateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproductset/SyncUpdateProductSet.java new file mode 100644 index 000000000..880b87773 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproductset/SyncUpdateProductSet.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_updateproductset_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; +import com.google.cloud.vision.v1.UpdateProductSetRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductSet { + + public static void main(String[] args) throws Exception { + syncUpdateProductSet(); + } + + public static void syncUpdateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductSetRequest request = + UpdateProductSetRequest.newBuilder() + .setProductSet(ProductSet.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ProductSet response = productSearchClient.updateProductSet(request); + } + } +} +// [END vision_v1_generated_productsearchclient_updateproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproductset/SyncUpdateProductSetProductsetFieldmask.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproductset/SyncUpdateProductSetProductsetFieldmask.java new file mode 100644 index 000000000..9b037115d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchclient/updateproductset/SyncUpdateProductSetProductsetFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchclient_updateproductset_productsetfieldmask_sync] +import com.google.cloud.vision.v1.ProductSearchClient; +import com.google.cloud.vision.v1.ProductSet; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductSetProductsetFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateProductSetProductsetFieldmask(); + } + + public static void syncUpdateProductSetProductsetFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSet productSet = ProductSet.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ProductSet response = productSearchClient.updateProductSet(productSet, updateMask); + } + } +} +// [END vision_v1_generated_productsearchclient_updateproductset_productsetfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/productsearchsettings/createproductset/SyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchsettings/createproductset/SyncCreateProductSet.java new file mode 100644 index 000000000..2646a3176 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/productsearchsettings/createproductset/SyncCreateProductSet.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.samples; + +// [START vision_v1_generated_productsearchsettings_createproductset_sync] +import com.google.cloud.vision.v1.ProductSearchSettings; +import java.time.Duration; + +public class SyncCreateProductSet { + + public static void main(String[] args) throws Exception { + syncCreateProductSet(); + } + + public static void syncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings.Builder productSearchSettingsBuilder = ProductSearchSettings.newBuilder(); + productSearchSettingsBuilder + .createProductSetSettings() + .setRetrySettings( + productSearchSettingsBuilder + .createProductSetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductSearchSettings productSearchSettings = productSearchSettingsBuilder.build(); + } +} +// [END vision_v1_generated_productsearchsettings_createproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..11b42f80e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.stub.samples; + +// [START vision_v1_generated_imageannotatorstubsettings_batchannotateimages_sync] +import com.google.cloud.vision.v1.stub.ImageAnnotatorStubSettings; +import java.time.Duration; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorStubSettings.Builder imageAnnotatorSettingsBuilder = + ImageAnnotatorStubSettings.newBuilder(); + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .setRetrySettings( + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageAnnotatorStubSettings imageAnnotatorSettings = imageAnnotatorSettingsBuilder.build(); + } +} +// [END vision_v1_generated_imageannotatorstubsettings_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1/stub/productsearchstubsettings/createproductset/SyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1/stub/productsearchstubsettings/createproductset/SyncCreateProductSet.java new file mode 100644 index 000000000..962dd0776 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1/stub/productsearchstubsettings/createproductset/SyncCreateProductSet.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1.stub.samples; + +// [START vision_v1_generated_productsearchstubsettings_createproductset_sync] +import com.google.cloud.vision.v1.stub.ProductSearchStubSettings; +import java.time.Duration; + +public class SyncCreateProductSet { + + public static void main(String[] args) throws Exception { + syncCreateProductSet(); + } + + public static void syncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchStubSettings.Builder productSearchSettingsBuilder = + ProductSearchStubSettings.newBuilder(); + productSearchSettingsBuilder + .createProductSetSettings() + .setRetrySettings( + productSearchSettingsBuilder + .createProductSetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductSearchStubSettings productSearchSettings = productSearchSettingsBuilder.build(); + } +} +// [END vision_v1_generated_productsearchstubsettings_createproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java new file mode 100644 index 000000000..0b2d54aab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p1beta1.samples; + +// [START vision_v1p1beta1_generated_imageannotatorclient_batchannotateimages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p1beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p1beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class AsyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + asyncBatchAnnotateImages(); + } + + public static void asyncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateImagesRequest request = + BatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + ApiFuture future = + imageAnnotatorClient.batchAnnotateImagesCallable().futureCall(request); + // Do something. + BatchAnnotateImagesResponse response = future.get(); + } + } +} +// [END vision_v1p1beta1_generated_imageannotatorclient_batchannotateimages_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..c6d016245 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p1beta1.samples; + +// [START vision_v1p1beta1_generated_imageannotatorclient_batchannotateimages_sync] +import com.google.cloud.vision.v1p1beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p1beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateImagesRequest request = + BatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(request); + } + } +} +// [END vision_v1p1beta1_generated_imageannotatorclient_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java new file mode 100644 index 000000000..1776beecd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p1beta1.samples; + +// [START +// vision_v1p1beta1_generated_imageannotatorclient_batchannotateimages_listannotateimagerequest_sync] +import com.google.cloud.vision.v1p1beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p1beta1.ImageAnnotatorClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchAnnotateImagesListannotateimagerequest { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImagesListannotateimagerequest(); + } + + public static void syncBatchAnnotateImagesListannotateimagerequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(requests); + } + } +} +// [END +// vision_v1p1beta1_generated_imageannotatorclient_batchannotateimages_listannotateimagerequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..dac7410b7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p1beta1.samples; + +// [START vision_v1p1beta1_generated_imageannotatorclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.vision.v1p1beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p1beta1.ImageAnnotatorSettings; +import com.google.cloud.vision.v1p1beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p1beta1_generated_imageannotatorclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..ca296f724 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p1beta1.samples; + +// [START vision_v1p1beta1_generated_imageannotatorclient_create_setcredentialsprovider1_sync] +import com.google.cloud.vision.v1p1beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p1beta1.ImageAnnotatorSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder() + .setTransportChannelProvider( + ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p1beta1_generated_imageannotatorclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..a69bba54e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p1beta1.samples; + +// [START vision_v1p1beta1_generated_imageannotatorclient_create_setendpoint_sync] +import com.google.cloud.vision.v1p1beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p1beta1.ImageAnnotatorSettings; +import com.google.cloud.vision.v1p1beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder().setEndpoint(myEndpoint).build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p1beta1_generated_imageannotatorclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..4ebc3aad2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p1beta1.samples; + +// [START vision_v1p1beta1_generated_imageannotatorsettings_batchannotateimages_sync] +import com.google.cloud.vision.v1p1beta1.ImageAnnotatorSettings; +import java.time.Duration; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings.Builder imageAnnotatorSettingsBuilder = + ImageAnnotatorSettings.newBuilder(); + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .setRetrySettings( + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageAnnotatorSettings imageAnnotatorSettings = imageAnnotatorSettingsBuilder.build(); + } +} +// [END vision_v1p1beta1_generated_imageannotatorsettings_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..6b518f507 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p1beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p1beta1.stub.samples; + +// [START vision_v1p1beta1_generated_imageannotatorstubsettings_batchannotateimages_sync] +import com.google.cloud.vision.v1p1beta1.stub.ImageAnnotatorStubSettings; +import java.time.Duration; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorStubSettings.Builder imageAnnotatorSettingsBuilder = + ImageAnnotatorStubSettings.newBuilder(); + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .setRetrySettings( + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageAnnotatorStubSettings imageAnnotatorSettings = imageAnnotatorSettingsBuilder.build(); + } +} +// [END vision_v1p1beta1_generated_imageannotatorstubsettings_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java new file mode 100644 index 000000000..990994c7f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.samples; + +// [START vision_v1p2beta1_generated_imageannotatorclient_asyncbatchannotatefiles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p2beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateFiles(); + } + + public static void asyncAsyncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + ApiFuture future = + imageAnnotatorClient.asyncBatchAnnotateFilesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END vision_v1p2beta1_generated_imageannotatorclient_asyncbatchannotatefiles_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java new file mode 100644 index 000000000..9368a0154 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.samples; + +// [START vision_v1p2beta1_generated_imageannotatorclient_asyncbatchannotatefiles_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.vision.v1p2beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p2beta1.OperationMetadata; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateFilesLRO { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateFilesLRO(); + } + + public static void asyncAsyncBatchAnnotateFilesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + OperationFuture future = + imageAnnotatorClient.asyncBatchAnnotateFilesOperationCallable().futureCall(request); + // Do something. + AsyncBatchAnnotateFilesResponse response = future.get(); + } + } +} +// [END vision_v1p2beta1_generated_imageannotatorclient_asyncbatchannotatefiles_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java new file mode 100644 index 000000000..f3b39a9cc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.samples; + +// [START vision_v1p2beta1_generated_imageannotatorclient_asyncbatchannotatefiles_sync] +import com.google.cloud.vision.v1p2beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class SyncAsyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateFiles(); + } + + public static void syncAsyncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + AsyncBatchAnnotateFilesResponse response = + imageAnnotatorClient.asyncBatchAnnotateFilesAsync(request).get(); + } + } +} +// [END vision_v1p2beta1_generated_imageannotatorclient_asyncbatchannotatefiles_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java new file mode 100644 index 000000000..757a420d9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.samples; + +// [START +// vision_v1p2beta1_generated_imageannotatorclient_asyncbatchannotatefiles_listasyncannotatefilerequest_sync] +import com.google.cloud.vision.v1p2beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateFilesListasyncannotatefilerequest(); + } + + public static void syncAsyncBatchAnnotateFilesListasyncannotatefilerequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + AsyncBatchAnnotateFilesResponse response = + imageAnnotatorClient.asyncBatchAnnotateFilesAsync(requests).get(); + } + } +} +// [END +// vision_v1p2beta1_generated_imageannotatorclient_asyncbatchannotatefiles_listasyncannotatefilerequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java new file mode 100644 index 000000000..774230918 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.samples; + +// [START vision_v1p2beta1_generated_imageannotatorclient_batchannotateimages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p2beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class AsyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + asyncBatchAnnotateImages(); + } + + public static void asyncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateImagesRequest request = + BatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + ApiFuture future = + imageAnnotatorClient.batchAnnotateImagesCallable().futureCall(request); + // Do something. + BatchAnnotateImagesResponse response = future.get(); + } + } +} +// [END vision_v1p2beta1_generated_imageannotatorclient_batchannotateimages_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..1429e9739 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.samples; + +// [START vision_v1p2beta1_generated_imageannotatorclient_batchannotateimages_sync] +import com.google.cloud.vision.v1p2beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateImagesRequest request = + BatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(request); + } + } +} +// [END vision_v1p2beta1_generated_imageannotatorclient_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java new file mode 100644 index 000000000..11ef012c1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.samples; + +// [START +// vision_v1p2beta1_generated_imageannotatorclient_batchannotateimages_listannotateimagerequest_sync] +import com.google.cloud.vision.v1p2beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchAnnotateImagesListannotateimagerequest { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImagesListannotateimagerequest(); + } + + public static void syncBatchAnnotateImagesListannotateimagerequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(requests); + } + } +} +// [END +// vision_v1p2beta1_generated_imageannotatorclient_batchannotateimages_listannotateimagerequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..18fcda6f5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.samples; + +// [START vision_v1p2beta1_generated_imageannotatorclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorSettings; +import com.google.cloud.vision.v1p2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p2beta1_generated_imageannotatorclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..1c9fc45c5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.samples; + +// [START vision_v1p2beta1_generated_imageannotatorclient_create_setcredentialsprovider1_sync] +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder() + .setTransportChannelProvider( + ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p2beta1_generated_imageannotatorclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..b13869588 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.samples; + +// [START vision_v1p2beta1_generated_imageannotatorclient_create_setendpoint_sync] +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorSettings; +import com.google.cloud.vision.v1p2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder().setEndpoint(myEndpoint).build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p2beta1_generated_imageannotatorclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..53c4164dc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.samples; + +// [START vision_v1p2beta1_generated_imageannotatorsettings_batchannotateimages_sync] +import com.google.cloud.vision.v1p2beta1.ImageAnnotatorSettings; +import java.time.Duration; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings.Builder imageAnnotatorSettingsBuilder = + ImageAnnotatorSettings.newBuilder(); + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .setRetrySettings( + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageAnnotatorSettings imageAnnotatorSettings = imageAnnotatorSettingsBuilder.build(); + } +} +// [END vision_v1p2beta1_generated_imageannotatorsettings_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..964c75726 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p2beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p2beta1.stub.samples; + +// [START vision_v1p2beta1_generated_imageannotatorstubsettings_batchannotateimages_sync] +import com.google.cloud.vision.v1p2beta1.stub.ImageAnnotatorStubSettings; +import java.time.Duration; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorStubSettings.Builder imageAnnotatorSettingsBuilder = + ImageAnnotatorStubSettings.newBuilder(); + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .setRetrySettings( + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageAnnotatorStubSettings imageAnnotatorSettings = imageAnnotatorSettingsBuilder.build(); + } +} +// [END vision_v1p2beta1_generated_imageannotatorstubsettings_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java new file mode 100644 index 000000000..27e557a9c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_imageannotatorclient_asyncbatchannotatefiles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateFiles(); + } + + public static void asyncAsyncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + ApiFuture future = + imageAnnotatorClient.asyncBatchAnnotateFilesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_imageannotatorclient_asyncbatchannotatefiles_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java new file mode 100644 index 000000000..e8d9caf7b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_imageannotatorclient_asyncbatchannotatefiles_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.vision.v1p3beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p3beta1.OperationMetadata; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateFilesLRO { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateFilesLRO(); + } + + public static void asyncAsyncBatchAnnotateFilesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + OperationFuture future = + imageAnnotatorClient.asyncBatchAnnotateFilesOperationCallable().futureCall(request); + // Do something. + AsyncBatchAnnotateFilesResponse response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_imageannotatorclient_asyncbatchannotatefiles_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java new file mode 100644 index 000000000..ba04c42a0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_imageannotatorclient_asyncbatchannotatefiles_sync] +import com.google.cloud.vision.v1p3beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class SyncAsyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateFiles(); + } + + public static void syncAsyncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + AsyncBatchAnnotateFilesResponse response = + imageAnnotatorClient.asyncBatchAnnotateFilesAsync(request).get(); + } + } +} +// [END vision_v1p3beta1_generated_imageannotatorclient_asyncbatchannotatefiles_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java new file mode 100644 index 000000000..e01fe084f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_imageannotatorclient_asyncbatchannotatefiles_listasyncannotatefilerequest_sync] +import com.google.cloud.vision.v1p3beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateFilesListasyncannotatefilerequest(); + } + + public static void syncAsyncBatchAnnotateFilesListasyncannotatefilerequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + AsyncBatchAnnotateFilesResponse response = + imageAnnotatorClient.asyncBatchAnnotateFilesAsync(requests).get(); + } + } +} +// [END +// vision_v1p3beta1_generated_imageannotatorclient_asyncbatchannotatefiles_listasyncannotatefilerequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java new file mode 100644 index 000000000..ea639bc9c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_imageannotatorclient_batchannotateimages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class AsyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + asyncBatchAnnotateImages(); + } + + public static void asyncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateImagesRequest request = + BatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + ApiFuture future = + imageAnnotatorClient.batchAnnotateImagesCallable().futureCall(request); + // Do something. + BatchAnnotateImagesResponse response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_imageannotatorclient_batchannotateimages_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..c923a152b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_imageannotatorclient_batchannotateimages_sync] +import com.google.cloud.vision.v1p3beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateImagesRequest request = + BatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(request); + } + } +} +// [END vision_v1p3beta1_generated_imageannotatorclient_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java new file mode 100644 index 000000000..a22008908 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_imageannotatorclient_batchannotateimages_listannotateimagerequest_sync] +import com.google.cloud.vision.v1p3beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchAnnotateImagesListannotateimagerequest { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImagesListannotateimagerequest(); + } + + public static void syncBatchAnnotateImagesListannotateimagerequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(requests); + } + } +} +// [END +// vision_v1p3beta1_generated_imageannotatorclient_batchannotateimages_listannotateimagerequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..6bda10d01 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_imageannotatorclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorSettings; +import com.google.cloud.vision.v1p3beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p3beta1_generated_imageannotatorclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..22dfe1eaa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_imageannotatorclient_create_setcredentialsprovider1_sync] +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder() + .setTransportChannelProvider( + ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p3beta1_generated_imageannotatorclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..dbed04152 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_imageannotatorclient_create_setendpoint_sync] +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorSettings; +import com.google.cloud.vision.v1p3beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder().setEndpoint(myEndpoint).build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p3beta1_generated_imageannotatorclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..fc827245d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_imageannotatorsettings_batchannotateimages_sync] +import com.google.cloud.vision.v1p3beta1.ImageAnnotatorSettings; +import java.time.Duration; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings.Builder imageAnnotatorSettingsBuilder = + ImageAnnotatorSettings.newBuilder(); + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .setRetrySettings( + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageAnnotatorSettings imageAnnotatorSettings = imageAnnotatorSettingsBuilder.build(); + } +} +// [END vision_v1p3beta1_generated_imageannotatorsettings_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/AsyncAddProductToProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/AsyncAddProductToProductSet.java new file mode 100644 index 000000000..533054cc5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/AsyncAddProductToProductSet.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; +import com.google.protobuf.Empty; + +public class AsyncAddProductToProductSet { + + public static void main(String[] args) throws Exception { + asyncAddProductToProductSet(); + } + + public static void asyncAddProductToProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + AddProductToProductSetRequest request = + AddProductToProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = + productSearchClient.addProductToProductSetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSet.java new file mode 100644 index 000000000..89026e696 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSet.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_sync] +import com.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncAddProductToProductSet { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSet(); + } + + public static void syncAddProductToProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + AddProductToProductSetRequest request = + AddProductToProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + productSearchClient.addProductToProductSet(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameProductname.java new file mode 100644 index 000000000..db09e2c8b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameProductname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_productsetnameproductname_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncAddProductToProductSetProductsetnameProductname { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetProductsetnameProductname(); + } + + public static void syncAddProductToProductSetProductsetnameProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_productsetnameproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameString.java new file mode 100644 index 000000000..764412e0f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_productsetnamestring_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncAddProductToProductSetProductsetnameString { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetProductsetnameString(); + } + + public static void syncAddProductToProductSetProductsetnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_productsetnamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringProductname.java new file mode 100644 index 000000000..154ad305d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringProductname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_stringproductname_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncAddProductToProductSetStringProductname { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetStringProductname(); + } + + public static void syncAddProductToProductSetStringProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_stringproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringString.java new file mode 100644 index 000000000..21f18eb16 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_stringstring_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncAddProductToProductSetStringString { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetStringString(); + } + + public static void syncAddProductToProductSetStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_addproducttoproductset_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..5d7bf9758 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSearchSettings; +import com.google.cloud.vision.v1p3beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings productSearchSettings = + ProductSearchSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); + } +} +// [END vision_v1p3beta1_generated_productsearchclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..fb4fcbe63 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_create_setcredentialsprovider1_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSearchSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings productSearchSettings = + ProductSearchSettings.newBuilder() + .setTransportChannelProvider( + ProductSearchSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); + } +} +// [END vision_v1p3beta1_generated_productsearchclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..edc3f344c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_create_setendpoint_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSearchSettings; +import com.google.cloud.vision.v1p3beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings productSearchSettings = + ProductSearchSettings.newBuilder().setEndpoint(myEndpoint).build(); + ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); + } +} +// [END vision_v1p3beta1_generated_productsearchclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/AsyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/AsyncCreateProduct.java new file mode 100644 index 000000000..9af3a914a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/AsyncCreateProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_createproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.CreateProductRequest; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class AsyncCreateProduct { + + public static void main(String[] args) throws Exception { + asyncCreateProduct(); + } + + public static void asyncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + ApiFuture future = productSearchClient.createProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_createproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000..195336f2a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/SyncCreateProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_createproduct_sync] +import com.google.cloud.vision.v1p3beta1.CreateProductRequest; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + Product response = productSearchClient.createProduct(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/SyncCreateProductLocationnameProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/SyncCreateProductLocationnameProductString.java new file mode 100644 index 000000000..b0e8dd03c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/SyncCreateProductLocationnameProductString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_createproduct_locationnameproductstring_sync] +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncCreateProductLocationnameProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductLocationnameProductString(); + } + + public static void syncCreateProductLocationnameProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productSearchClient.createProduct(parent, product, productId); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_createproduct_locationnameproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/SyncCreateProductStringProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/SyncCreateProductStringProductString.java new file mode 100644 index 000000000..12602bc3b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproduct/SyncCreateProductStringProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_createproduct_stringproductstring_sync] +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncCreateProductStringProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductStringProductString(); + } + + public static void syncCreateProductStringProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productSearchClient.createProduct(parent, product, productId); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_createproduct_stringproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/AsyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/AsyncCreateProductSet.java new file mode 100644 index 000000000..9697cc6e3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/AsyncCreateProductSet.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_createproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.CreateProductSetRequest; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; + +public class AsyncCreateProductSet { + + public static void main(String[] args) throws Exception { + asyncCreateProductSet(); + } + + public static void asyncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductSetRequest request = + CreateProductSetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProductSet(ProductSet.newBuilder().build()) + .setProductSetId("productSetId1003042158") + .build(); + ApiFuture future = + productSearchClient.createProductSetCallable().futureCall(request); + // Do something. + ProductSet response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_createproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/SyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/SyncCreateProductSet.java new file mode 100644 index 000000000..b47e1f9a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/SyncCreateProductSet.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_createproductset_sync] +import com.google.cloud.vision.v1p3beta1.CreateProductSetRequest; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; + +public class SyncCreateProductSet { + + public static void main(String[] args) throws Exception { + syncCreateProductSet(); + } + + public static void syncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductSetRequest request = + CreateProductSetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProductSet(ProductSet.newBuilder().build()) + .setProductSetId("productSetId1003042158") + .build(); + ProductSet response = productSearchClient.createProductSet(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_createproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/SyncCreateProductSetLocationnameProductsetString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/SyncCreateProductSetLocationnameProductsetString.java new file mode 100644 index 000000000..cb47fdd79 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/SyncCreateProductSetLocationnameProductsetString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_createproductset_locationnameproductsetstring_sync] +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; + +public class SyncCreateProductSetLocationnameProductsetString { + + public static void main(String[] args) throws Exception { + syncCreateProductSetLocationnameProductsetString(); + } + + public static void syncCreateProductSetLocationnameProductsetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + ProductSet response = productSearchClient.createProductSet(parent, productSet, productSetId); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_createproductset_locationnameproductsetstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/SyncCreateProductSetStringProductsetString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/SyncCreateProductSetStringProductsetString.java new file mode 100644 index 000000000..a959d0483 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createproductset/SyncCreateProductSetStringProductsetString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_createproductset_stringproductsetstring_sync] +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; + +public class SyncCreateProductSetStringProductsetString { + + public static void main(String[] args) throws Exception { + syncCreateProductSetStringProductsetString(); + } + + public static void syncCreateProductSetStringProductsetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + ProductSet response = productSearchClient.createProductSet(parent, productSet, productSetId); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_createproductset_stringproductsetstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/AsyncCreateReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/AsyncCreateReferenceImage.java new file mode 100644 index 000000000..bf5e24b8e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/AsyncCreateReferenceImage.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_createreferenceimage_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; + +public class AsyncCreateReferenceImage { + + public static void main(String[] args) throws Exception { + asyncCreateReferenceImage(); + } + + public static void asyncCreateReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateReferenceImageRequest request = + CreateReferenceImageRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setReferenceImage(ReferenceImage.newBuilder().build()) + .setReferenceImageId("referenceImageId1224107531") + .build(); + ApiFuture future = + productSearchClient.createReferenceImageCallable().futureCall(request); + // Do something. + ReferenceImage response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_createreferenceimage_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImage.java new file mode 100644 index 000000000..ce024e0e2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImage.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_createreferenceimage_sync] +import com.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; + +public class SyncCreateReferenceImage { + + public static void main(String[] args) throws Exception { + syncCreateReferenceImage(); + } + + public static void syncCreateReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateReferenceImageRequest request = + CreateReferenceImageRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setReferenceImage(ReferenceImage.newBuilder().build()) + .setReferenceImageId("referenceImageId1224107531") + .build(); + ReferenceImage response = productSearchClient.createReferenceImage(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_createreferenceimage_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageProductnameReferenceimageString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageProductnameReferenceimageString.java new file mode 100644 index 000000000..271a9677d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageProductnameReferenceimageString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_createreferenceimage_productnamereferenceimagestring_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; + +public class SyncCreateReferenceImageProductnameReferenceimageString { + + public static void main(String[] args) throws Exception { + syncCreateReferenceImageProductnameReferenceimageString(); + } + + public static void syncCreateReferenceImageProductnameReferenceimageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + ReferenceImage response = + productSearchClient.createReferenceImage(parent, referenceImage, referenceImageId); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_createreferenceimage_productnamereferenceimagestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageStringReferenceimageString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageStringReferenceimageString.java new file mode 100644 index 000000000..54373eaf2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageStringReferenceimageString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_createreferenceimage_stringreferenceimagestring_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; + +public class SyncCreateReferenceImageStringReferenceimageString { + + public static void main(String[] args) throws Exception { + syncCreateReferenceImageStringReferenceimageString(); + } + + public static void syncCreateReferenceImageStringReferenceimageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + ReferenceImage response = + productSearchClient.createReferenceImage(parent, referenceImage, referenceImageId); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_createreferenceimage_stringreferenceimagestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/AsyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/AsyncDeleteProduct.java new file mode 100644 index 000000000..ed6b85b19 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/AsyncDeleteProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_deleteproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.DeleteProductRequest; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteProduct { + + public static void main(String[] args) throws Exception { + asyncDeleteProduct(); + } + + public static void asyncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = productSearchClient.deleteProductCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deleteproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/SyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/SyncDeleteProduct.java new file mode 100644 index 000000000..99daaf239 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/SyncDeleteProduct.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_deleteproduct_sync] +import com.google.cloud.vision.v1p3beta1.DeleteProductRequest; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncDeleteProduct { + + public static void main(String[] args) throws Exception { + syncDeleteProduct(); + } + + public static void syncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + productSearchClient.deleteProduct(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deleteproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/SyncDeleteProductProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/SyncDeleteProductProductname.java new file mode 100644 index 000000000..f8a2650c4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/SyncDeleteProductProductname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_deleteproduct_productname_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncDeleteProductProductname { + + public static void main(String[] args) throws Exception { + syncDeleteProductProductname(); + } + + public static void syncDeleteProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.deleteProduct(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deleteproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/SyncDeleteProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/SyncDeleteProductString.java new file mode 100644 index 000000000..f76ab1369 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproduct/SyncDeleteProductString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_deleteproduct_string_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncDeleteProductString { + + public static void main(String[] args) throws Exception { + syncDeleteProductString(); + } + + public static void syncDeleteProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.deleteProduct(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deleteproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/AsyncDeleteProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/AsyncDeleteProductSet.java new file mode 100644 index 000000000..af2404334 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/AsyncDeleteProductSet.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_deleteproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.DeleteProductSetRequest; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; +import com.google.protobuf.Empty; + +public class AsyncDeleteProductSet { + + public static void main(String[] args) throws Exception { + asyncDeleteProductSet(); + } + + public static void asyncDeleteProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductSetRequest request = + DeleteProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + ApiFuture future = productSearchClient.deleteProductSetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deleteproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/SyncDeleteProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/SyncDeleteProductSet.java new file mode 100644 index 000000000..e43bfadea --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/SyncDeleteProductSet.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_deleteproductset_sync] +import com.google.cloud.vision.v1p3beta1.DeleteProductSetRequest; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncDeleteProductSet { + + public static void main(String[] args) throws Exception { + syncDeleteProductSet(); + } + + public static void syncDeleteProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductSetRequest request = + DeleteProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + productSearchClient.deleteProductSet(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deleteproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/SyncDeleteProductSetProductsetname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/SyncDeleteProductSetProductsetname.java new file mode 100644 index 000000000..854786fad --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/SyncDeleteProductSetProductsetname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_deleteproductset_productsetname_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncDeleteProductSetProductsetname { + + public static void main(String[] args) throws Exception { + syncDeleteProductSetProductsetname(); + } + + public static void syncDeleteProductSetProductsetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + productSearchClient.deleteProductSet(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deleteproductset_productsetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/SyncDeleteProductSetString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/SyncDeleteProductSetString.java new file mode 100644 index 000000000..9826a2c52 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deleteproductset/SyncDeleteProductSetString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_deleteproductset_string_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncDeleteProductSetString { + + public static void main(String[] args) throws Exception { + syncDeleteProductSetString(); + } + + public static void syncDeleteProductSetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + productSearchClient.deleteProductSet(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deleteproductset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/AsyncDeleteReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/AsyncDeleteReferenceImage.java new file mode 100644 index 000000000..1030ec55a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/AsyncDeleteReferenceImage.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_deletereferenceimage_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImageName; +import com.google.protobuf.Empty; + +public class AsyncDeleteReferenceImage { + + public static void main(String[] args) throws Exception { + asyncDeleteReferenceImage(); + } + + public static void asyncDeleteReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteReferenceImageRequest request = + DeleteReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + ApiFuture future = + productSearchClient.deleteReferenceImageCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deletereferenceimage_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImage.java new file mode 100644 index 000000000..dbad79626 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImage.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_deletereferenceimage_sync] +import com.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImageName; + +public class SyncDeleteReferenceImage { + + public static void main(String[] args) throws Exception { + syncDeleteReferenceImage(); + } + + public static void syncDeleteReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteReferenceImageRequest request = + DeleteReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + productSearchClient.deleteReferenceImage(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deletereferenceimage_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageReferenceimagename.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageReferenceimagename.java new file mode 100644 index 000000000..04e8d18aa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageReferenceimagename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_deletereferenceimage_referenceimagename_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImageName; + +public class SyncDeleteReferenceImageReferenceimagename { + + public static void main(String[] args) throws Exception { + syncDeleteReferenceImageReferenceimagename(); + } + + public static void syncDeleteReferenceImageReferenceimagename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + productSearchClient.deleteReferenceImage(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deletereferenceimage_referenceimagename_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageString.java new file mode 100644 index 000000000..947dc4824 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_deletereferenceimage_string_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImageName; + +public class SyncDeleteReferenceImageString { + + public static void main(String[] args) throws Exception { + syncDeleteReferenceImageString(); + } + + public static void syncDeleteReferenceImageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString(); + productSearchClient.deleteReferenceImage(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_deletereferenceimage_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/AsyncGetProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/AsyncGetProduct.java new file mode 100644 index 000000000..4ba33ac36 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/AsyncGetProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.GetProductRequest; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class AsyncGetProduct { + + public static void main(String[] args) throws Exception { + asyncGetProduct(); + } + + public static void asyncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = productSearchClient.getProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/SyncGetProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/SyncGetProduct.java new file mode 100644 index 000000000..b4633b14e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/SyncGetProduct.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getproduct_sync] +import com.google.cloud.vision.v1p3beta1.GetProductRequest; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncGetProduct { + + public static void main(String[] args) throws Exception { + syncGetProduct(); + } + + public static void syncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + Product response = productSearchClient.getProduct(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/SyncGetProductProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/SyncGetProductProductname.java new file mode 100644 index 000000000..0b4047436 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/SyncGetProductProductname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getproduct_productname_sync] +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncGetProductProductname { + + public static void main(String[] args) throws Exception { + syncGetProductProductname(); + } + + public static void syncGetProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + Product response = productSearchClient.getProduct(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/SyncGetProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/SyncGetProductString.java new file mode 100644 index 000000000..d4dbb7779 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproduct/SyncGetProductString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getproduct_string_sync] +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncGetProductString { + + public static void main(String[] args) throws Exception { + syncGetProductString(); + } + + public static void syncGetProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + Product response = productSearchClient.getProduct(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/AsyncGetProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/AsyncGetProductSet.java new file mode 100644 index 000000000..00ffb6bc4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/AsyncGetProductSet.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.GetProductSetRequest; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class AsyncGetProductSet { + + public static void main(String[] args) throws Exception { + asyncGetProductSet(); + } + + public static void asyncGetProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductSetRequest request = + GetProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + ApiFuture future = + productSearchClient.getProductSetCallable().futureCall(request); + // Do something. + ProductSet response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/SyncGetProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/SyncGetProductSet.java new file mode 100644 index 000000000..4a12adbd3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/SyncGetProductSet.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getproductset_sync] +import com.google.cloud.vision.v1p3beta1.GetProductSetRequest; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncGetProductSet { + + public static void main(String[] args) throws Exception { + syncGetProductSet(); + } + + public static void syncGetProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductSetRequest request = + GetProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + ProductSet response = productSearchClient.getProductSet(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/SyncGetProductSetProductsetname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/SyncGetProductSetProductsetname.java new file mode 100644 index 000000000..f7c71eeff --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/SyncGetProductSetProductsetname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getproductset_productsetname_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncGetProductSetProductsetname { + + public static void main(String[] args) throws Exception { + syncGetProductSetProductsetname(); + } + + public static void syncGetProductSetProductsetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductSet response = productSearchClient.getProductSet(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getproductset_productsetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/SyncGetProductSetString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/SyncGetProductSetString.java new file mode 100644 index 000000000..2a467baca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getproductset/SyncGetProductSetString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getproductset_string_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncGetProductSetString { + + public static void main(String[] args) throws Exception { + syncGetProductSetString(); + } + + public static void syncGetProductSetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + ProductSet response = productSearchClient.getProductSet(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getproductset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/AsyncGetReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/AsyncGetReferenceImage.java new file mode 100644 index 000000000..a7f07b5d1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/AsyncGetReferenceImage.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getreferenceimage_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.GetReferenceImageRequest; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; +import com.google.cloud.vision.v1p3beta1.ReferenceImageName; + +public class AsyncGetReferenceImage { + + public static void main(String[] args) throws Exception { + asyncGetReferenceImage(); + } + + public static void asyncGetReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetReferenceImageRequest request = + GetReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + ApiFuture future = + productSearchClient.getReferenceImageCallable().futureCall(request); + // Do something. + ReferenceImage response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getreferenceimage_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/SyncGetReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/SyncGetReferenceImage.java new file mode 100644 index 000000000..ddf93eebf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/SyncGetReferenceImage.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getreferenceimage_sync] +import com.google.cloud.vision.v1p3beta1.GetReferenceImageRequest; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; +import com.google.cloud.vision.v1p3beta1.ReferenceImageName; + +public class SyncGetReferenceImage { + + public static void main(String[] args) throws Exception { + syncGetReferenceImage(); + } + + public static void syncGetReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetReferenceImageRequest request = + GetReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + ReferenceImage response = productSearchClient.getReferenceImage(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getreferenceimage_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageReferenceimagename.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageReferenceimagename.java new file mode 100644 index 000000000..fc4d1adc1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageReferenceimagename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getreferenceimage_referenceimagename_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; +import com.google.cloud.vision.v1p3beta1.ReferenceImageName; + +public class SyncGetReferenceImageReferenceimagename { + + public static void main(String[] args) throws Exception { + syncGetReferenceImageReferenceimagename(); + } + + public static void syncGetReferenceImageReferenceimagename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + ReferenceImage response = productSearchClient.getReferenceImage(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getreferenceimage_referenceimagename_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageString.java new file mode 100644 index 000000000..f8b0246a7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_getreferenceimage_string_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; +import com.google.cloud.vision.v1p3beta1.ReferenceImageName; + +public class SyncGetReferenceImageString { + + public static void main(String[] args) throws Exception { + syncGetReferenceImageString(); + } + + public static void syncGetReferenceImageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString(); + ReferenceImage response = productSearchClient.getReferenceImage(name); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_getreferenceimage_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/AsyncImportProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/AsyncImportProductSets.java new file mode 100644 index 000000000..8b543a0cc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/AsyncImportProductSets.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_importproductsets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1p3beta1.ImportProductSetsRequest; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.longrunning.Operation; + +public class AsyncImportProductSets { + + public static void main(String[] args) throws Exception { + asyncImportProductSets(); + } + + public static void asyncImportProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ImportProductSetsRequest request = + ImportProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) + .build(); + ApiFuture future = + productSearchClient.importProductSetsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_importproductsets_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/AsyncImportProductSetsLRO.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/AsyncImportProductSetsLRO.java new file mode 100644 index 000000000..ccb149c8e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/AsyncImportProductSetsLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_importproductsets_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.vision.v1p3beta1.BatchOperationMetadata; +import com.google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1p3beta1.ImportProductSetsRequest; +import com.google.cloud.vision.v1p3beta1.ImportProductSetsResponse; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class AsyncImportProductSetsLRO { + + public static void main(String[] args) throws Exception { + asyncImportProductSetsLRO(); + } + + public static void asyncImportProductSetsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ImportProductSetsRequest request = + ImportProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) + .build(); + OperationFuture future = + productSearchClient.importProductSetsOperationCallable().futureCall(request); + // Do something. + ImportProductSetsResponse response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_importproductsets_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/SyncImportProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/SyncImportProductSets.java new file mode 100644 index 000000000..0be377eca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/SyncImportProductSets.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_importproductsets_sync] +import com.google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1p3beta1.ImportProductSetsRequest; +import com.google.cloud.vision.v1p3beta1.ImportProductSetsResponse; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncImportProductSets { + + public static void main(String[] args) throws Exception { + syncImportProductSets(); + } + + public static void syncImportProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ImportProductSetsRequest request = + ImportProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) + .build(); + ImportProductSetsResponse response = + productSearchClient.importProductSetsAsync(request).get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_importproductsets_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/SyncImportProductSetsLocationnameImportproductsetsinputconfig.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/SyncImportProductSetsLocationnameImportproductsetsinputconfig.java new file mode 100644 index 000000000..2dcaf84b0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/SyncImportProductSetsLocationnameImportproductsetsinputconfig.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_importproductsets_locationnameimportproductsetsinputconfig_sync] +import com.google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1p3beta1.ImportProductSetsResponse; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncImportProductSetsLocationnameImportproductsetsinputconfig { + + public static void main(String[] args) throws Exception { + syncImportProductSetsLocationnameImportproductsetsinputconfig(); + } + + public static void syncImportProductSetsLocationnameImportproductsetsinputconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + ImportProductSetsResponse response = + productSearchClient.importProductSetsAsync(parent, inputConfig).get(); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_importproductsets_locationnameimportproductsetsinputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/SyncImportProductSetsStringImportproductsetsinputconfig.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/SyncImportProductSetsStringImportproductsetsinputconfig.java new file mode 100644 index 000000000..de013a595 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/importproductsets/SyncImportProductSetsStringImportproductsetsinputconfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_importproductsets_stringimportproductsetsinputconfig_sync] +import com.google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1p3beta1.ImportProductSetsResponse; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncImportProductSetsStringImportproductsetsinputconfig { + + public static void main(String[] args) throws Exception { + syncImportProductSetsStringImportproductsetsinputconfig(); + } + + public static void syncImportProductSetsStringImportproductsetsinputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + ImportProductSetsResponse response = + productSearchClient.importProductSetsAsync(parent, inputConfig).get(); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_importproductsets_stringimportproductsetsinputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/AsyncListProducts.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/AsyncListProducts.java new file mode 100644 index 000000000..e0c8e47f2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/AsyncListProducts.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.ListProductsRequest; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class AsyncListProducts { + + public static void main(String[] args) throws Exception { + asyncListProducts(); + } + + public static void asyncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listProductsPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/AsyncListProductsPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/AsyncListProductsPaged.java new file mode 100644 index 000000000..f1a5d4aa2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/AsyncListProductsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproducts_paged_async] +import com.google.cloud.vision.v1p3beta1.ListProductsRequest; +import com.google.cloud.vision.v1p3beta1.ListProductsResponse; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.common.base.Strings; + +public class AsyncListProductsPaged { + + public static void main(String[] args) throws Exception { + asyncListProductsPaged(); + } + + public static void asyncListProductsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListProductsResponse response = productSearchClient.listProductsCallable().call(request); + for (Product element : response.getProductsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproducts_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/SyncListProducts.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/SyncListProducts.java new file mode 100644 index 000000000..37e8dfd7b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/SyncListProducts.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproducts_sync] +import com.google.cloud.vision.v1p3beta1.ListProductsRequest; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncListProducts { + + public static void main(String[] args) throws Exception { + syncListProducts(); + } + + public static void syncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Product element : productSearchClient.listProducts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/SyncListProductsLocationname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/SyncListProductsLocationname.java new file mode 100644 index 000000000..083c86797 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/SyncListProductsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproducts_locationname_sync] +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncListProductsLocationname { + + public static void main(String[] args) throws Exception { + syncListProductsLocationname(); + } + + public static void syncListProductsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Product element : productSearchClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproducts_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/SyncListProductsString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/SyncListProductsString.java new file mode 100644 index 000000000..f156d4354 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproducts/SyncListProductsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproducts_string_sync] +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; + +public class SyncListProductsString { + + public static void main(String[] args) throws Exception { + syncListProductsString(); + } + + public static void syncListProductsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Product element : productSearchClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproducts_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/AsyncListProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/AsyncListProductSets.java new file mode 100644 index 000000000..165f0b245 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/AsyncListProductSets.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproductsets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.ListProductSetsRequest; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; + +public class AsyncListProductSets { + + public static void main(String[] args) throws Exception { + asyncListProductSets(); + } + + public static void asyncListProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductSetsRequest request = + ListProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listProductSetsPagedCallable().futureCall(request); + // Do something. + for (ProductSet element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproductsets_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/AsyncListProductSetsPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/AsyncListProductSetsPaged.java new file mode 100644 index 000000000..5e454493f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/AsyncListProductSetsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproductsets_paged_async] +import com.google.cloud.vision.v1p3beta1.ListProductSetsRequest; +import com.google.cloud.vision.v1p3beta1.ListProductSetsResponse; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; +import com.google.common.base.Strings; + +public class AsyncListProductSetsPaged { + + public static void main(String[] args) throws Exception { + asyncListProductSetsPaged(); + } + + public static void asyncListProductSetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductSetsRequest request = + ListProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListProductSetsResponse response = + productSearchClient.listProductSetsCallable().call(request); + for (ProductSet element : response.getProductSetsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproductsets_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/SyncListProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/SyncListProductSets.java new file mode 100644 index 000000000..463615a4b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/SyncListProductSets.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproductsets_sync] +import com.google.cloud.vision.v1p3beta1.ListProductSetsRequest; +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; + +public class SyncListProductSets { + + public static void main(String[] args) throws Exception { + syncListProductSets(); + } + + public static void syncListProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductSetsRequest request = + ListProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ProductSet element : productSearchClient.listProductSets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproductsets_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/SyncListProductSetsLocationname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/SyncListProductSetsLocationname.java new file mode 100644 index 000000000..2cfa1086a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/SyncListProductSetsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproductsets_locationname_sync] +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; + +public class SyncListProductSetsLocationname { + + public static void main(String[] args) throws Exception { + syncListProductSetsLocationname(); + } + + public static void syncListProductSetsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (ProductSet element : productSearchClient.listProductSets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproductsets_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/SyncListProductSetsString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/SyncListProductSetsString.java new file mode 100644 index 000000000..79f0475a1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsets/SyncListProductSetsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproductsets_string_sync] +import com.google.cloud.vision.v1p3beta1.LocationName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; + +public class SyncListProductSetsString { + + public static void main(String[] args) throws Exception { + syncListProductSetsString(); + } + + public static void syncListProductSetsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (ProductSet element : productSearchClient.listProductSets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproductsets_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSet.java new file mode 100644 index 000000000..2b5e3fb3f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSet.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproductsinproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class AsyncListProductsInProductSet { + + public static void main(String[] args) throws Exception { + asyncListProductsInProductSet(); + } + + public static void asyncListProductsInProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsInProductSetRequest request = + ListProductsInProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listProductsInProductSetPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproductsinproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSetPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSetPaged.java new file mode 100644 index 000000000..e0409004a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSetPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproductsinproductset_paged_async] +import com.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1p3beta1.ListProductsInProductSetResponse; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; +import com.google.common.base.Strings; + +public class AsyncListProductsInProductSetPaged { + + public static void main(String[] args) throws Exception { + asyncListProductsInProductSetPaged(); + } + + public static void asyncListProductsInProductSetPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsInProductSetRequest request = + ListProductsInProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListProductsInProductSetResponse response = + productSearchClient.listProductsInProductSetCallable().call(request); + for (Product element : response.getProductsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproductsinproductset_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSet.java new file mode 100644 index 000000000..8fcb98ff6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSet.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproductsinproductset_sync] +import com.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncListProductsInProductSet { + + public static void main(String[] args) throws Exception { + syncListProductsInProductSet(); + } + + public static void syncListProductsInProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsInProductSetRequest request = + ListProductsInProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Product element : productSearchClient.listProductsInProductSet(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproductsinproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetProductsetname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetProductsetname.java new file mode 100644 index 000000000..bf7472304 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetProductsetname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_listproductsinproductset_productsetname_sync] +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncListProductsInProductSetProductsetname { + + public static void main(String[] args) throws Exception { + syncListProductsInProductSetProductsetname(); + } + + public static void syncListProductsInProductSetProductsetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + for (Product element : productSearchClient.listProductsInProductSet(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproductsinproductset_productsetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetString.java new file mode 100644 index 000000000..40338a072 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listproductsinproductset_string_sync] +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncListProductsInProductSetString { + + public static void main(String[] args) throws Exception { + syncListProductsInProductSetString(); + } + + public static void syncListProductsInProductSetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + for (Product element : productSearchClient.listProductsInProductSet(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listproductsinproductset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/AsyncListReferenceImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/AsyncListReferenceImages.java new file mode 100644 index 000000000..0586619cb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/AsyncListReferenceImages.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listreferenceimages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; + +public class AsyncListReferenceImages { + + public static void main(String[] args) throws Exception { + asyncListReferenceImages(); + } + + public static void asyncListReferenceImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListReferenceImagesRequest request = + ListReferenceImagesRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listReferenceImagesPagedCallable().futureCall(request); + // Do something. + for (ReferenceImage element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listreferenceimages_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/AsyncListReferenceImagesPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/AsyncListReferenceImagesPaged.java new file mode 100644 index 000000000..82f1f7677 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/AsyncListReferenceImagesPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listreferenceimages_paged_async] +import com.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1p3beta1.ListReferenceImagesResponse; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; +import com.google.common.base.Strings; + +public class AsyncListReferenceImagesPaged { + + public static void main(String[] args) throws Exception { + asyncListReferenceImagesPaged(); + } + + public static void asyncListReferenceImagesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListReferenceImagesRequest request = + ListReferenceImagesRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListReferenceImagesResponse response = + productSearchClient.listReferenceImagesCallable().call(request); + for (ReferenceImage element : response.getReferenceImagesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listreferenceimages_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/SyncListReferenceImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/SyncListReferenceImages.java new file mode 100644 index 000000000..579684673 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/SyncListReferenceImages.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listreferenceimages_sync] +import com.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; + +public class SyncListReferenceImages { + + public static void main(String[] args) throws Exception { + syncListReferenceImages(); + } + + public static void syncListReferenceImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListReferenceImagesRequest request = + ListReferenceImagesRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ReferenceImage element : productSearchClient.listReferenceImages(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listreferenceimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesProductname.java new file mode 100644 index 000000000..9c08e2d73 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listreferenceimages_productname_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; + +public class SyncListReferenceImagesProductname { + + public static void main(String[] args) throws Exception { + syncListReferenceImagesProductname(); + } + + public static void syncListReferenceImagesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + for (ReferenceImage element : productSearchClient.listReferenceImages(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listreferenceimages_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesString.java new file mode 100644 index 000000000..619aaee78 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_listreferenceimages_string_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ReferenceImage; + +public class SyncListReferenceImagesString { + + public static void main(String[] args) throws Exception { + syncListReferenceImagesString(); + } + + public static void syncListReferenceImagesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + for (ReferenceImage element : productSearchClient.listReferenceImages(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_listreferenceimages_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/AsyncRemoveProductFromProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/AsyncRemoveProductFromProductSet.java new file mode 100644 index 000000000..264f773fb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/AsyncRemoveProductFromProductSet.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; +import com.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest; +import com.google.protobuf.Empty; + +public class AsyncRemoveProductFromProductSet { + + public static void main(String[] args) throws Exception { + asyncRemoveProductFromProductSet(); + } + + public static void asyncRemoveProductFromProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + RemoveProductFromProductSetRequest request = + RemoveProductFromProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = + productSearchClient.removeProductFromProductSetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSet.java new file mode 100644 index 000000000..8fc234a05 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSet.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; +import com.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest; + +public class SyncRemoveProductFromProductSet { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSet(); + } + + public static void syncRemoveProductFromProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + RemoveProductFromProductSetRequest request = + RemoveProductFromProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + productSearchClient.removeProductFromProductSet(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameProductname.java new file mode 100644 index 000000000..d5b1513c1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameProductname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_productsetnameproductname_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncRemoveProductFromProductSetProductsetnameProductname { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetProductsetnameProductname(); + } + + public static void syncRemoveProductFromProductSetProductsetnameProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_productsetnameproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameString.java new file mode 100644 index 000000000..d305c81a9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_productsetnamestring_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncRemoveProductFromProductSetProductsetnameString { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetProductsetnameString(); + } + + public static void syncRemoveProductFromProductSetProductsetnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_productsetnamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringProductname.java new file mode 100644 index 000000000..1b4201626 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringProductname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_stringproductname_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncRemoveProductFromProductSetStringProductname { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetStringProductname(); + } + + public static void syncRemoveProductFromProductSetStringProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_stringproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringString.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringString.java new file mode 100644 index 000000000..4b9c7b97c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START +// vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_stringstring_sync] +import com.google.cloud.vision.v1p3beta1.ProductName; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSetName; + +public class SyncRemoveProductFromProductSetStringString { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetStringString(); + } + + public static void syncRemoveProductFromProductSetStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END +// vision_v1p3beta1_generated_productsearchclient_removeproductfromproductset_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproduct/AsyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproduct/AsyncUpdateProduct.java new file mode 100644 index 000000000..882ebf46f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproduct/AsyncUpdateProduct.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_updateproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateProduct { + + public static void main(String[] args) throws Exception { + asyncUpdateProduct(); + } + + public static void asyncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = productSearchClient.updateProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_updateproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproduct/SyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproduct/SyncUpdateProduct.java new file mode 100644 index 000000000..7e4f49afc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproduct/SyncUpdateProduct.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_updateproduct_sync] +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProduct { + + public static void main(String[] args) throws Exception { + syncUpdateProduct(); + } + + public static void syncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Product response = productSearchClient.updateProduct(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_updateproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproduct/SyncUpdateProductProductFieldmask.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproduct/SyncUpdateProductProductFieldmask.java new file mode 100644 index 000000000..bb05b2037 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproduct/SyncUpdateProductProductFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_updateproduct_productfieldmask_sync] +import com.google.cloud.vision.v1p3beta1.Product; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductProductFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateProductProductFieldmask(); + } + + public static void syncUpdateProductProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + Product product = Product.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Product response = productSearchClient.updateProduct(product, updateMask); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_updateproduct_productfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproductset/AsyncUpdateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproductset/AsyncUpdateProductSet.java new file mode 100644 index 000000000..a015b0dea --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproductset/AsyncUpdateProductSet.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_updateproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; +import com.google.cloud.vision.v1p3beta1.UpdateProductSetRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateProductSet { + + public static void main(String[] args) throws Exception { + asyncUpdateProductSet(); + } + + public static void asyncUpdateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductSetRequest request = + UpdateProductSetRequest.newBuilder() + .setProductSet(ProductSet.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + productSearchClient.updateProductSetCallable().futureCall(request); + // Do something. + ProductSet response = future.get(); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_updateproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproductset/SyncUpdateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproductset/SyncUpdateProductSet.java new file mode 100644 index 000000000..a2f8abbcd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproductset/SyncUpdateProductSet.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_updateproductset_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; +import com.google.cloud.vision.v1p3beta1.UpdateProductSetRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductSet { + + public static void main(String[] args) throws Exception { + syncUpdateProductSet(); + } + + public static void syncUpdateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductSetRequest request = + UpdateProductSetRequest.newBuilder() + .setProductSet(ProductSet.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ProductSet response = productSearchClient.updateProductSet(request); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_updateproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproductset/SyncUpdateProductSetProductsetFieldmask.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproductset/SyncUpdateProductSetProductsetFieldmask.java new file mode 100644 index 000000000..d391e356e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchclient/updateproductset/SyncUpdateProductSetProductsetFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchclient_updateproductset_productsetfieldmask_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchClient; +import com.google.cloud.vision.v1p3beta1.ProductSet; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductSetProductsetFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateProductSetProductsetFieldmask(); + } + + public static void syncUpdateProductSetProductsetFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSet productSet = ProductSet.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ProductSet response = productSearchClient.updateProductSet(productSet, updateMask); + } + } +} +// [END vision_v1p3beta1_generated_productsearchclient_updateproductset_productsetfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchsettings/createproductset/SyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchsettings/createproductset/SyncCreateProductSet.java new file mode 100644 index 000000000..4ff45436e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/productsearchsettings/createproductset/SyncCreateProductSet.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.samples; + +// [START vision_v1p3beta1_generated_productsearchsettings_createproductset_sync] +import com.google.cloud.vision.v1p3beta1.ProductSearchSettings; +import java.time.Duration; + +public class SyncCreateProductSet { + + public static void main(String[] args) throws Exception { + syncCreateProductSet(); + } + + public static void syncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings.Builder productSearchSettingsBuilder = ProductSearchSettings.newBuilder(); + productSearchSettingsBuilder + .createProductSetSettings() + .setRetrySettings( + productSearchSettingsBuilder + .createProductSetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductSearchSettings productSearchSettings = productSearchSettingsBuilder.build(); + } +} +// [END vision_v1p3beta1_generated_productsearchsettings_createproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..6644fa4c3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.stub.samples; + +// [START vision_v1p3beta1_generated_imageannotatorstubsettings_batchannotateimages_sync] +import com.google.cloud.vision.v1p3beta1.stub.ImageAnnotatorStubSettings; +import java.time.Duration; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorStubSettings.Builder imageAnnotatorSettingsBuilder = + ImageAnnotatorStubSettings.newBuilder(); + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .setRetrySettings( + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageAnnotatorStubSettings imageAnnotatorSettings = imageAnnotatorSettingsBuilder.build(); + } +} +// [END vision_v1p3beta1_generated_imageannotatorstubsettings_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/stub/productsearchstubsettings/createproductset/SyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/stub/productsearchstubsettings/createproductset/SyncCreateProductSet.java new file mode 100644 index 000000000..0f3638abc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p3beta1/stub/productsearchstubsettings/createproductset/SyncCreateProductSet.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p3beta1.stub.samples; + +// [START vision_v1p3beta1_generated_productsearchstubsettings_createproductset_sync] +import com.google.cloud.vision.v1p3beta1.stub.ProductSearchStubSettings; +import java.time.Duration; + +public class SyncCreateProductSet { + + public static void main(String[] args) throws Exception { + syncCreateProductSet(); + } + + public static void syncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchStubSettings.Builder productSearchSettingsBuilder = + ProductSearchStubSettings.newBuilder(); + productSearchSettingsBuilder + .createProductSetSettings() + .setRetrySettings( + productSearchSettingsBuilder + .createProductSetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductSearchStubSettings productSearchSettings = productSearchSettingsBuilder.build(); + } +} +// [END vision_v1p3beta1_generated_productsearchstubsettings_createproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java new file mode 100644 index 000000000..2596b80d1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFiles.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotatefiles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateFiles(); + } + + public static void asyncAsyncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + ApiFuture future = + imageAnnotatorClient.asyncBatchAnnotateFilesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotatefiles_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java new file mode 100644 index 000000000..b10c0539f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/AsyncAsyncBatchAnnotateFilesLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotatefiles_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.vision.v1p4beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p4beta1.OperationMetadata; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateFilesLRO { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateFilesLRO(); + } + + public static void asyncAsyncBatchAnnotateFilesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + OperationFuture future = + imageAnnotatorClient.asyncBatchAnnotateFilesOperationCallable().futureCall(request); + // Do something. + AsyncBatchAnnotateFilesResponse response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotatefiles_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java new file mode 100644 index 000000000..283f71504 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFiles.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotatefiles_sync] +import com.google.cloud.vision.v1p4beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class SyncAsyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateFiles(); + } + + public static void syncAsyncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateFilesRequest request = + AsyncBatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + AsyncBatchAnnotateFilesResponse response = + imageAnnotatorClient.asyncBatchAnnotateFilesAsync(request).get(); + } + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotatefiles_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java new file mode 100644 index 000000000..cb7448656 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotatefiles/SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotatefiles_listasyncannotatefilerequest_sync] +import com.google.cloud.vision.v1p4beta1.AsyncAnnotateFileRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncAsyncBatchAnnotateFilesListasyncannotatefilerequest { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateFilesListasyncannotatefilerequest(); + } + + public static void syncAsyncBatchAnnotateFilesListasyncannotatefilerequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + AsyncBatchAnnotateFilesResponse response = + imageAnnotatorClient.asyncBatchAnnotateFilesAsync(requests).get(); + } + } +} +// [END +// vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotatefiles_listasyncannotatefilerequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImages.java new file mode 100644 index 000000000..d6c129ea3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImages.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotateimages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p4beta1.OutputConfig; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateImages(); + } + + public static void asyncAsyncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateImagesRequest request = + AsyncBatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .build(); + ApiFuture future = + imageAnnotatorClient.asyncBatchAnnotateImagesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotateimages_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImagesLRO.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImagesLRO.java new file mode 100644 index 000000000..b2a404c11 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/AsyncAsyncBatchAnnotateImagesLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotateimages_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.vision.v1p4beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p4beta1.OperationMetadata; +import com.google.cloud.vision.v1p4beta1.OutputConfig; +import java.util.ArrayList; + +public class AsyncAsyncBatchAnnotateImagesLRO { + + public static void main(String[] args) throws Exception { + asyncAsyncBatchAnnotateImagesLRO(); + } + + public static void asyncAsyncBatchAnnotateImagesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateImagesRequest request = + AsyncBatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .build(); + OperationFuture future = + imageAnnotatorClient.asyncBatchAnnotateImagesOperationCallable().futureCall(request); + // Do something. + AsyncBatchAnnotateImagesResponse response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotateimages_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImages.java new file mode 100644 index 000000000..be053e027 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImages.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotateimages_sync] +import com.google.cloud.vision.v1p4beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p4beta1.OutputConfig; +import java.util.ArrayList; + +public class SyncAsyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateImages(); + } + + public static void syncAsyncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + AsyncBatchAnnotateImagesRequest request = + AsyncBatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .build(); + AsyncBatchAnnotateImagesResponse response = + imageAnnotatorClient.asyncBatchAnnotateImagesAsync(request).get(); + } + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig.java new file mode 100644 index 000000000..5093f76c8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/asyncbatchannotateimages/SyncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotateimages_listannotateimagerequestoutputconfig_sync] +import com.google.cloud.vision.v1p4beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p4beta1.OutputConfig; +import java.util.ArrayList; +import java.util.List; + +public class SyncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig { + + public static void main(String[] args) throws Exception { + syncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig(); + } + + public static void syncAsyncBatchAnnotateImagesListannotateimagerequestOutputconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + AsyncBatchAnnotateImagesResponse response = + imageAnnotatorClient.asyncBatchAnnotateImagesAsync(requests, outputConfig).get(); + } + } +} +// [END +// vision_v1p4beta1_generated_imageannotatorclient_asyncbatchannotateimages_listannotateimagerequestoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotatefiles/AsyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotatefiles/AsyncBatchAnnotateFiles.java new file mode 100644 index 000000000..d713be7a8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotatefiles/AsyncBatchAnnotateFiles.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_batchannotatefiles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.AnnotateFileRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class AsyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + asyncBatchAnnotateFiles(); + } + + public static void asyncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateFilesRequest request = + BatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + ApiFuture future = + imageAnnotatorClient.batchAnnotateFilesCallable().futureCall(request); + // Do something. + BatchAnnotateFilesResponse response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_batchannotatefiles_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFiles.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFiles.java new file mode 100644 index 000000000..81ffcfe75 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFiles.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_batchannotatefiles_sync] +import com.google.cloud.vision.v1p4beta1.AnnotateFileRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class SyncBatchAnnotateFiles { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateFiles(); + } + + public static void syncBatchAnnotateFiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateFilesRequest request = + BatchAnnotateFilesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + BatchAnnotateFilesResponse response = imageAnnotatorClient.batchAnnotateFiles(request); + } + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_batchannotatefiles_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFilesListannotatefilerequest.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFilesListannotatefilerequest.java new file mode 100644 index 000000000..e333d9e36 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotatefiles/SyncBatchAnnotateFilesListannotatefilerequest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_imageannotatorclient_batchannotatefiles_listannotatefilerequest_sync] +import com.google.cloud.vision.v1p4beta1.AnnotateFileRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchAnnotateFilesListannotatefilerequest { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateFilesListannotatefilerequest(); + } + + public static void syncBatchAnnotateFilesListannotatefilerequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + BatchAnnotateFilesResponse response = imageAnnotatorClient.batchAnnotateFiles(requests); + } + } +} +// [END +// vision_v1p4beta1_generated_imageannotatorclient_batchannotatefiles_listannotatefilerequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java new file mode 100644 index 000000000..689119130 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotateimages/AsyncBatchAnnotateImages.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_batchannotateimages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class AsyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + asyncBatchAnnotateImages(); + } + + public static void asyncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateImagesRequest request = + BatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + ApiFuture future = + imageAnnotatorClient.batchAnnotateImagesCallable().futureCall(request); + // Do something. + BatchAnnotateImagesResponse response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_batchannotateimages_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..549285223 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_batchannotateimages_sync] +import com.google.cloud.vision.v1p4beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import java.util.ArrayList; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + BatchAnnotateImagesRequest request = + BatchAnnotateImagesRequest.newBuilder() + .addAllRequests(new ArrayList()) + .build(); + BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(request); + } + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java new file mode 100644 index 000000000..d51b744e5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/batchannotateimages/SyncBatchAnnotateImagesListannotateimagerequest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_imageannotatorclient_batchannotateimages_listannotateimagerequest_sync] +import com.google.cloud.vision.v1p4beta1.AnnotateImageRequest; +import com.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchAnnotateImagesListannotateimagerequest { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImagesListannotateimagerequest(); + } + + public static void syncBatchAnnotateImagesListannotateimagerequest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) { + List requests = new ArrayList<>(); + BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(requests); + } + } +} +// [END +// vision_v1p4beta1_generated_imageannotatorclient_batchannotateimages_listannotateimagerequest_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..02ea14b4a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorSettings; +import com.google.cloud.vision.v1p4beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..a0443d02b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_create_setcredentialsprovider1_sync] +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder() + .setTransportChannelProvider( + ImageAnnotatorSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..01cd71f84 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorclient_create_setendpoint_sync] +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient; +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorSettings; +import com.google.cloud.vision.v1p4beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings imageAnnotatorSettings = + ImageAnnotatorSettings.newBuilder().setEndpoint(myEndpoint).build(); + ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings); + } +} +// [END vision_v1p4beta1_generated_imageannotatorclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..f46a1dedc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/imageannotatorsettings/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_imageannotatorsettings_batchannotateimages_sync] +import com.google.cloud.vision.v1p4beta1.ImageAnnotatorSettings; +import java.time.Duration; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorSettings.Builder imageAnnotatorSettingsBuilder = + ImageAnnotatorSettings.newBuilder(); + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .setRetrySettings( + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageAnnotatorSettings imageAnnotatorSettings = imageAnnotatorSettingsBuilder.build(); + } +} +// [END vision_v1p4beta1_generated_imageannotatorsettings_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/AsyncAddProductToProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/AsyncAddProductToProductSet.java new file mode 100644 index 000000000..838d54f95 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/AsyncAddProductToProductSet.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; +import com.google.protobuf.Empty; + +public class AsyncAddProductToProductSet { + + public static void main(String[] args) throws Exception { + asyncAddProductToProductSet(); + } + + public static void asyncAddProductToProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + AddProductToProductSetRequest request = + AddProductToProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = + productSearchClient.addProductToProductSetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSet.java new file mode 100644 index 000000000..55a74dd24 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSet.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_sync] +import com.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncAddProductToProductSet { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSet(); + } + + public static void syncAddProductToProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + AddProductToProductSetRequest request = + AddProductToProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + productSearchClient.addProductToProductSet(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameProductname.java new file mode 100644 index 000000000..5e5db0cb4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameProductname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_productsetnameproductname_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncAddProductToProductSetProductsetnameProductname { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetProductsetnameProductname(); + } + + public static void syncAddProductToProductSetProductsetnameProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_productsetnameproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameString.java new file mode 100644 index 000000000..7061382e5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetProductsetnameString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_productsetnamestring_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncAddProductToProductSetProductsetnameString { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetProductsetnameString(); + } + + public static void syncAddProductToProductSetProductsetnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_productsetnamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringProductname.java new file mode 100644 index 000000000..6b65870c7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringProductname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_stringproductname_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncAddProductToProductSetStringProductname { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetStringProductname(); + } + + public static void syncAddProductToProductSetStringProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_stringproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringString.java new file mode 100644 index 000000000..e05ad4c60 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/addproducttoproductset/SyncAddProductToProductSetStringString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_stringstring_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncAddProductToProductSetStringString { + + public static void main(String[] args) throws Exception { + syncAddProductToProductSetStringString(); + } + + public static void syncAddProductToProductSetStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.addProductToProductSet(name, product); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_addproducttoproductset_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..a2701e5bd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSearchSettings; +import com.google.cloud.vision.v1p4beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings productSearchSettings = + ProductSearchSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); + } +} +// [END vision_v1p4beta1_generated_productsearchclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..109564889 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_create_setcredentialsprovider1_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSearchSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings productSearchSettings = + ProductSearchSettings.newBuilder() + .setTransportChannelProvider( + ProductSearchSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); + } +} +// [END vision_v1p4beta1_generated_productsearchclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..c165ae58d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_create_setendpoint_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSearchSettings; +import com.google.cloud.vision.v1p4beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings productSearchSettings = + ProductSearchSettings.newBuilder().setEndpoint(myEndpoint).build(); + ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); + } +} +// [END vision_v1p4beta1_generated_productsearchclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/AsyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/AsyncCreateProduct.java new file mode 100644 index 000000000..85344e60b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/AsyncCreateProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_createproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.CreateProductRequest; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class AsyncCreateProduct { + + public static void main(String[] args) throws Exception { + asyncCreateProduct(); + } + + public static void asyncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + ApiFuture future = productSearchClient.createProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_createproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000..533161528 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/SyncCreateProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_createproduct_sync] +import com.google.cloud.vision.v1p4beta1.CreateProductRequest; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + Product response = productSearchClient.createProduct(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/SyncCreateProductLocationnameProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/SyncCreateProductLocationnameProductString.java new file mode 100644 index 000000000..c71a989ae --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/SyncCreateProductLocationnameProductString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_createproduct_locationnameproductstring_sync] +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncCreateProductLocationnameProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductLocationnameProductString(); + } + + public static void syncCreateProductLocationnameProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productSearchClient.createProduct(parent, product, productId); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_createproduct_locationnameproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/SyncCreateProductStringProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/SyncCreateProductStringProductString.java new file mode 100644 index 000000000..a8999f14b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproduct/SyncCreateProductStringProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_createproduct_stringproductstring_sync] +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncCreateProductStringProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductStringProductString(); + } + + public static void syncCreateProductStringProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productSearchClient.createProduct(parent, product, productId); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_createproduct_stringproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/AsyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/AsyncCreateProductSet.java new file mode 100644 index 000000000..f4da457f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/AsyncCreateProductSet.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_createproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.CreateProductSetRequest; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; + +public class AsyncCreateProductSet { + + public static void main(String[] args) throws Exception { + asyncCreateProductSet(); + } + + public static void asyncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductSetRequest request = + CreateProductSetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProductSet(ProductSet.newBuilder().build()) + .setProductSetId("productSetId1003042158") + .build(); + ApiFuture future = + productSearchClient.createProductSetCallable().futureCall(request); + // Do something. + ProductSet response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_createproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/SyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/SyncCreateProductSet.java new file mode 100644 index 000000000..c6535de6b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/SyncCreateProductSet.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_createproductset_sync] +import com.google.cloud.vision.v1p4beta1.CreateProductSetRequest; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; + +public class SyncCreateProductSet { + + public static void main(String[] args) throws Exception { + syncCreateProductSet(); + } + + public static void syncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateProductSetRequest request = + CreateProductSetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setProductSet(ProductSet.newBuilder().build()) + .setProductSetId("productSetId1003042158") + .build(); + ProductSet response = productSearchClient.createProductSet(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_createproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/SyncCreateProductSetLocationnameProductsetString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/SyncCreateProductSetLocationnameProductsetString.java new file mode 100644 index 000000000..d848f64d0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/SyncCreateProductSetLocationnameProductsetString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_createproductset_locationnameproductsetstring_sync] +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; + +public class SyncCreateProductSetLocationnameProductsetString { + + public static void main(String[] args) throws Exception { + syncCreateProductSetLocationnameProductsetString(); + } + + public static void syncCreateProductSetLocationnameProductsetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + ProductSet response = productSearchClient.createProductSet(parent, productSet, productSetId); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_createproductset_locationnameproductsetstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/SyncCreateProductSetStringProductsetString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/SyncCreateProductSetStringProductsetString.java new file mode 100644 index 000000000..b06d27799 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createproductset/SyncCreateProductSetStringProductsetString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_createproductset_stringproductsetstring_sync] +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; + +public class SyncCreateProductSetStringProductsetString { + + public static void main(String[] args) throws Exception { + syncCreateProductSetStringProductsetString(); + } + + public static void syncCreateProductSetStringProductsetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + ProductSet productSet = ProductSet.newBuilder().build(); + String productSetId = "productSetId1003042158"; + ProductSet response = productSearchClient.createProductSet(parent, productSet, productSetId); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_createproductset_stringproductsetstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/AsyncCreateReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/AsyncCreateReferenceImage.java new file mode 100644 index 000000000..a9364a5f9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/AsyncCreateReferenceImage.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_createreferenceimage_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; + +public class AsyncCreateReferenceImage { + + public static void main(String[] args) throws Exception { + asyncCreateReferenceImage(); + } + + public static void asyncCreateReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateReferenceImageRequest request = + CreateReferenceImageRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setReferenceImage(ReferenceImage.newBuilder().build()) + .setReferenceImageId("referenceImageId1224107531") + .build(); + ApiFuture future = + productSearchClient.createReferenceImageCallable().futureCall(request); + // Do something. + ReferenceImage response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_createreferenceimage_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImage.java new file mode 100644 index 000000000..b99ed9a5d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImage.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_createreferenceimage_sync] +import com.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; + +public class SyncCreateReferenceImage { + + public static void main(String[] args) throws Exception { + syncCreateReferenceImage(); + } + + public static void syncCreateReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + CreateReferenceImageRequest request = + CreateReferenceImageRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setReferenceImage(ReferenceImage.newBuilder().build()) + .setReferenceImageId("referenceImageId1224107531") + .build(); + ReferenceImage response = productSearchClient.createReferenceImage(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_createreferenceimage_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageProductnameReferenceimageString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageProductnameReferenceimageString.java new file mode 100644 index 000000000..22cb2f404 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageProductnameReferenceimageString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_createreferenceimage_productnamereferenceimagestring_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; + +public class SyncCreateReferenceImageProductnameReferenceimageString { + + public static void main(String[] args) throws Exception { + syncCreateReferenceImageProductnameReferenceimageString(); + } + + public static void syncCreateReferenceImageProductnameReferenceimageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + ReferenceImage response = + productSearchClient.createReferenceImage(parent, referenceImage, referenceImageId); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_createreferenceimage_productnamereferenceimagestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageStringReferenceimageString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageStringReferenceimageString.java new file mode 100644 index 000000000..e1fb9ea89 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/createreferenceimage/SyncCreateReferenceImageStringReferenceimageString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_createreferenceimage_stringreferenceimagestring_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; + +public class SyncCreateReferenceImageStringReferenceimageString { + + public static void main(String[] args) throws Exception { + syncCreateReferenceImageStringReferenceimageString(); + } + + public static void syncCreateReferenceImageStringReferenceimageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); + String referenceImageId = "referenceImageId1224107531"; + ReferenceImage response = + productSearchClient.createReferenceImage(parent, referenceImage, referenceImageId); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_createreferenceimage_stringreferenceimagestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/AsyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/AsyncDeleteProduct.java new file mode 100644 index 000000000..bae78e483 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/AsyncDeleteProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_deleteproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.DeleteProductRequest; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteProduct { + + public static void main(String[] args) throws Exception { + asyncDeleteProduct(); + } + + public static void asyncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = productSearchClient.deleteProductCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deleteproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/SyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/SyncDeleteProduct.java new file mode 100644 index 000000000..d60d22bfb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/SyncDeleteProduct.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_deleteproduct_sync] +import com.google.cloud.vision.v1p4beta1.DeleteProductRequest; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncDeleteProduct { + + public static void main(String[] args) throws Exception { + syncDeleteProduct(); + } + + public static void syncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + productSearchClient.deleteProduct(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deleteproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/SyncDeleteProductProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/SyncDeleteProductProductname.java new file mode 100644 index 000000000..99017ce7b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/SyncDeleteProductProductname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_deleteproduct_productname_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncDeleteProductProductname { + + public static void main(String[] args) throws Exception { + syncDeleteProductProductname(); + } + + public static void syncDeleteProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.deleteProduct(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deleteproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/SyncDeleteProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/SyncDeleteProductString.java new file mode 100644 index 000000000..4f8eb4a22 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproduct/SyncDeleteProductString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_deleteproduct_string_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncDeleteProductString { + + public static void main(String[] args) throws Exception { + syncDeleteProductString(); + } + + public static void syncDeleteProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.deleteProduct(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deleteproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/AsyncDeleteProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/AsyncDeleteProductSet.java new file mode 100644 index 000000000..5ffb39fda --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/AsyncDeleteProductSet.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_deleteproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.DeleteProductSetRequest; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; +import com.google.protobuf.Empty; + +public class AsyncDeleteProductSet { + + public static void main(String[] args) throws Exception { + asyncDeleteProductSet(); + } + + public static void asyncDeleteProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductSetRequest request = + DeleteProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + ApiFuture future = productSearchClient.deleteProductSetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deleteproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/SyncDeleteProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/SyncDeleteProductSet.java new file mode 100644 index 000000000..9fbc570ca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/SyncDeleteProductSet.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_deleteproductset_sync] +import com.google.cloud.vision.v1p4beta1.DeleteProductSetRequest; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncDeleteProductSet { + + public static void main(String[] args) throws Exception { + syncDeleteProductSet(); + } + + public static void syncDeleteProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteProductSetRequest request = + DeleteProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + productSearchClient.deleteProductSet(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deleteproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/SyncDeleteProductSetProductsetname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/SyncDeleteProductSetProductsetname.java new file mode 100644 index 000000000..8de079d5e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/SyncDeleteProductSetProductsetname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_deleteproductset_productsetname_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncDeleteProductSetProductsetname { + + public static void main(String[] args) throws Exception { + syncDeleteProductSetProductsetname(); + } + + public static void syncDeleteProductSetProductsetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + productSearchClient.deleteProductSet(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deleteproductset_productsetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/SyncDeleteProductSetString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/SyncDeleteProductSetString.java new file mode 100644 index 000000000..4c59169fc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deleteproductset/SyncDeleteProductSetString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_deleteproductset_string_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncDeleteProductSetString { + + public static void main(String[] args) throws Exception { + syncDeleteProductSetString(); + } + + public static void syncDeleteProductSetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + productSearchClient.deleteProductSet(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deleteproductset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/AsyncDeleteReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/AsyncDeleteReferenceImage.java new file mode 100644 index 000000000..f417327c0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/AsyncDeleteReferenceImage.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_deletereferenceimage_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImageName; +import com.google.protobuf.Empty; + +public class AsyncDeleteReferenceImage { + + public static void main(String[] args) throws Exception { + asyncDeleteReferenceImage(); + } + + public static void asyncDeleteReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteReferenceImageRequest request = + DeleteReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + ApiFuture future = + productSearchClient.deleteReferenceImageCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deletereferenceimage_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImage.java new file mode 100644 index 000000000..b7d0a14e9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImage.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_deletereferenceimage_sync] +import com.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImageName; + +public class SyncDeleteReferenceImage { + + public static void main(String[] args) throws Exception { + syncDeleteReferenceImage(); + } + + public static void syncDeleteReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + DeleteReferenceImageRequest request = + DeleteReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + productSearchClient.deleteReferenceImage(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deletereferenceimage_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageReferenceimagename.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageReferenceimagename.java new file mode 100644 index 000000000..fe58521e7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageReferenceimagename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_deletereferenceimage_referenceimagename_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImageName; + +public class SyncDeleteReferenceImageReferenceimagename { + + public static void main(String[] args) throws Exception { + syncDeleteReferenceImageReferenceimagename(); + } + + public static void syncDeleteReferenceImageReferenceimagename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + productSearchClient.deleteReferenceImage(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deletereferenceimage_referenceimagename_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageString.java new file mode 100644 index 000000000..fc0c0f3f7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/deletereferenceimage/SyncDeleteReferenceImageString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_deletereferenceimage_string_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImageName; + +public class SyncDeleteReferenceImageString { + + public static void main(String[] args) throws Exception { + syncDeleteReferenceImageString(); + } + + public static void syncDeleteReferenceImageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString(); + productSearchClient.deleteReferenceImage(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_deletereferenceimage_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/AsyncGetProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/AsyncGetProduct.java new file mode 100644 index 000000000..0d121f430 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/AsyncGetProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.GetProductRequest; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class AsyncGetProduct { + + public static void main(String[] args) throws Exception { + asyncGetProduct(); + } + + public static void asyncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = productSearchClient.getProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/SyncGetProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/SyncGetProduct.java new file mode 100644 index 000000000..dcea1eff6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/SyncGetProduct.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getproduct_sync] +import com.google.cloud.vision.v1p4beta1.GetProductRequest; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncGetProduct { + + public static void main(String[] args) throws Exception { + syncGetProduct(); + } + + public static void syncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + Product response = productSearchClient.getProduct(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/SyncGetProductProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/SyncGetProductProductname.java new file mode 100644 index 000000000..130ff7a41 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/SyncGetProductProductname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getproduct_productname_sync] +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncGetProductProductname { + + public static void main(String[] args) throws Exception { + syncGetProductProductname(); + } + + public static void syncGetProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + Product response = productSearchClient.getProduct(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/SyncGetProductString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/SyncGetProductString.java new file mode 100644 index 000000000..b706b29bd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproduct/SyncGetProductString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getproduct_string_sync] +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncGetProductString { + + public static void main(String[] args) throws Exception { + syncGetProductString(); + } + + public static void syncGetProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + Product response = productSearchClient.getProduct(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/AsyncGetProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/AsyncGetProductSet.java new file mode 100644 index 000000000..130745414 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/AsyncGetProductSet.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.GetProductSetRequest; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class AsyncGetProductSet { + + public static void main(String[] args) throws Exception { + asyncGetProductSet(); + } + + public static void asyncGetProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductSetRequest request = + GetProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + ApiFuture future = + productSearchClient.getProductSetCallable().futureCall(request); + // Do something. + ProductSet response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/SyncGetProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/SyncGetProductSet.java new file mode 100644 index 000000000..b065d9e44 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/SyncGetProductSet.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getproductset_sync] +import com.google.cloud.vision.v1p4beta1.GetProductSetRequest; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncGetProductSet { + + public static void main(String[] args) throws Exception { + syncGetProductSet(); + } + + public static void syncGetProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetProductSetRequest request = + GetProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .build(); + ProductSet response = productSearchClient.getProductSet(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/SyncGetProductSetProductsetname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/SyncGetProductSetProductsetname.java new file mode 100644 index 000000000..7f66c9924 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/SyncGetProductSetProductsetname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getproductset_productsetname_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncGetProductSetProductsetname { + + public static void main(String[] args) throws Exception { + syncGetProductSetProductsetname(); + } + + public static void syncGetProductSetProductsetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductSet response = productSearchClient.getProductSet(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getproductset_productsetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/SyncGetProductSetString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/SyncGetProductSetString.java new file mode 100644 index 000000000..4e19e808d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getproductset/SyncGetProductSetString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getproductset_string_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncGetProductSetString { + + public static void main(String[] args) throws Exception { + syncGetProductSetString(); + } + + public static void syncGetProductSetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + ProductSet response = productSearchClient.getProductSet(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getproductset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/AsyncGetReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/AsyncGetReferenceImage.java new file mode 100644 index 000000000..65201b35c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/AsyncGetReferenceImage.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getreferenceimage_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.GetReferenceImageRequest; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; +import com.google.cloud.vision.v1p4beta1.ReferenceImageName; + +public class AsyncGetReferenceImage { + + public static void main(String[] args) throws Exception { + asyncGetReferenceImage(); + } + + public static void asyncGetReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetReferenceImageRequest request = + GetReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + ApiFuture future = + productSearchClient.getReferenceImageCallable().futureCall(request); + // Do something. + ReferenceImage response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getreferenceimage_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/SyncGetReferenceImage.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/SyncGetReferenceImage.java new file mode 100644 index 000000000..f75422433 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/SyncGetReferenceImage.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getreferenceimage_sync] +import com.google.cloud.vision.v1p4beta1.GetReferenceImageRequest; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; +import com.google.cloud.vision.v1p4beta1.ReferenceImageName; + +public class SyncGetReferenceImage { + + public static void main(String[] args) throws Exception { + syncGetReferenceImage(); + } + + public static void syncGetReferenceImage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + GetReferenceImageRequest request = + GetReferenceImageRequest.newBuilder() + .setName( + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString()) + .build(); + ReferenceImage response = productSearchClient.getReferenceImage(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getreferenceimage_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageReferenceimagename.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageReferenceimagename.java new file mode 100644 index 000000000..e8acc4896 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageReferenceimagename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getreferenceimage_referenceimagename_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; +import com.google.cloud.vision.v1p4beta1.ReferenceImageName; + +public class SyncGetReferenceImageReferenceimagename { + + public static void main(String[] args) throws Exception { + syncGetReferenceImageReferenceimagename(); + } + + public static void syncGetReferenceImageReferenceimagename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ReferenceImageName name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); + ReferenceImage response = productSearchClient.getReferenceImage(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getreferenceimage_referenceimagename_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageString.java new file mode 100644 index 000000000..2376fe134 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/getreferenceimage/SyncGetReferenceImageString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_getreferenceimage_string_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; +import com.google.cloud.vision.v1p4beta1.ReferenceImageName; + +public class SyncGetReferenceImageString { + + public static void main(String[] args) throws Exception { + syncGetReferenceImageString(); + } + + public static void syncGetReferenceImageString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = + ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") + .toString(); + ReferenceImage response = productSearchClient.getReferenceImage(name); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_getreferenceimage_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/AsyncImportProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/AsyncImportProductSets.java new file mode 100644 index 000000000..6d0572e5f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/AsyncImportProductSets.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_importproductsets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1p4beta1.ImportProductSetsRequest; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.longrunning.Operation; + +public class AsyncImportProductSets { + + public static void main(String[] args) throws Exception { + asyncImportProductSets(); + } + + public static void asyncImportProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ImportProductSetsRequest request = + ImportProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) + .build(); + ApiFuture future = + productSearchClient.importProductSetsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_importproductsets_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/AsyncImportProductSetsLRO.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/AsyncImportProductSetsLRO.java new file mode 100644 index 000000000..e661950aa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/AsyncImportProductSetsLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_importproductsets_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.vision.v1p4beta1.BatchOperationMetadata; +import com.google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1p4beta1.ImportProductSetsRequest; +import com.google.cloud.vision.v1p4beta1.ImportProductSetsResponse; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class AsyncImportProductSetsLRO { + + public static void main(String[] args) throws Exception { + asyncImportProductSetsLRO(); + } + + public static void asyncImportProductSetsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ImportProductSetsRequest request = + ImportProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) + .build(); + OperationFuture future = + productSearchClient.importProductSetsOperationCallable().futureCall(request); + // Do something. + ImportProductSetsResponse response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_importproductsets_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/SyncImportProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/SyncImportProductSets.java new file mode 100644 index 000000000..84ab57aaf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/SyncImportProductSets.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_importproductsets_sync] +import com.google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1p4beta1.ImportProductSetsRequest; +import com.google.cloud.vision.v1p4beta1.ImportProductSetsResponse; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncImportProductSets { + + public static void main(String[] args) throws Exception { + syncImportProductSets(); + } + + public static void syncImportProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ImportProductSetsRequest request = + ImportProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) + .build(); + ImportProductSetsResponse response = + productSearchClient.importProductSetsAsync(request).get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_importproductsets_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/SyncImportProductSetsLocationnameImportproductsetsinputconfig.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/SyncImportProductSetsLocationnameImportproductsetsinputconfig.java new file mode 100644 index 000000000..140afdb15 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/SyncImportProductSetsLocationnameImportproductsetsinputconfig.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_importproductsets_locationnameimportproductsetsinputconfig_sync] +import com.google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1p4beta1.ImportProductSetsResponse; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncImportProductSetsLocationnameImportproductsetsinputconfig { + + public static void main(String[] args) throws Exception { + syncImportProductSetsLocationnameImportproductsetsinputconfig(); + } + + public static void syncImportProductSetsLocationnameImportproductsetsinputconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + ImportProductSetsResponse response = + productSearchClient.importProductSetsAsync(parent, inputConfig).get(); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_importproductsets_locationnameimportproductsetsinputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/SyncImportProductSetsStringImportproductsetsinputconfig.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/SyncImportProductSetsStringImportproductsetsinputconfig.java new file mode 100644 index 000000000..7a453aaf7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/importproductsets/SyncImportProductSetsStringImportproductsetsinputconfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_importproductsets_stringimportproductsetsinputconfig_sync] +import com.google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig; +import com.google.cloud.vision.v1p4beta1.ImportProductSetsResponse; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncImportProductSetsStringImportproductsetsinputconfig { + + public static void main(String[] args) throws Exception { + syncImportProductSetsStringImportproductsetsinputconfig(); + } + + public static void syncImportProductSetsStringImportproductsetsinputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); + ImportProductSetsResponse response = + productSearchClient.importProductSetsAsync(parent, inputConfig).get(); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_importproductsets_stringimportproductsetsinputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/AsyncListProducts.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/AsyncListProducts.java new file mode 100644 index 000000000..6f2e1d85f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/AsyncListProducts.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.ListProductsRequest; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class AsyncListProducts { + + public static void main(String[] args) throws Exception { + asyncListProducts(); + } + + public static void asyncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listProductsPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/AsyncListProductsPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/AsyncListProductsPaged.java new file mode 100644 index 000000000..5acf5b3ff --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/AsyncListProductsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproducts_paged_async] +import com.google.cloud.vision.v1p4beta1.ListProductsRequest; +import com.google.cloud.vision.v1p4beta1.ListProductsResponse; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.common.base.Strings; + +public class AsyncListProductsPaged { + + public static void main(String[] args) throws Exception { + asyncListProductsPaged(); + } + + public static void asyncListProductsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListProductsResponse response = productSearchClient.listProductsCallable().call(request); + for (Product element : response.getProductsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproducts_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/SyncListProducts.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/SyncListProducts.java new file mode 100644 index 000000000..7b25981bf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/SyncListProducts.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproducts_sync] +import com.google.cloud.vision.v1p4beta1.ListProductsRequest; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncListProducts { + + public static void main(String[] args) throws Exception { + syncListProducts(); + } + + public static void syncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Product element : productSearchClient.listProducts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/SyncListProductsLocationname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/SyncListProductsLocationname.java new file mode 100644 index 000000000..5a402b105 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/SyncListProductsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproducts_locationname_sync] +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncListProductsLocationname { + + public static void main(String[] args) throws Exception { + syncListProductsLocationname(); + } + + public static void syncListProductsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Product element : productSearchClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproducts_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/SyncListProductsString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/SyncListProductsString.java new file mode 100644 index 000000000..cc09a44b0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproducts/SyncListProductsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproducts_string_sync] +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncListProductsString { + + public static void main(String[] args) throws Exception { + syncListProductsString(); + } + + public static void syncListProductsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Product element : productSearchClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproducts_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/AsyncListProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/AsyncListProductSets.java new file mode 100644 index 000000000..172d2b21a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/AsyncListProductSets.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproductsets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.ListProductSetsRequest; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; + +public class AsyncListProductSets { + + public static void main(String[] args) throws Exception { + asyncListProductSets(); + } + + public static void asyncListProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductSetsRequest request = + ListProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listProductSetsPagedCallable().futureCall(request); + // Do something. + for (ProductSet element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproductsets_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/AsyncListProductSetsPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/AsyncListProductSetsPaged.java new file mode 100644 index 000000000..09b0aee98 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/AsyncListProductSetsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproductsets_paged_async] +import com.google.cloud.vision.v1p4beta1.ListProductSetsRequest; +import com.google.cloud.vision.v1p4beta1.ListProductSetsResponse; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; +import com.google.common.base.Strings; + +public class AsyncListProductSetsPaged { + + public static void main(String[] args) throws Exception { + asyncListProductSetsPaged(); + } + + public static void asyncListProductSetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductSetsRequest request = + ListProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListProductSetsResponse response = + productSearchClient.listProductSetsCallable().call(request); + for (ProductSet element : response.getProductSetsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproductsets_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/SyncListProductSets.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/SyncListProductSets.java new file mode 100644 index 000000000..6f932ba1f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/SyncListProductSets.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproductsets_sync] +import com.google.cloud.vision.v1p4beta1.ListProductSetsRequest; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; + +public class SyncListProductSets { + + public static void main(String[] args) throws Exception { + syncListProductSets(); + } + + public static void syncListProductSets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductSetsRequest request = + ListProductSetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ProductSet element : productSearchClient.listProductSets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproductsets_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/SyncListProductSetsLocationname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/SyncListProductSetsLocationname.java new file mode 100644 index 000000000..2508f3fe0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/SyncListProductSetsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproductsets_locationname_sync] +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; + +public class SyncListProductSetsLocationname { + + public static void main(String[] args) throws Exception { + syncListProductSetsLocationname(); + } + + public static void syncListProductSetsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (ProductSet element : productSearchClient.listProductSets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproductsets_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/SyncListProductSetsString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/SyncListProductSetsString.java new file mode 100644 index 000000000..7232271a9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsets/SyncListProductSetsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproductsets_string_sync] +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; + +public class SyncListProductSetsString { + + public static void main(String[] args) throws Exception { + syncListProductSetsString(); + } + + public static void syncListProductSetsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (ProductSet element : productSearchClient.listProductSets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproductsets_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSet.java new file mode 100644 index 000000000..98128e626 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSet.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproductsinproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class AsyncListProductsInProductSet { + + public static void main(String[] args) throws Exception { + asyncListProductsInProductSet(); + } + + public static void asyncListProductsInProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsInProductSetRequest request = + ListProductsInProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listProductsInProductSetPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproductsinproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSetPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSetPaged.java new file mode 100644 index 000000000..c91fe9d48 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/AsyncListProductsInProductSetPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproductsinproductset_paged_async] +import com.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1p4beta1.ListProductsInProductSetResponse; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; +import com.google.common.base.Strings; + +public class AsyncListProductsInProductSetPaged { + + public static void main(String[] args) throws Exception { + asyncListProductsInProductSetPaged(); + } + + public static void asyncListProductsInProductSetPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsInProductSetRequest request = + ListProductsInProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListProductsInProductSetResponse response = + productSearchClient.listProductsInProductSetCallable().call(request); + for (Product element : response.getProductsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproductsinproductset_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSet.java new file mode 100644 index 000000000..d13a297e4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSet.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproductsinproductset_sync] +import com.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncListProductsInProductSet { + + public static void main(String[] args) throws Exception { + syncListProductsInProductSet(); + } + + public static void syncListProductsInProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListProductsInProductSetRequest request = + ListProductsInProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Product element : productSearchClient.listProductsInProductSet(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproductsinproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetProductsetname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetProductsetname.java new file mode 100644 index 000000000..1fa2f5ed4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetProductsetname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_listproductsinproductset_productsetname_sync] +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncListProductsInProductSetProductsetname { + + public static void main(String[] args) throws Exception { + syncListProductsInProductSetProductsetname(); + } + + public static void syncListProductsInProductSetProductsetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + for (Product element : productSearchClient.listProductsInProductSet(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproductsinproductset_productsetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetString.java new file mode 100644 index 000000000..6e5e6a229 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listproductsinproductset/SyncListProductsInProductSetString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listproductsinproductset_string_sync] +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncListProductsInProductSetString { + + public static void main(String[] args) throws Exception { + syncListProductsInProductSetString(); + } + + public static void syncListProductsInProductSetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + for (Product element : productSearchClient.listProductsInProductSet(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listproductsinproductset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/AsyncListReferenceImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/AsyncListReferenceImages.java new file mode 100644 index 000000000..d61caad10 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/AsyncListReferenceImages.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listreferenceimages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; + +public class AsyncListReferenceImages { + + public static void main(String[] args) throws Exception { + asyncListReferenceImages(); + } + + public static void asyncListReferenceImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListReferenceImagesRequest request = + ListReferenceImagesRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + productSearchClient.listReferenceImagesPagedCallable().futureCall(request); + // Do something. + for (ReferenceImage element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listreferenceimages_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/AsyncListReferenceImagesPaged.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/AsyncListReferenceImagesPaged.java new file mode 100644 index 000000000..b15ff7d57 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/AsyncListReferenceImagesPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listreferenceimages_paged_async] +import com.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1p4beta1.ListReferenceImagesResponse; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; +import com.google.common.base.Strings; + +public class AsyncListReferenceImagesPaged { + + public static void main(String[] args) throws Exception { + asyncListReferenceImagesPaged(); + } + + public static void asyncListReferenceImagesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListReferenceImagesRequest request = + ListReferenceImagesRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListReferenceImagesResponse response = + productSearchClient.listReferenceImagesCallable().call(request); + for (ReferenceImage element : response.getReferenceImagesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listreferenceimages_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/SyncListReferenceImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/SyncListReferenceImages.java new file mode 100644 index 000000000..3cf83c282 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/SyncListReferenceImages.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listreferenceimages_sync] +import com.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; + +public class SyncListReferenceImages { + + public static void main(String[] args) throws Exception { + syncListReferenceImages(); + } + + public static void syncListReferenceImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ListReferenceImagesRequest request = + ListReferenceImagesRequest.newBuilder() + .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ReferenceImage element : productSearchClient.listReferenceImages(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listreferenceimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesProductname.java new file mode 100644 index 000000000..299de5115 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listreferenceimages_productname_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; + +public class SyncListReferenceImagesProductname { + + public static void main(String[] args) throws Exception { + syncListReferenceImagesProductname(); + } + + public static void syncListReferenceImagesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + for (ReferenceImage element : productSearchClient.listReferenceImages(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listreferenceimages_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesString.java new file mode 100644 index 000000000..d4d9145d8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/listreferenceimages/SyncListReferenceImagesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_listreferenceimages_string_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ReferenceImage; + +public class SyncListReferenceImagesString { + + public static void main(String[] args) throws Exception { + syncListReferenceImagesString(); + } + + public static void syncListReferenceImagesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + for (ReferenceImage element : productSearchClient.listReferenceImages(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_listreferenceimages_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/AsyncPurgeProducts.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/AsyncPurgeProducts.java new file mode 100644 index 000000000..cdbb5087c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/AsyncPurgeProducts.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_purgeproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.PurgeProductsRequest; +import com.google.longrunning.Operation; + +public class AsyncPurgeProducts { + + public static void main(String[] args) throws Exception { + asyncPurgeProducts(); + } + + public static void asyncPurgeProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setForce(true) + .build(); + ApiFuture future = productSearchClient.purgeProductsCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_purgeproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/AsyncPurgeProductsLRO.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/AsyncPurgeProductsLRO.java new file mode 100644 index 000000000..5ff406276 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/AsyncPurgeProductsLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_purgeproducts_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.vision.v1p4beta1.BatchOperationMetadata; +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.PurgeProductsRequest; +import com.google.protobuf.Empty; + +public class AsyncPurgeProductsLRO { + + public static void main(String[] args) throws Exception { + asyncPurgeProductsLRO(); + } + + public static void asyncPurgeProductsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setForce(true) + .build(); + OperationFuture future = + productSearchClient.purgeProductsOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_purgeproducts_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/SyncPurgeProducts.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/SyncPurgeProducts.java new file mode 100644 index 000000000..c400cdab0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/SyncPurgeProducts.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_purgeproducts_sync] +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.PurgeProductsRequest; + +public class SyncPurgeProducts { + + public static void main(String[] args) throws Exception { + syncPurgeProducts(); + } + + public static void syncPurgeProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setForce(true) + .build(); + productSearchClient.purgeProductsAsync(request).get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_purgeproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/SyncPurgeProductsLocationname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/SyncPurgeProductsLocationname.java new file mode 100644 index 000000000..53e829480 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/SyncPurgeProductsLocationname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_purgeproducts_locationname_sync] +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncPurgeProductsLocationname { + + public static void main(String[] args) throws Exception { + syncPurgeProductsLocationname(); + } + + public static void syncPurgeProductsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + productSearchClient.purgeProductsAsync(parent).get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_purgeproducts_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/SyncPurgeProductsString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/SyncPurgeProductsString.java new file mode 100644 index 000000000..ad560a744 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/purgeproducts/SyncPurgeProductsString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_purgeproducts_string_sync] +import com.google.cloud.vision.v1p4beta1.LocationName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; + +public class SyncPurgeProductsString { + + public static void main(String[] args) throws Exception { + syncPurgeProductsString(); + } + + public static void syncPurgeProductsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + productSearchClient.purgeProductsAsync(parent).get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_purgeproducts_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/AsyncRemoveProductFromProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/AsyncRemoveProductFromProductSet.java new file mode 100644 index 000000000..15664749d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/AsyncRemoveProductFromProductSet.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; +import com.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest; +import com.google.protobuf.Empty; + +public class AsyncRemoveProductFromProductSet { + + public static void main(String[] args) throws Exception { + asyncRemoveProductFromProductSet(); + } + + public static void asyncRemoveProductFromProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + RemoveProductFromProductSetRequest request = + RemoveProductFromProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + ApiFuture future = + productSearchClient.removeProductFromProductSetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSet.java new file mode 100644 index 000000000..2265378c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSet.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; +import com.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest; + +public class SyncRemoveProductFromProductSet { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSet(); + } + + public static void syncRemoveProductFromProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + RemoveProductFromProductSetRequest request = + RemoveProductFromProductSetRequest.newBuilder() + .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) + .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) + .build(); + productSearchClient.removeProductFromProductSet(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameProductname.java new file mode 100644 index 000000000..cf8b97a43 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameProductname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_productsetnameproductname_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncRemoveProductFromProductSetProductsetnameProductname { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetProductsetnameProductname(); + } + + public static void syncRemoveProductFromProductSetProductsetnameProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_productsetnameproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameString.java new file mode 100644 index 000000000..3a8bf678b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetProductsetnameString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_productsetnamestring_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncRemoveProductFromProductSetProductsetnameString { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetProductsetnameString(); + } + + public static void syncRemoveProductFromProductSetProductsetnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_productsetnamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringProductname.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringProductname.java new file mode 100644 index 000000000..759e42c30 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringProductname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_stringproductname_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncRemoveProductFromProductSetStringProductname { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetStringProductname(); + } + + public static void syncRemoveProductFromProductSetStringProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_stringproductname_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringString.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringString.java new file mode 100644 index 000000000..80d75a821 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/removeproductfromproductset/SyncRemoveProductFromProductSetStringString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START +// vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_stringstring_sync] +import com.google.cloud.vision.v1p4beta1.ProductName; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSetName; + +public class SyncRemoveProductFromProductSetStringString { + + public static void main(String[] args) throws Exception { + syncRemoveProductFromProductSetStringString(); + } + + public static void syncRemoveProductFromProductSetStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); + String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); + productSearchClient.removeProductFromProductSet(name, product); + } + } +} +// [END +// vision_v1p4beta1_generated_productsearchclient_removeproductfromproductset_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproduct/AsyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproduct/AsyncUpdateProduct.java new file mode 100644 index 000000000..2f30feee9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproduct/AsyncUpdateProduct.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_updateproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateProduct { + + public static void main(String[] args) throws Exception { + asyncUpdateProduct(); + } + + public static void asyncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = productSearchClient.updateProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_updateproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproduct/SyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproduct/SyncUpdateProduct.java new file mode 100644 index 000000000..d3c9c1c63 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproduct/SyncUpdateProduct.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_updateproduct_sync] +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProduct { + + public static void main(String[] args) throws Exception { + syncUpdateProduct(); + } + + public static void syncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Product response = productSearchClient.updateProduct(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_updateproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproduct/SyncUpdateProductProductFieldmask.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproduct/SyncUpdateProductProductFieldmask.java new file mode 100644 index 000000000..d8de09474 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproduct/SyncUpdateProductProductFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_updateproduct_productfieldmask_sync] +import com.google.cloud.vision.v1p4beta1.Product; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductProductFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateProductProductFieldmask(); + } + + public static void syncUpdateProductProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + Product product = Product.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Product response = productSearchClient.updateProduct(product, updateMask); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_updateproduct_productfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproductset/AsyncUpdateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproductset/AsyncUpdateProductSet.java new file mode 100644 index 000000000..ed2ebd5e8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproductset/AsyncUpdateProductSet.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_updateproductset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; +import com.google.cloud.vision.v1p4beta1.UpdateProductSetRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateProductSet { + + public static void main(String[] args) throws Exception { + asyncUpdateProductSet(); + } + + public static void asyncUpdateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductSetRequest request = + UpdateProductSetRequest.newBuilder() + .setProductSet(ProductSet.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + productSearchClient.updateProductSetCallable().futureCall(request); + // Do something. + ProductSet response = future.get(); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_updateproductset_async] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproductset/SyncUpdateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproductset/SyncUpdateProductSet.java new file mode 100644 index 000000000..62fcb9362 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproductset/SyncUpdateProductSet.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_updateproductset_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; +import com.google.cloud.vision.v1p4beta1.UpdateProductSetRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductSet { + + public static void main(String[] args) throws Exception { + syncUpdateProductSet(); + } + + public static void syncUpdateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + UpdateProductSetRequest request = + UpdateProductSetRequest.newBuilder() + .setProductSet(ProductSet.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ProductSet response = productSearchClient.updateProductSet(request); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_updateproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproductset/SyncUpdateProductSetProductsetFieldmask.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproductset/SyncUpdateProductSetProductsetFieldmask.java new file mode 100644 index 000000000..f363755ca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchclient/updateproductset/SyncUpdateProductSetProductsetFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchclient_updateproductset_productsetfieldmask_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchClient; +import com.google.cloud.vision.v1p4beta1.ProductSet; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductSetProductsetFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateProductSetProductsetFieldmask(); + } + + public static void syncUpdateProductSetProductsetFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { + ProductSet productSet = ProductSet.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ProductSet response = productSearchClient.updateProductSet(productSet, updateMask); + } + } +} +// [END vision_v1p4beta1_generated_productsearchclient_updateproductset_productsetfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchsettings/createproductset/SyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchsettings/createproductset/SyncCreateProductSet.java new file mode 100644 index 000000000..1abe83dff --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/productsearchsettings/createproductset/SyncCreateProductSet.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.samples; + +// [START vision_v1p4beta1_generated_productsearchsettings_createproductset_sync] +import com.google.cloud.vision.v1p4beta1.ProductSearchSettings; +import java.time.Duration; + +public class SyncCreateProductSet { + + public static void main(String[] args) throws Exception { + syncCreateProductSet(); + } + + public static void syncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchSettings.Builder productSearchSettingsBuilder = ProductSearchSettings.newBuilder(); + productSearchSettingsBuilder + .createProductSetSettings() + .setRetrySettings( + productSearchSettingsBuilder + .createProductSetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductSearchSettings productSearchSettings = productSearchSettingsBuilder.build(); + } +} +// [END vision_v1p4beta1_generated_productsearchsettings_createproductset_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java new file mode 100644 index 000000000..8d3d27807 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/stub/imageannotatorstubsettings/batchannotateimages/SyncBatchAnnotateImages.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.stub.samples; + +// [START vision_v1p4beta1_generated_imageannotatorstubsettings_batchannotateimages_sync] +import com.google.cloud.vision.v1p4beta1.stub.ImageAnnotatorStubSettings; +import java.time.Duration; + +public class SyncBatchAnnotateImages { + + public static void main(String[] args) throws Exception { + syncBatchAnnotateImages(); + } + + public static void syncBatchAnnotateImages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageAnnotatorStubSettings.Builder imageAnnotatorSettingsBuilder = + ImageAnnotatorStubSettings.newBuilder(); + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .setRetrySettings( + imageAnnotatorSettingsBuilder + .batchAnnotateImagesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageAnnotatorStubSettings imageAnnotatorSettings = imageAnnotatorSettingsBuilder.build(); + } +} +// [END vision_v1p4beta1_generated_imageannotatorstubsettings_batchannotateimages_sync] diff --git a/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/stub/productsearchstubsettings/createproductset/SyncCreateProductSet.java b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/stub/productsearchstubsettings/createproductset/SyncCreateProductSet.java new file mode 100644 index 000000000..35837206f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vision/v1p4beta1/stub/productsearchstubsettings/createproductset/SyncCreateProductSet.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vision.v1p4beta1.stub.samples; + +// [START vision_v1p4beta1_generated_productsearchstubsettings_createproductset_sync] +import com.google.cloud.vision.v1p4beta1.stub.ProductSearchStubSettings; +import java.time.Duration; + +public class SyncCreateProductSet { + + public static void main(String[] args) throws Exception { + syncCreateProductSet(); + } + + public static void syncCreateProductSet() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductSearchStubSettings.Builder productSearchSettingsBuilder = + ProductSearchStubSettings.newBuilder(); + productSearchSettingsBuilder + .createProductSetSettings() + .setRetrySettings( + productSearchSettingsBuilder + .createProductSetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductSearchStubSettings productSearchSettings = productSearchSettingsBuilder.build(); + } +} +// [END vision_v1p4beta1_generated_productsearchstubsettings_createproductset_sync]