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