diff --git a/README.md b/README.md index 9ccf8020..bb0be0e3 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,13 @@ If you are using Maven, add this to your pom.xml file: If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-retail:2.2.3' +implementation 'com.google.cloud:google-cloud-retail:2.2.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-retail" % "2.2.3" +libraryDependencies += "com.google.cloud" % "google-cloud-retail" % "2.2.4" ``` ## Authentication diff --git a/google-cloud-retail/pom.xml b/google-cloud-retail/pom.xml index 00c7a307..eb623472 100644 --- a/google-cloud-retail/pom.xml +++ b/google-cloud-retail/pom.xml @@ -65,6 +65,10 @@ com.google.api gax-grpc + + + com.google.api + gax-httpjson org.threeten @@ -95,12 +99,24 @@ test + + 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-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceClient.java index 9bfd5a37..862bd411 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceClient.java @@ -99,6 +99,20 @@ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); * } * + *

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.
+ * CatalogServiceSettings catalogServiceSettings =
+ *     CatalogServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceSettings.java index c4ae476d..6abdbf47 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceSettings.java @@ -23,6 +23,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; @@ -119,11 +120,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CatalogServiceStubSettings.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 CatalogServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CatalogServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CatalogServiceStubSettings.defaultTransportChannelProvider(); } @@ -133,11 +141,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CatalogServiceStubSettings.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); @@ -175,6 +189,11 @@ private static Builder createDefault() { return new Builder(CatalogServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CatalogServiceStubSettings.newHttpJsonBuilder()); + } + public CatalogServiceStubSettings.Builder getStubSettingsBuilder() { return ((CatalogServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceClient.java index 532803e6..343a7699 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceClient.java @@ -17,13 +17,13 @@ package com.google.cloud.retail.v2; 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.retail.v2.stub.CompletionServiceStub; import com.google.cloud.retail.v2.stub.CompletionServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -107,13 +107,29 @@ * CompletionServiceClient.create(completionServiceSettings); * } * + *

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.
+ * CompletionServiceSettings completionServiceSettings =
+ *     CompletionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CompletionServiceClient completionServiceClient =
+ *     CompletionServiceClient.create(completionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class CompletionServiceClient implements BackgroundResource { private final CompletionServiceSettings settings; private final CompletionServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of CompletionServiceClient with default settings. */ public static final CompletionServiceClient create() throws IOException { @@ -145,13 +161,17 @@ public static final CompletionServiceClient create(CompletionServiceStub stub) { protected CompletionServiceClient(CompletionServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((CompletionServiceStubSettings) 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()); } protected CompletionServiceClient(CompletionServiceStub 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 CompletionServiceSettings getSettings() { @@ -166,10 +186,18 @@ public CompletionServiceStub 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. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Completes the specified prefix with keyword suggestions. diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceSettings.java index af4c1485..8eec040c 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceSettings.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; @@ -113,11 +114,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CompletionServiceStubSettings.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 CompletionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CompletionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CompletionServiceStubSettings.defaultTransportChannelProvider(); } @@ -127,11 +135,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CompletionServiceStubSettings.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); @@ -169,6 +183,11 @@ private static Builder createDefault() { return new Builder(CompletionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CompletionServiceStubSettings.newHttpJsonBuilder()); + } + public CompletionServiceStubSettings.Builder getStubSettingsBuilder() { return ((CompletionServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceClient.java index e29e8711..6562b4e8 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceClient.java @@ -101,6 +101,21 @@ * PredictionServiceClient.create(predictionServiceSettings); * } * + *

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.
+ * PredictionServiceSettings predictionServiceSettings =
+ *     PredictionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * PredictionServiceClient predictionServiceClient =
+ *     PredictionServiceClient.create(predictionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceSettings.java index acd28f39..0213704f 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceSettings.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; @@ -98,11 +99,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return PredictionServiceStubSettings.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 PredictionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return PredictionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return PredictionServiceStubSettings.defaultTransportChannelProvider(); } @@ -112,11 +120,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return PredictionServiceStubSettings.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); @@ -154,6 +168,11 @@ private static Builder createDefault() { return new Builder(PredictionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(PredictionServiceStubSettings.newHttpJsonBuilder()); + } + public PredictionServiceStubSettings.Builder getStubSettingsBuilder() { return ((PredictionServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceClient.java index cc9e7a2a..a97dbdb6 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; 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; @@ -30,7 +31,6 @@ import com.google.cloud.retail.v2.stub.ProductServiceStubSettings; 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; @@ -105,13 +105,28 @@ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); * } * + *

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.
+ * ProductServiceSettings productServiceSettings =
+ *     ProductServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ProductServiceClient implements BackgroundResource { private final ProductServiceSettings settings; private final ProductServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ProductServiceClient with default settings. */ public static final ProductServiceClient create() throws IOException { @@ -143,13 +158,17 @@ public static final ProductServiceClient create(ProductServiceStub stub) { protected ProductServiceClient(ProductServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((ProductServiceStubSettings) 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()); } protected ProductServiceClient(ProductServiceStub 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 ProductServiceSettings getSettings() { @@ -164,10 +183,18 @@ public ProductServiceStub 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. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a [Product][google.cloud.retail.v2.Product]. diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceSettings.java index 8e4f742f..246c88c4 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceSettings.java @@ -23,6 +23,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; @@ -203,11 +204,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ProductServiceStubSettings.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 ProductServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ProductServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ProductServiceStubSettings.defaultTransportChannelProvider(); } @@ -217,11 +225,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ProductServiceStubSettings.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); @@ -259,6 +273,11 @@ private static Builder createDefault() { return new Builder(ProductServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ProductServiceStubSettings.newHttpJsonBuilder()); + } + public ProductServiceStubSettings.Builder getStubSettingsBuilder() { return ((ProductServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceClient.java index 05006228..f3f3a528 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceClient.java @@ -124,6 +124,20 @@ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); * } * + *

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.
+ * SearchServiceSettings searchServiceSettings =
+ *     SearchServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceSettings.java index 4ed2515b..4a7ec04e 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceSettings.java @@ -23,6 +23,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 SearchServiceStubSettings.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 SearchServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SearchServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SearchServiceStubSettings.defaultTransportChannelProvider(); } @@ -114,11 +122,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SearchServiceStubSettings.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(SearchServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SearchServiceStubSettings.newHttpJsonBuilder()); + } + public SearchServiceStubSettings.Builder getStubSettingsBuilder() { return ((SearchServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceClient.java index 0303d673..2c92c83d 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceClient.java @@ -18,13 +18,13 @@ import com.google.api.HttpBody; 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.retail.v2.stub.UserEventServiceStub; import com.google.cloud.retail.v2.stub.UserEventServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -100,13 +100,29 @@ * UserEventServiceClient.create(userEventServiceSettings); * } * + *

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.
+ * UserEventServiceSettings userEventServiceSettings =
+ *     UserEventServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * UserEventServiceClient userEventServiceClient =
+ *     UserEventServiceClient.create(userEventServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class UserEventServiceClient implements BackgroundResource { private final UserEventServiceSettings settings; private final UserEventServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of UserEventServiceClient with default settings. */ public static final UserEventServiceClient create() throws IOException { @@ -138,13 +154,17 @@ public static final UserEventServiceClient create(UserEventServiceStub stub) { protected UserEventServiceClient(UserEventServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((UserEventServiceStubSettings) 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()); } protected UserEventServiceClient(UserEventServiceStub 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 UserEventServiceSettings getSettings() { @@ -159,10 +179,18 @@ public UserEventServiceStub 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. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Writes a single user event. diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceSettings.java index 051c8cb4..51560da9 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceSettings.java @@ -22,6 +22,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; @@ -140,11 +141,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return UserEventServiceStubSettings.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 UserEventServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return UserEventServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return UserEventServiceStubSettings.defaultTransportChannelProvider(); } @@ -154,11 +162,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return UserEventServiceStubSettings.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); @@ -196,6 +210,11 @@ private static Builder createDefault() { return new Builder(UserEventServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(UserEventServiceStubSettings.newHttpJsonBuilder()); + } + public UserEventServiceStubSettings.Builder getStubSettingsBuilder() { return ((UserEventServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CatalogServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CatalogServiceStubSettings.java index 1944da11..0da1d1a2 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CatalogServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CatalogServiceStubSettings.java @@ -27,6 +27,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.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -186,6 +189,11 @@ public CatalogServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCatalogServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCatalogServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -218,18 +226,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(CatalogServiceStubSettings.class)) @@ -237,11 +252,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(CatalogServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CatalogServiceStubSettings.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); @@ -355,6 +389,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 .listCatalogsSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStub.java index f5f4d03a..0ccd8074 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStub.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStub.java @@ -38,7 +38,11 @@ public abstract class CompletionServiceStub 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 completeQueryCallable() { diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStubSettings.java index c95aba06..09f076fd 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStubSettings.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; @@ -122,6 +125,11 @@ public CompletionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCompletionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCompletionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -154,18 +162,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(CompletionServiceStubSettings.class)) @@ -173,11 +188,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(CompletionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CompletionServiceStubSettings.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); @@ -283,6 +317,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 .completeQuerySettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceCallableFactory.java new file mode 100644 index 00000000..1cdee1ce --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceCallableFactory.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.retail.v2.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 CatalogService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCatalogServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceStub.java new file mode 100644 index 00000000..5a2088da --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceStub.java @@ -0,0 +1,365 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.stub; + +import static com.google.cloud.retail.v2.CatalogServiceClient.ListCatalogsPagedResponse; + +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.retail.v2.Catalog; +import com.google.cloud.retail.v2.GetDefaultBranchRequest; +import com.google.cloud.retail.v2.GetDefaultBranchResponse; +import com.google.cloud.retail.v2.ListCatalogsRequest; +import com.google.cloud.retail.v2.ListCatalogsResponse; +import com.google.cloud.retail.v2.SetDefaultBranchRequest; +import com.google.cloud.retail.v2.UpdateCatalogRequest; +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 CatalogService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCatalogServiceStub extends CatalogServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listCatalogsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CatalogService/ListCatalogs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*}/catalogs", + 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(ListCatalogsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateCatalogMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CatalogService/UpdateCatalog") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{catalog.name=projects/*/locations/*/catalogs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "catalog.name", request.getCatalog().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("catalog", request.getCatalog())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Catalog.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CatalogService/SetDefaultBranch") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearCatalog().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CatalogService/GetDefaultBranch") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GetDefaultBranchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listCatalogsCallable; + private final UnaryCallable + listCatalogsPagedCallable; + private final UnaryCallable updateCatalogCallable; + private final UnaryCallable setDefaultBranchCallable; + private final UnaryCallable + getDefaultBranchCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCatalogServiceStub create(CatalogServiceStubSettings settings) + throws IOException { + return new HttpJsonCatalogServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCatalogServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCatalogServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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 HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCatalogServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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 HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listCatalogsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listCatalogsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateCatalogTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateCatalogMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listCatalogsCallable = + callableFactory.createUnaryCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.listCatalogsPagedCallable = + callableFactory.createPagedCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.updateCatalogCallable = + callableFactory.createUnaryCallable( + updateCatalogTransportSettings, settings.updateCatalogSettings(), clientContext); + this.setDefaultBranchCallable = + callableFactory.createUnaryCallable( + setDefaultBranchTransportSettings, settings.setDefaultBranchSettings(), clientContext); + this.getDefaultBranchCallable = + callableFactory.createUnaryCallable( + getDefaultBranchTransportSettings, settings.getDefaultBranchSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listCatalogsMethodDescriptor); + methodDescriptors.add(updateCatalogMethodDescriptor); + methodDescriptors.add(setDefaultBranchMethodDescriptor); + methodDescriptors.add(getDefaultBranchMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listCatalogsCallable() { + return listCatalogsCallable; + } + + @Override + public UnaryCallable listCatalogsPagedCallable() { + return listCatalogsPagedCallable; + } + + @Override + public UnaryCallable updateCatalogCallable() { + return updateCatalogCallable; + } + + @Override + public UnaryCallable setDefaultBranchCallable() { + return setDefaultBranchCallable; + } + + @Override + public UnaryCallable + getDefaultBranchCallable() { + return getDefaultBranchCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceCallableFactory.java new file mode 100644 index 00000000..15c6a41f --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceCallableFactory.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.retail.v2.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 CompletionService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCompletionServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceStub.java new file mode 100644 index 00000000..cb0dbd53 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceStub.java @@ -0,0 +1,291 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.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.retail.v2.CompleteQueryRequest; +import com.google.cloud.retail.v2.CompleteQueryResponse; +import com.google.cloud.retail.v2.ImportCompletionDataRequest; +import com.google.cloud.retail.v2.ImportCompletionDataResponse; +import com.google.cloud.retail.v2.ImportMetadata; +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 CompletionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCompletionServiceStub extends CompletionServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportCompletionDataResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + completeQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CompletionService/CompleteQuery") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{catalog=projects/*/locations/*/catalogs/*}:completeQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "dataset", request.getDataset()); + serializer.putQueryParam(fields, "deviceType", request.getDeviceType()); + serializer.putQueryParam( + fields, "languageCodes", request.getLanguageCodesList()); + serializer.putQueryParam( + fields, "maxSuggestions", request.getMaxSuggestions()); + serializer.putQueryParam(fields, "query", request.getQuery()); + serializer.putQueryParam(fields, "visitorId", request.getVisitorId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompleteQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + importCompletionDataMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CompletionService/ImportCompletionData") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/completionData: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( + (ImportCompletionDataRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable completeQueryCallable; + private final UnaryCallable importCompletionDataCallable; + private final OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCompletionServiceStub create(CompletionServiceStubSettings settings) + throws IOException { + return new HttpJsonCompletionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCompletionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCompletionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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 HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCompletionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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 HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + completeQueryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(completeQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + importCompletionDataTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importCompletionDataMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.completeQueryCallable = + callableFactory.createUnaryCallable( + completeQueryTransportSettings, settings.completeQuerySettings(), clientContext); + this.importCompletionDataCallable = + callableFactory.createUnaryCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataSettings(), + clientContext); + this.importCompletionDataOperationCallable = + callableFactory.createOperationCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(completeQueryMethodDescriptor); + methodDescriptors.add(importCompletionDataMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable completeQueryCallable() { + return completeQueryCallable; + } + + @Override + public UnaryCallable importCompletionDataCallable() { + return importCompletionDataCallable; + } + + @Override + public OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable() { + return importCompletionDataOperationCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceCallableFactory.java new file mode 100644 index 00000000..fca54521 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceCallableFactory.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.retail.v2.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 PredictionService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonPredictionServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceStub.java new file mode 100644 index 00000000..e9f4a1d9 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceStub.java @@ -0,0 +1,194 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.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.retail.v2.PredictRequest; +import com.google.cloud.retail.v2.PredictResponse; +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 PredictionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonPredictionServiceStub extends PredictionServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + predictMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.PredictionService/Predict") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PredictResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable predictCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonPredictionServiceStub create(PredictionServiceStubSettings settings) + throws IOException { + return new HttpJsonPredictionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonPredictionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonPredictionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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 HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonPredictionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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 HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings predictTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(predictMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.predictCallable = + callableFactory.createUnaryCallable( + predictTransportSettings, settings.predictSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(predictMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable predictCallable() { + return predictCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceCallableFactory.java new file mode 100644 index 00000000..f27eead2 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceCallableFactory.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.retail.v2.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 ProductService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonProductServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceStub.java new file mode 100644 index 00000000..b8cf0324 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceStub.java @@ -0,0 +1,895 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.stub; + +import static com.google.cloud.retail.v2.ProductServiceClient.ListProductsPagedResponse; + +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.retail.v2.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2.CreateProductRequest; +import com.google.cloud.retail.v2.DeleteProductRequest; +import com.google.cloud.retail.v2.GetProductRequest; +import com.google.cloud.retail.v2.ImportMetadata; +import com.google.cloud.retail.v2.ImportProductsRequest; +import com.google.cloud.retail.v2.ImportProductsResponse; +import com.google.cloud.retail.v2.ListProductsRequest; +import com.google.cloud.retail.v2.ListProductsResponse; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2.RemoveLocalInventoriesResponse; +import com.google.cloud.retail.v2.SetInventoryMetadata; +import com.google.cloud.retail.v2.SetInventoryRequest; +import com.google.cloud.retail.v2.SetInventoryResponse; +import com.google.cloud.retail.v2.UpdateProductRequest; +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 ProductService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonProductServiceStub extends ProductServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(RemoveLocalInventoriesMetadata.getDescriptor()) + .add(AddLocalInventoriesMetadata.getDescriptor()) + .add(AddFulfillmentPlacesMetadata.getDescriptor()) + .add(RemoveFulfillmentPlacesMetadata.getDescriptor()) + .add(SetInventoryResponse.getDescriptor()) + .add(AddLocalInventoriesResponse.getDescriptor()) + .add(ImportProductsResponse.getDescriptor()) + .add(RemoveFulfillmentPlacesResponse.getDescriptor()) + .add(RemoveLocalInventoriesResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .add(AddFulfillmentPlacesResponse.getDescriptor()) + .add(SetInventoryMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/CreateProduct") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/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 getProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/GetProduct") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/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 + listProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/ListProducts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/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, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readMask", request.getReadMask()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/UpdateProduct") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{product.name=projects/*/locations/*/catalogs/*/branches/*/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, "allowMissing", request.getAllowMissing()); + 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.retail.v2.ProductService/DeleteProduct") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/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 + importProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/ImportProducts") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products: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( + (ImportProductsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + setInventoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/SetInventory") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "inventory.name", request.getInventory().getName()); + 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( + (SetInventoryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/AddFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/RemoveFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/AddLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/RemoveLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createProductCallable; + private final UnaryCallable getProductCallable; + private final UnaryCallable listProductsCallable; + private final UnaryCallable + listProductsPagedCallable; + private final UnaryCallable updateProductCallable; + private final UnaryCallable deleteProductCallable; + private final UnaryCallable importProductsCallable; + private final OperationCallable + importProductsOperationCallable; + private final UnaryCallable setInventoryCallable; + private final OperationCallable + setInventoryOperationCallable; + private final UnaryCallable addFulfillmentPlacesCallable; + private final OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable; + private final UnaryCallable + removeFulfillmentPlacesCallable; + private final OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable; + private final UnaryCallable addLocalInventoriesCallable; + private final OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable; + private final UnaryCallable + removeLocalInventoriesCallable; + private final OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonProductServiceStub create(ProductServiceStubSettings settings) + throws IOException { + return new HttpJsonProductServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonProductServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonProductServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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 HttpJsonProductServiceStub( + ProductServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonProductServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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 HttpJsonProductServiceStub( + ProductServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setInventoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setInventoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createProductCallable = + callableFactory.createUnaryCallable( + createProductTransportSettings, settings.createProductSettings(), clientContext); + this.getProductCallable = + callableFactory.createUnaryCallable( + getProductTransportSettings, settings.getProductSettings(), clientContext); + this.listProductsCallable = + callableFactory.createUnaryCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.listProductsPagedCallable = + callableFactory.createPagedCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.updateProductCallable = + callableFactory.createUnaryCallable( + updateProductTransportSettings, settings.updateProductSettings(), clientContext); + this.deleteProductCallable = + callableFactory.createUnaryCallable( + deleteProductTransportSettings, settings.deleteProductSettings(), clientContext); + this.importProductsCallable = + callableFactory.createUnaryCallable( + importProductsTransportSettings, settings.importProductsSettings(), clientContext); + this.importProductsOperationCallable = + callableFactory.createOperationCallable( + importProductsTransportSettings, + settings.importProductsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.setInventoryCallable = + callableFactory.createUnaryCallable( + setInventoryTransportSettings, settings.setInventorySettings(), clientContext); + this.setInventoryOperationCallable = + callableFactory.createOperationCallable( + setInventoryTransportSettings, + settings.setInventoryOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesSettings(), + clientContext); + this.addFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesSettings(), + clientContext); + this.removeFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addLocalInventoriesCallable = + callableFactory.createUnaryCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesSettings(), + clientContext); + this.addLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeLocalInventoriesCallable = + callableFactory.createUnaryCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesSettings(), + clientContext); + this.removeLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createProductMethodDescriptor); + methodDescriptors.add(getProductMethodDescriptor); + methodDescriptors.add(listProductsMethodDescriptor); + methodDescriptors.add(updateProductMethodDescriptor); + methodDescriptors.add(deleteProductMethodDescriptor); + methodDescriptors.add(importProductsMethodDescriptor); + methodDescriptors.add(setInventoryMethodDescriptor); + methodDescriptors.add(addFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(removeFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(addLocalInventoriesMethodDescriptor); + methodDescriptors.add(removeLocalInventoriesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createProductCallable() { + return createProductCallable; + } + + @Override + public UnaryCallable getProductCallable() { + return getProductCallable; + } + + @Override + public UnaryCallable listProductsCallable() { + return listProductsCallable; + } + + @Override + public UnaryCallable listProductsPagedCallable() { + return listProductsPagedCallable; + } + + @Override + public UnaryCallable updateProductCallable() { + return updateProductCallable; + } + + @Override + public UnaryCallable deleteProductCallable() { + return deleteProductCallable; + } + + @Override + public UnaryCallable importProductsCallable() { + return importProductsCallable; + } + + @Override + public OperationCallable + importProductsOperationCallable() { + return importProductsOperationCallable; + } + + @Override + public UnaryCallable setInventoryCallable() { + return setInventoryCallable; + } + + @Override + public OperationCallable + setInventoryOperationCallable() { + return setInventoryOperationCallable; + } + + @Override + public UnaryCallable addFulfillmentPlacesCallable() { + return addFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable() { + return addFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable + removeFulfillmentPlacesCallable() { + return removeFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable() { + return removeFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable addLocalInventoriesCallable() { + return addLocalInventoriesCallable; + } + + @Override + public OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable() { + return addLocalInventoriesOperationCallable; + } + + @Override + public UnaryCallable removeLocalInventoriesCallable() { + return removeLocalInventoriesCallable; + } + + @Override + public OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable() { + return removeLocalInventoriesOperationCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceCallableFactory.java new file mode 100644 index 00000000..1aad89bd --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceCallableFactory.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.retail.v2.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 SearchService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSearchServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceStub.java new file mode 100644 index 00000000..7caaa740 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceStub.java @@ -0,0 +1,204 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.stub; + +import static com.google.cloud.retail.v2.SearchServiceClient.SearchPagedResponse; + +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.retail.v2.SearchRequest; +import com.google.cloud.retail.v2.SearchResponse; +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 SearchService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSearchServiceStub extends SearchServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor searchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.SearchService/Search") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SearchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable searchCallable; + private final UnaryCallable searchPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSearchServiceStub create(SearchServiceStubSettings settings) + throws IOException { + return new HttpJsonSearchServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSearchServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSearchServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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 HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSearchServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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 HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings searchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(searchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.searchCallable = + callableFactory.createUnaryCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + this.searchPagedCallable = + callableFactory.createPagedCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(searchMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable searchCallable() { + return searchCallable; + } + + @Override + public UnaryCallable searchPagedCallable() { + return searchPagedCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceCallableFactory.java new file mode 100644 index 00000000..26bd6635 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceCallableFactory.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.retail.v2.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 UserEventService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonUserEventServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceStub.java new file mode 100644 index 00000000..38e4a9d1 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceStub.java @@ -0,0 +1,481 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.stub; + +import com.google.api.HttpBody; +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.retail.v2.CollectUserEventRequest; +import com.google.cloud.retail.v2.ImportMetadata; +import com.google.cloud.retail.v2.ImportUserEventsRequest; +import com.google.cloud.retail.v2.ImportUserEventsResponse; +import com.google.cloud.retail.v2.PurgeMetadata; +import com.google.cloud.retail.v2.PurgeUserEventsRequest; +import com.google.cloud.retail.v2.PurgeUserEventsResponse; +import com.google.cloud.retail.v2.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2.RejoinUserEventsRequest; +import com.google.cloud.retail.v2.RejoinUserEventsResponse; +import com.google.cloud.retail.v2.UserEvent; +import com.google.cloud.retail.v2.WriteUserEventRequest; +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 UserEventService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonUserEventServiceStub extends UserEventServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportUserEventsResponse.getDescriptor()) + .add(PurgeMetadata.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .add(RejoinUserEventsResponse.getDescriptor()) + .add(PurgeUserEventsResponse.getDescriptor()) + .add(RejoinUserEventsMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + writeUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.UserEventService/WriteUserEvent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + 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("userEvent", request.getUserEvent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UserEvent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + collectUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.UserEventService/CollectUserEvent") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect", + 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, "ets", request.getEts()); + serializer.putQueryParam(fields, "uri", request.getUri()); + serializer.putQueryParam(fields, "userEvent", request.getUserEvent()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(HttpBody.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + purgeUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.UserEventService/PurgeUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents: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( + (PurgeUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.UserEventService/ImportUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents: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( + (ImportUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + rejoinUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.UserEventService/RejoinUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + 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( + (RejoinUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable writeUserEventCallable; + private final UnaryCallable collectUserEventCallable; + private final UnaryCallable purgeUserEventsCallable; + private final OperationCallable + purgeUserEventsOperationCallable; + private final UnaryCallable importUserEventsCallable; + private final OperationCallable + importUserEventsOperationCallable; + private final UnaryCallable rejoinUserEventsCallable; + private final OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonUserEventServiceStub create(UserEventServiceStubSettings settings) + throws IOException { + return new HttpJsonUserEventServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonUserEventServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonUserEventServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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 HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonUserEventServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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 HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings writeUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(writeUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings collectUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(collectUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings purgeUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(purgeUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings rejoinUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(rejoinUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.writeUserEventCallable = + callableFactory.createUnaryCallable( + writeUserEventTransportSettings, settings.writeUserEventSettings(), clientContext); + this.collectUserEventCallable = + callableFactory.createUnaryCallable( + collectUserEventTransportSettings, settings.collectUserEventSettings(), clientContext); + this.purgeUserEventsCallable = + callableFactory.createUnaryCallable( + purgeUserEventsTransportSettings, settings.purgeUserEventsSettings(), clientContext); + this.purgeUserEventsOperationCallable = + callableFactory.createOperationCallable( + purgeUserEventsTransportSettings, + settings.purgeUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importUserEventsCallable = + callableFactory.createUnaryCallable( + importUserEventsTransportSettings, settings.importUserEventsSettings(), clientContext); + this.importUserEventsOperationCallable = + callableFactory.createOperationCallable( + importUserEventsTransportSettings, + settings.importUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.rejoinUserEventsCallable = + callableFactory.createUnaryCallable( + rejoinUserEventsTransportSettings, settings.rejoinUserEventsSettings(), clientContext); + this.rejoinUserEventsOperationCallable = + callableFactory.createOperationCallable( + rejoinUserEventsTransportSettings, + settings.rejoinUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(writeUserEventMethodDescriptor); + methodDescriptors.add(collectUserEventMethodDescriptor); + methodDescriptors.add(purgeUserEventsMethodDescriptor); + methodDescriptors.add(importUserEventsMethodDescriptor); + methodDescriptors.add(rejoinUserEventsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable writeUserEventCallable() { + return writeUserEventCallable; + } + + @Override + public UnaryCallable collectUserEventCallable() { + return collectUserEventCallable; + } + + @Override + public UnaryCallable purgeUserEventsCallable() { + return purgeUserEventsCallable; + } + + @Override + public OperationCallable + purgeUserEventsOperationCallable() { + return purgeUserEventsOperationCallable; + } + + @Override + public UnaryCallable importUserEventsCallable() { + return importUserEventsCallable; + } + + @Override + public OperationCallable + importUserEventsOperationCallable() { + return importUserEventsOperationCallable; + } + + @Override + public UnaryCallable rejoinUserEventsCallable() { + return rejoinUserEventsCallable; + } + + @Override + public OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable() { + return rejoinUserEventsOperationCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2/stub/PredictionServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/PredictionServiceStubSettings.java index 6ae5c4b5..679165b8 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/PredictionServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/PredictionServiceStubSettings.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; @@ -96,6 +99,11 @@ public PredictionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcPredictionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonPredictionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -128,18 +136,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(PredictionServiceStubSettings.class)) @@ -147,11 +162,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(PredictionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PredictionServiceStubSettings.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); @@ -241,6 +275,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 .predictSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStub.java index 82101796..78dfafd7 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStub.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStub.java @@ -61,7 +61,11 @@ public abstract class ProductServiceStub 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 createProductCallable() { diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStubSettings.java index 1887510c..995e1139 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStubSettings.java @@ -28,6 +28,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; @@ -320,6 +323,11 @@ public ProductServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcProductServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonProductServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -352,18 +360,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(ProductServiceStubSettings.class)) @@ -371,11 +386,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(ProductServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ProductServiceStubSettings.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); @@ -598,6 +632,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 .createProductSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/SearchServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/SearchServiceStubSettings.java index bc880833..f8a89672 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/SearchServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/SearchServiceStubSettings.java @@ -27,6 +27,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.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -157,6 +160,11 @@ public SearchServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSearchServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSearchServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -189,18 +197,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(SearchServiceStubSettings.class)) @@ -208,11 +223,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(SearchServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SearchServiceStubSettings.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); @@ -303,6 +337,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 .searchSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStub.java index d0794487..9735dcbc 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStub.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStub.java @@ -46,7 +46,11 @@ public abstract class UserEventServiceStub 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 writeUserEventCallable() { diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStubSettings.java index 6d4f2fd4..9b556438 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStubSettings.java @@ -26,6 +26,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; @@ -163,6 +166,11 @@ public UserEventServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcUserEventServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonUserEventServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -195,18 +203,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(UserEventServiceStubSettings.class)) @@ -214,11 +229,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(UserEventServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return UserEventServiceStubSettings.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); @@ -389,6 +423,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 .writeUserEventSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceClient.java index 71de43b5..4ba69f59 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceClient.java @@ -100,6 +100,20 @@ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); * } * + *

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.
+ * CatalogServiceSettings catalogServiceSettings =
+ *     CatalogServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceSettings.java index 5ce90c09..a2692406 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceSettings.java @@ -23,6 +23,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; @@ -162,11 +163,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CatalogServiceStubSettings.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 CatalogServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CatalogServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CatalogServiceStubSettings.defaultTransportChannelProvider(); } @@ -176,11 +184,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CatalogServiceStubSettings.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); @@ -218,6 +232,11 @@ private static Builder createDefault() { return new Builder(CatalogServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CatalogServiceStubSettings.newHttpJsonBuilder()); + } + public CatalogServiceStubSettings.Builder getStubSettingsBuilder() { return ((CatalogServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceClient.java index 116d00b1..972267fe 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceClient.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.retail.v2alpha.stub.CompletionServiceStub; import com.google.cloud.retail.v2alpha.stub.CompletionServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -108,6 +108,21 @@ * CompletionServiceClient.create(completionServiceSettings); * } * + *

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.
+ * CompletionServiceSettings completionServiceSettings =
+ *     CompletionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CompletionServiceClient completionServiceClient =
+ *     CompletionServiceClient.create(completionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -115,7 +130,8 @@ public class CompletionServiceClient implements BackgroundResource { private final CompletionServiceSettings settings; private final CompletionServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of CompletionServiceClient with default settings. */ public static final CompletionServiceClient create() throws IOException { @@ -147,13 +163,17 @@ public static final CompletionServiceClient create(CompletionServiceStub stub) { protected CompletionServiceClient(CompletionServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((CompletionServiceStubSettings) 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()); } protected CompletionServiceClient(CompletionServiceStub 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 CompletionServiceSettings getSettings() { @@ -168,10 +188,18 @@ public CompletionServiceStub 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. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Completes the specified prefix with keyword suggestions. diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceSettings.java index ee307daa..b9d4cc2a 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceSettings.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; @@ -114,11 +115,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CompletionServiceStubSettings.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 CompletionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CompletionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CompletionServiceStubSettings.defaultTransportChannelProvider(); } @@ -128,11 +136,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CompletionServiceStubSettings.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); @@ -170,6 +184,11 @@ private static Builder createDefault() { return new Builder(CompletionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CompletionServiceStubSettings.newHttpJsonBuilder()); + } + public CompletionServiceStubSettings.Builder getStubSettingsBuilder() { return ((CompletionServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceClient.java index d5270698..54b7dba9 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceClient.java @@ -101,6 +101,20 @@ * ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); * } * + *

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.
+ * ControlServiceSettings controlServiceSettings =
+ *     ControlServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ControlServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceSettings.java index 8bad2cb5..b15aac0d 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceSettings.java @@ -23,6 +23,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; @@ -124,11 +125,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ControlServiceStubSettings.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 ControlServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ControlServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ControlServiceStubSettings.defaultTransportChannelProvider(); } @@ -138,11 +146,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ControlServiceStubSettings.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); @@ -180,6 +194,11 @@ private static Builder createDefault() { return new Builder(ControlServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ControlServiceStubSettings.newHttpJsonBuilder()); + } + public ControlServiceStubSettings.Builder getStubSettingsBuilder() { return ((ControlServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceClient.java index bbf984a9..c4126cd1 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceClient.java @@ -102,6 +102,21 @@ * PredictionServiceClient.create(predictionServiceSettings); * } * + *

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.
+ * PredictionServiceSettings predictionServiceSettings =
+ *     PredictionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * PredictionServiceClient predictionServiceClient =
+ *     PredictionServiceClient.create(predictionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceSettings.java index 62ced44d..60d2a1e4 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceSettings.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; @@ -99,11 +100,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return PredictionServiceStubSettings.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 PredictionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return PredictionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return PredictionServiceStubSettings.defaultTransportChannelProvider(); } @@ -113,11 +121,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return PredictionServiceStubSettings.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); @@ -155,6 +169,11 @@ private static Builder createDefault() { return new Builder(PredictionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(PredictionServiceStubSettings.newHttpJsonBuilder()); + } + public PredictionServiceStubSettings.Builder getStubSettingsBuilder() { return ((PredictionServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceClient.java index b03e9157..0871c9c8 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceClient.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.retail.v2alpha.stub.ProductServiceStubSettings; 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; @@ -106,6 +106,20 @@ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); * } * + *

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.
+ * ProductServiceSettings productServiceSettings =
+ *     ProductServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -113,7 +127,8 @@ public class ProductServiceClient implements BackgroundResource { private final ProductServiceSettings settings; private final ProductServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ProductServiceClient with default settings. */ public static final ProductServiceClient create() throws IOException { @@ -145,13 +160,17 @@ public static final ProductServiceClient create(ProductServiceStub stub) { protected ProductServiceClient(ProductServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((ProductServiceStubSettings) 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()); } protected ProductServiceClient(ProductServiceStub 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 ProductServiceSettings getSettings() { @@ -166,10 +185,18 @@ public ProductServiceStub 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. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a [Product][google.cloud.retail.v2alpha.Product]. diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceSettings.java index d65553f0..de3e6fbf 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceSettings.java @@ -23,6 +23,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; @@ -215,11 +216,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ProductServiceStubSettings.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 ProductServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ProductServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ProductServiceStubSettings.defaultTransportChannelProvider(); } @@ -229,11 +237,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ProductServiceStubSettings.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); @@ -271,6 +285,11 @@ private static Builder createDefault() { return new Builder(ProductServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ProductServiceStubSettings.newHttpJsonBuilder()); + } + public ProductServiceStubSettings.Builder getStubSettingsBuilder() { return ((ProductServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceClient.java index cb32d658..4a99248f 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceClient.java @@ -123,6 +123,20 @@ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); * } * + *

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.
+ * SearchServiceSettings searchServiceSettings =
+ *     SearchServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceSettings.java index 4b64c5c6..bb53ae37 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceSettings.java @@ -23,6 +23,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; @@ -101,11 +102,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SearchServiceStubSettings.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 SearchServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SearchServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SearchServiceStubSettings.defaultTransportChannelProvider(); } @@ -115,11 +123,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SearchServiceStubSettings.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); @@ -157,6 +171,11 @@ private static Builder createDefault() { return new Builder(SearchServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SearchServiceStubSettings.newHttpJsonBuilder()); + } + public SearchServiceStubSettings.Builder getStubSettingsBuilder() { return ((SearchServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClient.java index df630afa..c4d433e3 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClient.java @@ -106,6 +106,21 @@ * ServingConfigServiceClient.create(servingConfigServiceSettings); * } * + *

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.
+ * ServingConfigServiceSettings servingConfigServiceSettings =
+ *     ServingConfigServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ServingConfigServiceClient servingConfigServiceClient =
+ *     ServingConfigServiceClient.create(servingConfigServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceSettings.java index d829c944..b6c0cb66 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceSettings.java @@ -23,6 +23,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; @@ -138,11 +139,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ServingConfigServiceStubSettings.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 ServingConfigServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ServingConfigServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ServingConfigServiceStubSettings.defaultTransportChannelProvider(); } @@ -152,11 +160,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ServingConfigServiceStubSettings.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); @@ -195,6 +209,11 @@ private static Builder createDefault() { return new Builder(ServingConfigServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ServingConfigServiceStubSettings.newHttpJsonBuilder()); + } + public ServingConfigServiceStubSettings.Builder getStubSettingsBuilder() { return ((ServingConfigServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceClient.java index e964d571..047bf863 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceClient.java @@ -19,13 +19,13 @@ import com.google.api.HttpBody; 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.retail.v2alpha.stub.UserEventServiceStub; import com.google.cloud.retail.v2alpha.stub.UserEventServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -101,6 +101,21 @@ * UserEventServiceClient.create(userEventServiceSettings); * } * + *

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.
+ * UserEventServiceSettings userEventServiceSettings =
+ *     UserEventServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * UserEventServiceClient userEventServiceClient =
+ *     UserEventServiceClient.create(userEventServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -108,7 +123,8 @@ public class UserEventServiceClient implements BackgroundResource { private final UserEventServiceSettings settings; private final UserEventServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of UserEventServiceClient with default settings. */ public static final UserEventServiceClient create() throws IOException { @@ -140,13 +156,17 @@ public static final UserEventServiceClient create(UserEventServiceStub stub) { protected UserEventServiceClient(UserEventServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((UserEventServiceStubSettings) 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()); } protected UserEventServiceClient(UserEventServiceStub 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 UserEventServiceSettings getSettings() { @@ -161,10 +181,18 @@ public UserEventServiceStub 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. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Writes a single user event. diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceSettings.java index 4e413e80..a6470138 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceSettings.java @@ -22,6 +22,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; @@ -141,11 +142,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return UserEventServiceStubSettings.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 UserEventServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return UserEventServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return UserEventServiceStubSettings.defaultTransportChannelProvider(); } @@ -155,11 +163,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return UserEventServiceStubSettings.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); @@ -197,6 +211,11 @@ private static Builder createDefault() { return new Builder(UserEventServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(UserEventServiceStubSettings.newHttpJsonBuilder()); + } + public UserEventServiceStubSettings.Builder getStubSettingsBuilder() { return ((UserEventServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CatalogServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CatalogServiceStubSettings.java index 818c66a5..b5542b5e 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CatalogServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CatalogServiceStubSettings.java @@ -27,6 +27,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.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -252,6 +255,11 @@ public CatalogServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCatalogServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCatalogServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -284,18 +292,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(CatalogServiceStubSettings.class)) @@ -303,11 +318,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(CatalogServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CatalogServiceStubSettings.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); @@ -470,6 +504,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 .listCatalogsSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStub.java index 7b2bd81a..e3cabeca 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStub.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStub.java @@ -40,7 +40,11 @@ public abstract class CompletionServiceStub 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 completeQueryCallable() { diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStubSettings.java index 6e939255..413700f2 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStubSettings.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; @@ -123,6 +126,11 @@ public CompletionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCompletionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCompletionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -155,18 +163,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(CompletionServiceStubSettings.class)) @@ -174,11 +189,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(CompletionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CompletionServiceStubSettings.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); @@ -284,6 +318,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 .completeQuerySettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ControlServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ControlServiceStubSettings.java index d58eafd2..c42ca138 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ControlServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ControlServiceStubSettings.java @@ -27,6 +27,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.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -190,6 +193,11 @@ public ControlServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcControlServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonControlServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -222,18 +230,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(ControlServiceStubSettings.class)) @@ -241,11 +256,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(ControlServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ControlServiceStubSettings.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); @@ -350,6 +384,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 .createControlSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceCallableFactory.java new file mode 100644 index 00000000..66ae6647 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceCallableFactory.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.retail.v2alpha.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 CatalogService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCatalogServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceStub.java new file mode 100644 index 00000000..aaf8a44a --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceStub.java @@ -0,0 +1,772 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import static com.google.cloud.retail.v2alpha.CatalogServiceClient.ListCatalogsPagedResponse; + +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.retail.v2alpha.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.GetAttributesConfigRequest; +import com.google.cloud.retail.v2alpha.GetCompletionConfigRequest; +import com.google.cloud.retail.v2alpha.GetDefaultBranchRequest; +import com.google.cloud.retail.v2alpha.GetDefaultBranchResponse; +import com.google.cloud.retail.v2alpha.ListCatalogsRequest; +import com.google.cloud.retail.v2alpha.ListCatalogsResponse; +import com.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest; +import com.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest; +import com.google.cloud.retail.v2alpha.SetDefaultBranchRequest; +import com.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest; +import com.google.cloud.retail.v2alpha.UpdateCatalogRequest; +import com.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest; +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 CatalogService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCatalogServiceStub extends CatalogServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listCatalogsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/ListCatalogs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*}/catalogs", + 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(ListCatalogsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateCatalogMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/UpdateCatalog") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{catalog.name=projects/*/locations/*/catalogs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "catalog.name", request.getCatalog().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("catalog", request.getCatalog())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Catalog.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/SetDefaultBranch") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearCatalog().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/GetDefaultBranch") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GetDefaultBranchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getCompletionConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/GetCompletionConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/completionConfig}", + 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(CompletionConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateCompletionConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.CatalogService/UpdateCompletionConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{completionConfig.name=projects/*/locations/*/catalogs/*/completionConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "completionConfig.name", + request.getCompletionConfig().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("completionConfig", request.getCompletionConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompletionConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getAttributesConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/GetAttributesConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/attributesConfig}", + 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(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateAttributesConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.CatalogService/UpdateAttributesConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{attributesConfig.name=projects/*/locations/*/catalogs/*/attributesConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "attributesConfig.name", + request.getAttributesConfig().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("attributesConfig", request.getAttributesConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/AddCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.CatalogService/RemoveCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + replaceCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.CatalogService/ReplaceCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listCatalogsCallable; + private final UnaryCallable + listCatalogsPagedCallable; + private final UnaryCallable updateCatalogCallable; + private final UnaryCallable setDefaultBranchCallable; + private final UnaryCallable + getDefaultBranchCallable; + private final UnaryCallable + getCompletionConfigCallable; + private final UnaryCallable + updateCompletionConfigCallable; + private final UnaryCallable + getAttributesConfigCallable; + private final UnaryCallable + updateAttributesConfigCallable; + private final UnaryCallable + addCatalogAttributeCallable; + private final UnaryCallable + removeCatalogAttributeCallable; + private final UnaryCallable + replaceCatalogAttributeCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCatalogServiceStub create(CatalogServiceStubSettings settings) + throws IOException { + return new HttpJsonCatalogServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCatalogServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCatalogServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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 HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCatalogServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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 HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listCatalogsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listCatalogsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateCatalogTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateCatalogMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getCompletionConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getCompletionConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateCompletionConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateCompletionConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getAttributesConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getAttributesConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateAttributesConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateAttributesConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + replaceCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(replaceCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listCatalogsCallable = + callableFactory.createUnaryCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.listCatalogsPagedCallable = + callableFactory.createPagedCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.updateCatalogCallable = + callableFactory.createUnaryCallable( + updateCatalogTransportSettings, settings.updateCatalogSettings(), clientContext); + this.setDefaultBranchCallable = + callableFactory.createUnaryCallable( + setDefaultBranchTransportSettings, settings.setDefaultBranchSettings(), clientContext); + this.getDefaultBranchCallable = + callableFactory.createUnaryCallable( + getDefaultBranchTransportSettings, settings.getDefaultBranchSettings(), clientContext); + this.getCompletionConfigCallable = + callableFactory.createUnaryCallable( + getCompletionConfigTransportSettings, + settings.getCompletionConfigSettings(), + clientContext); + this.updateCompletionConfigCallable = + callableFactory.createUnaryCallable( + updateCompletionConfigTransportSettings, + settings.updateCompletionConfigSettings(), + clientContext); + this.getAttributesConfigCallable = + callableFactory.createUnaryCallable( + getAttributesConfigTransportSettings, + settings.getAttributesConfigSettings(), + clientContext); + this.updateAttributesConfigCallable = + callableFactory.createUnaryCallable( + updateAttributesConfigTransportSettings, + settings.updateAttributesConfigSettings(), + clientContext); + this.addCatalogAttributeCallable = + callableFactory.createUnaryCallable( + addCatalogAttributeTransportSettings, + settings.addCatalogAttributeSettings(), + clientContext); + this.removeCatalogAttributeCallable = + callableFactory.createUnaryCallable( + removeCatalogAttributeTransportSettings, + settings.removeCatalogAttributeSettings(), + clientContext); + this.replaceCatalogAttributeCallable = + callableFactory.createUnaryCallable( + replaceCatalogAttributeTransportSettings, + settings.replaceCatalogAttributeSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listCatalogsMethodDescriptor); + methodDescriptors.add(updateCatalogMethodDescriptor); + methodDescriptors.add(setDefaultBranchMethodDescriptor); + methodDescriptors.add(getDefaultBranchMethodDescriptor); + methodDescriptors.add(getCompletionConfigMethodDescriptor); + methodDescriptors.add(updateCompletionConfigMethodDescriptor); + methodDescriptors.add(getAttributesConfigMethodDescriptor); + methodDescriptors.add(updateAttributesConfigMethodDescriptor); + methodDescriptors.add(addCatalogAttributeMethodDescriptor); + methodDescriptors.add(removeCatalogAttributeMethodDescriptor); + methodDescriptors.add(replaceCatalogAttributeMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listCatalogsCallable() { + return listCatalogsCallable; + } + + @Override + public UnaryCallable listCatalogsPagedCallable() { + return listCatalogsPagedCallable; + } + + @Override + public UnaryCallable updateCatalogCallable() { + return updateCatalogCallable; + } + + @Override + public UnaryCallable setDefaultBranchCallable() { + return setDefaultBranchCallable; + } + + @Override + public UnaryCallable + getDefaultBranchCallable() { + return getDefaultBranchCallable; + } + + @Override + public UnaryCallable getCompletionConfigCallable() { + return getCompletionConfigCallable; + } + + @Override + public UnaryCallable + updateCompletionConfigCallable() { + return updateCompletionConfigCallable; + } + + @Override + public UnaryCallable getAttributesConfigCallable() { + return getAttributesConfigCallable; + } + + @Override + public UnaryCallable + updateAttributesConfigCallable() { + return updateAttributesConfigCallable; + } + + @Override + public UnaryCallable addCatalogAttributeCallable() { + return addCatalogAttributeCallable; + } + + @Override + public UnaryCallable + removeCatalogAttributeCallable() { + return removeCatalogAttributeCallable; + } + + @Override + public UnaryCallable + replaceCatalogAttributeCallable() { + return replaceCatalogAttributeCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceCallableFactory.java new file mode 100644 index 00000000..2d87d8b6 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceCallableFactory.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.retail.v2alpha.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 CompletionService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCompletionServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceStub.java new file mode 100644 index 00000000..397adb86 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceStub.java @@ -0,0 +1,292 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.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.retail.v2alpha.CompleteQueryRequest; +import com.google.cloud.retail.v2alpha.CompleteQueryResponse; +import com.google.cloud.retail.v2alpha.ImportCompletionDataRequest; +import com.google.cloud.retail.v2alpha.ImportCompletionDataResponse; +import com.google.cloud.retail.v2alpha.ImportMetadata; +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 CompletionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCompletionServiceStub extends CompletionServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportCompletionDataResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + completeQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CompletionService/CompleteQuery") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:completeQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "dataset", request.getDataset()); + serializer.putQueryParam(fields, "deviceType", request.getDeviceType()); + serializer.putQueryParam( + fields, "languageCodes", request.getLanguageCodesList()); + serializer.putQueryParam( + fields, "maxSuggestions", request.getMaxSuggestions()); + serializer.putQueryParam(fields, "query", request.getQuery()); + serializer.putQueryParam(fields, "visitorId", request.getVisitorId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompleteQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + importCompletionDataMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.CompletionService/ImportCompletionData") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/completionData: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( + (ImportCompletionDataRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable completeQueryCallable; + private final UnaryCallable importCompletionDataCallable; + private final OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCompletionServiceStub create(CompletionServiceStubSettings settings) + throws IOException { + return new HttpJsonCompletionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCompletionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCompletionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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 HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCompletionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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 HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + completeQueryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(completeQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + importCompletionDataTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importCompletionDataMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.completeQueryCallable = + callableFactory.createUnaryCallable( + completeQueryTransportSettings, settings.completeQuerySettings(), clientContext); + this.importCompletionDataCallable = + callableFactory.createUnaryCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataSettings(), + clientContext); + this.importCompletionDataOperationCallable = + callableFactory.createOperationCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(completeQueryMethodDescriptor); + methodDescriptors.add(importCompletionDataMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable completeQueryCallable() { + return completeQueryCallable; + } + + @Override + public UnaryCallable importCompletionDataCallable() { + return importCompletionDataCallable; + } + + @Override + public OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable() { + return importCompletionDataOperationCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceCallableFactory.java new file mode 100644 index 00000000..a4bb05d7 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceCallableFactory.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.retail.v2alpha.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 ControlService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonControlServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceStub.java new file mode 100644 index 00000000..2dbd5c64 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceStub.java @@ -0,0 +1,410 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import static com.google.cloud.retail.v2alpha.ControlServiceClient.ListControlsPagedResponse; + +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.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.CreateControlRequest; +import com.google.cloud.retail.v2alpha.DeleteControlRequest; +import com.google.cloud.retail.v2alpha.GetControlRequest; +import com.google.cloud.retail.v2alpha.ListControlsRequest; +import com.google.cloud.retail.v2alpha.ListControlsResponse; +import com.google.cloud.retail.v2alpha.UpdateControlRequest; +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 ControlService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonControlServiceStub extends ControlServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ControlService/CreateControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls", + 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, "controlId", request.getControlId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("control", request.getControl())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ControlService/DeleteControl") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}", + 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 + updateControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ControlService/UpdateControl") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{control.name=projects/*/locations/*/catalogs/*/controls/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "control.name", request.getControl().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("control", request.getControl())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ControlService/GetControl") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}", + 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(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listControlsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ControlService/ListControls") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls", + 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, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListControlsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createControlCallable; + private final UnaryCallable deleteControlCallable; + private final UnaryCallable updateControlCallable; + private final UnaryCallable getControlCallable; + private final UnaryCallable listControlsCallable; + private final UnaryCallable + listControlsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonControlServiceStub create(ControlServiceStubSettings settings) + throws IOException { + return new HttpJsonControlServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonControlServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonControlServiceStub( + ControlServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonControlServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonControlServiceStub( + ControlServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonControlServiceStub, 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 HttpJsonControlServiceStub( + ControlServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonControlServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonControlServiceStub, 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 HttpJsonControlServiceStub( + ControlServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listControlsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listControlsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createControlCallable = + callableFactory.createUnaryCallable( + createControlTransportSettings, settings.createControlSettings(), clientContext); + this.deleteControlCallable = + callableFactory.createUnaryCallable( + deleteControlTransportSettings, settings.deleteControlSettings(), clientContext); + this.updateControlCallable = + callableFactory.createUnaryCallable( + updateControlTransportSettings, settings.updateControlSettings(), clientContext); + this.getControlCallable = + callableFactory.createUnaryCallable( + getControlTransportSettings, settings.getControlSettings(), clientContext); + this.listControlsCallable = + callableFactory.createUnaryCallable( + listControlsTransportSettings, settings.listControlsSettings(), clientContext); + this.listControlsPagedCallable = + callableFactory.createPagedCallable( + listControlsTransportSettings, settings.listControlsSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createControlMethodDescriptor); + methodDescriptors.add(deleteControlMethodDescriptor); + methodDescriptors.add(updateControlMethodDescriptor); + methodDescriptors.add(getControlMethodDescriptor); + methodDescriptors.add(listControlsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createControlCallable() { + return createControlCallable; + } + + @Override + public UnaryCallable deleteControlCallable() { + return deleteControlCallable; + } + + @Override + public UnaryCallable updateControlCallable() { + return updateControlCallable; + } + + @Override + public UnaryCallable getControlCallable() { + return getControlCallable; + } + + @Override + public UnaryCallable listControlsCallable() { + return listControlsCallable; + } + + @Override + public UnaryCallable listControlsPagedCallable() { + return listControlsPagedCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceCallableFactory.java new file mode 100644 index 00000000..f289b936 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceCallableFactory.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.retail.v2alpha.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 PredictionService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPredictionServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceStub.java new file mode 100644 index 00000000..502fde4e --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceStub.java @@ -0,0 +1,194 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.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.retail.v2alpha.PredictRequest; +import com.google.cloud.retail.v2alpha.PredictResponse; +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 PredictionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPredictionServiceStub extends PredictionServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + predictMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.PredictionService/Predict") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PredictResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable predictCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonPredictionServiceStub create(PredictionServiceStubSettings settings) + throws IOException { + return new HttpJsonPredictionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonPredictionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonPredictionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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 HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonPredictionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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 HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings predictTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(predictMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.predictCallable = + callableFactory.createUnaryCallable( + predictTransportSettings, settings.predictSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(predictMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable predictCallable() { + return predictCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceCallableFactory.java new file mode 100644 index 00000000..5255bceb --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceCallableFactory.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.retail.v2alpha.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 ProductService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceStub.java new file mode 100644 index 00000000..8bfa4371 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceStub.java @@ -0,0 +1,973 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import static com.google.cloud.retail.v2alpha.ProductServiceClient.ListProductsPagedResponse; + +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.retail.v2alpha.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.CreateProductRequest; +import com.google.cloud.retail.v2alpha.DeleteProductRequest; +import com.google.cloud.retail.v2alpha.GetProductRequest; +import com.google.cloud.retail.v2alpha.ImportMetadata; +import com.google.cloud.retail.v2alpha.ImportProductsRequest; +import com.google.cloud.retail.v2alpha.ImportProductsResponse; +import com.google.cloud.retail.v2alpha.ListProductsRequest; +import com.google.cloud.retail.v2alpha.ListProductsResponse; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.PurgeProductsMetadata; +import com.google.cloud.retail.v2alpha.PurgeProductsRequest; +import com.google.cloud.retail.v2alpha.PurgeProductsResponse; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.SetInventoryMetadata; +import com.google.cloud.retail.v2alpha.SetInventoryRequest; +import com.google.cloud.retail.v2alpha.SetInventoryResponse; +import com.google.cloud.retail.v2alpha.UpdateProductRequest; +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 ProductService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductServiceStub extends ProductServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(RemoveLocalInventoriesResponse.getDescriptor()) + .add(PurgeProductsMetadata.getDescriptor()) + .add(AddFulfillmentPlacesResponse.getDescriptor()) + .add(RemoveFulfillmentPlacesMetadata.getDescriptor()) + .add(SetInventoryResponse.getDescriptor()) + .add(SetInventoryMetadata.getDescriptor()) + .add(AddLocalInventoriesMetadata.getDescriptor()) + .add(PurgeProductsResponse.getDescriptor()) + .add(ImportProductsResponse.getDescriptor()) + .add(AddLocalInventoriesResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .add(AddFulfillmentPlacesMetadata.getDescriptor()) + .add(RemoveFulfillmentPlacesResponse.getDescriptor()) + .add(RemoveLocalInventoriesMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/CreateProduct") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/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 getProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/GetProduct") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/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 + listProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/ListProducts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/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, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readMask", request.getReadMask()); + serializer.putQueryParam( + fields, "requireTotalSize", request.getRequireTotalSize()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/UpdateProduct") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{product.name=projects/*/locations/*/catalogs/*/branches/*/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, "allowMissing", request.getAllowMissing()); + 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.retail.v2alpha.ProductService/DeleteProduct") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/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 + purgeProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/PurgeProducts") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/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 static final ApiMethodDescriptor + importProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/ImportProducts") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products: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( + (ImportProductsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + setInventoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/SetInventory") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "inventory.name", request.getInventory().getName()); + 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( + (SetInventoryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/AddFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ProductService/RemoveFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/AddLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ProductService/RemoveLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createProductCallable; + private final UnaryCallable getProductCallable; + private final UnaryCallable listProductsCallable; + private final UnaryCallable + listProductsPagedCallable; + private final UnaryCallable updateProductCallable; + private final UnaryCallable deleteProductCallable; + private final UnaryCallable purgeProductsCallable; + private final OperationCallable< + PurgeProductsRequest, PurgeProductsResponse, PurgeProductsMetadata> + purgeProductsOperationCallable; + private final UnaryCallable importProductsCallable; + private final OperationCallable + importProductsOperationCallable; + private final UnaryCallable setInventoryCallable; + private final OperationCallable + setInventoryOperationCallable; + private final UnaryCallable addFulfillmentPlacesCallable; + private final OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable; + private final UnaryCallable + removeFulfillmentPlacesCallable; + private final OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable; + private final UnaryCallable addLocalInventoriesCallable; + private final OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable; + private final UnaryCallable + removeLocalInventoriesCallable; + private final OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonProductServiceStub create(ProductServiceStubSettings settings) + throws IOException { + return new HttpJsonProductServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonProductServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonProductServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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 HttpJsonProductServiceStub( + ProductServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonProductServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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 HttpJsonProductServiceStub( + ProductServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings purgeProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(purgeProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setInventoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setInventoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createProductCallable = + callableFactory.createUnaryCallable( + createProductTransportSettings, settings.createProductSettings(), clientContext); + this.getProductCallable = + callableFactory.createUnaryCallable( + getProductTransportSettings, settings.getProductSettings(), clientContext); + this.listProductsCallable = + callableFactory.createUnaryCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.listProductsPagedCallable = + callableFactory.createPagedCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.updateProductCallable = + callableFactory.createUnaryCallable( + updateProductTransportSettings, settings.updateProductSettings(), clientContext); + this.deleteProductCallable = + callableFactory.createUnaryCallable( + deleteProductTransportSettings, settings.deleteProductSettings(), clientContext); + this.purgeProductsCallable = + callableFactory.createUnaryCallable( + purgeProductsTransportSettings, settings.purgeProductsSettings(), clientContext); + this.purgeProductsOperationCallable = + callableFactory.createOperationCallable( + purgeProductsTransportSettings, + settings.purgeProductsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importProductsCallable = + callableFactory.createUnaryCallable( + importProductsTransportSettings, settings.importProductsSettings(), clientContext); + this.importProductsOperationCallable = + callableFactory.createOperationCallable( + importProductsTransportSettings, + settings.importProductsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.setInventoryCallable = + callableFactory.createUnaryCallable( + setInventoryTransportSettings, settings.setInventorySettings(), clientContext); + this.setInventoryOperationCallable = + callableFactory.createOperationCallable( + setInventoryTransportSettings, + settings.setInventoryOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesSettings(), + clientContext); + this.addFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesSettings(), + clientContext); + this.removeFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addLocalInventoriesCallable = + callableFactory.createUnaryCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesSettings(), + clientContext); + this.addLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeLocalInventoriesCallable = + callableFactory.createUnaryCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesSettings(), + clientContext); + this.removeLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createProductMethodDescriptor); + methodDescriptors.add(getProductMethodDescriptor); + methodDescriptors.add(listProductsMethodDescriptor); + methodDescriptors.add(updateProductMethodDescriptor); + methodDescriptors.add(deleteProductMethodDescriptor); + methodDescriptors.add(purgeProductsMethodDescriptor); + methodDescriptors.add(importProductsMethodDescriptor); + methodDescriptors.add(setInventoryMethodDescriptor); + methodDescriptors.add(addFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(removeFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(addLocalInventoriesMethodDescriptor); + methodDescriptors.add(removeLocalInventoriesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createProductCallable() { + return createProductCallable; + } + + @Override + public UnaryCallable getProductCallable() { + return getProductCallable; + } + + @Override + public UnaryCallable listProductsCallable() { + return listProductsCallable; + } + + @Override + public UnaryCallable listProductsPagedCallable() { + return listProductsPagedCallable; + } + + @Override + public UnaryCallable updateProductCallable() { + return updateProductCallable; + } + + @Override + public UnaryCallable deleteProductCallable() { + return deleteProductCallable; + } + + @Override + public UnaryCallable purgeProductsCallable() { + return purgeProductsCallable; + } + + @Override + public OperationCallable + purgeProductsOperationCallable() { + return purgeProductsOperationCallable; + } + + @Override + public UnaryCallable importProductsCallable() { + return importProductsCallable; + } + + @Override + public OperationCallable + importProductsOperationCallable() { + return importProductsOperationCallable; + } + + @Override + public UnaryCallable setInventoryCallable() { + return setInventoryCallable; + } + + @Override + public OperationCallable + setInventoryOperationCallable() { + return setInventoryOperationCallable; + } + + @Override + public UnaryCallable addFulfillmentPlacesCallable() { + return addFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable() { + return addFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable + removeFulfillmentPlacesCallable() { + return removeFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable() { + return removeFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable addLocalInventoriesCallable() { + return addLocalInventoriesCallable; + } + + @Override + public OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable() { + return addLocalInventoriesOperationCallable; + } + + @Override + public UnaryCallable removeLocalInventoriesCallable() { + return removeLocalInventoriesCallable; + } + + @Override + public OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable() { + return removeLocalInventoriesOperationCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceCallableFactory.java new file mode 100644 index 00000000..39aa67d7 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceCallableFactory.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.retail.v2alpha.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 SearchService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSearchServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceStub.java new file mode 100644 index 00000000..03335485 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceStub.java @@ -0,0 +1,204 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import static com.google.cloud.retail.v2alpha.SearchServiceClient.SearchPagedResponse; + +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.retail.v2alpha.SearchRequest; +import com.google.cloud.retail.v2alpha.SearchResponse; +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 SearchService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSearchServiceStub extends SearchServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor searchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.SearchService/Search") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SearchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable searchCallable; + private final UnaryCallable searchPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSearchServiceStub create(SearchServiceStubSettings settings) + throws IOException { + return new HttpJsonSearchServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSearchServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSearchServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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 HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSearchServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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 HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings searchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(searchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.searchCallable = + callableFactory.createUnaryCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + this.searchPagedCallable = + callableFactory.createPagedCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(searchMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable searchCallable() { + return searchCallable; + } + + @Override + public UnaryCallable searchPagedCallable() { + return searchPagedCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceCallableFactory.java new file mode 100644 index 00000000..b440ec40 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceCallableFactory.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.retail.v2alpha.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 ServingConfigService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonServingConfigServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceStub.java new file mode 100644 index 00000000..17883438 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceStub.java @@ -0,0 +1,544 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import static com.google.cloud.retail.v2alpha.ServingConfigServiceClient.ListServingConfigsPagedResponse; + +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.retail.v2alpha.AddControlRequest; +import com.google.cloud.retail.v2alpha.CreateServingConfigRequest; +import com.google.cloud.retail.v2alpha.DeleteServingConfigRequest; +import com.google.cloud.retail.v2alpha.GetServingConfigRequest; +import com.google.cloud.retail.v2alpha.ListServingConfigsRequest; +import com.google.cloud.retail.v2alpha.ListServingConfigsResponse; +import com.google.cloud.retail.v2alpha.RemoveControlRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.UpdateServingConfigRequest; +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 ServingConfigService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonServingConfigServiceStub extends ServingConfigServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ServingConfigService/CreateServingConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + 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, "servingConfigId", request.getServingConfigId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("servingConfig", request.getServingConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ServingConfigService/DeleteServingConfig") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + 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 + updateServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ServingConfigService/UpdateServingConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{servingConfig.name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig.name", request.getServingConfig().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("servingConfig", request.getServingConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ServingConfigService/GetServingConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + 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(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listServingConfigsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ServingConfigService/ListServingConfigs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + 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(ListServingConfigsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ServingConfigService/AddControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{servingConfig=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig", request.getServingConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServingConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ServingConfigService/RemoveControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{servingConfig=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig", request.getServingConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServingConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + createServingConfigCallable; + private final UnaryCallable deleteServingConfigCallable; + private final UnaryCallable + updateServingConfigCallable; + private final UnaryCallable getServingConfigCallable; + private final UnaryCallable + listServingConfigsCallable; + private final UnaryCallable + listServingConfigsPagedCallable; + private final UnaryCallable addControlCallable; + private final UnaryCallable removeControlCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonServingConfigServiceStub create( + ServingConfigServiceStubSettings settings) throws IOException { + return new HttpJsonServingConfigServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonServingConfigServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonServingConfigServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonServingConfigServiceStub, 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 HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonServingConfigServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonServingConfigServiceStub, 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 HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + createServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listServingConfigsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listServingConfigsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings addControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings removeControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createServingConfigCallable = + callableFactory.createUnaryCallable( + createServingConfigTransportSettings, + settings.createServingConfigSettings(), + clientContext); + this.deleteServingConfigCallable = + callableFactory.createUnaryCallable( + deleteServingConfigTransportSettings, + settings.deleteServingConfigSettings(), + clientContext); + this.updateServingConfigCallable = + callableFactory.createUnaryCallable( + updateServingConfigTransportSettings, + settings.updateServingConfigSettings(), + clientContext); + this.getServingConfigCallable = + callableFactory.createUnaryCallable( + getServingConfigTransportSettings, settings.getServingConfigSettings(), clientContext); + this.listServingConfigsCallable = + callableFactory.createUnaryCallable( + listServingConfigsTransportSettings, + settings.listServingConfigsSettings(), + clientContext); + this.listServingConfigsPagedCallable = + callableFactory.createPagedCallable( + listServingConfigsTransportSettings, + settings.listServingConfigsSettings(), + clientContext); + this.addControlCallable = + callableFactory.createUnaryCallable( + addControlTransportSettings, settings.addControlSettings(), clientContext); + this.removeControlCallable = + callableFactory.createUnaryCallable( + removeControlTransportSettings, settings.removeControlSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createServingConfigMethodDescriptor); + methodDescriptors.add(deleteServingConfigMethodDescriptor); + methodDescriptors.add(updateServingConfigMethodDescriptor); + methodDescriptors.add(getServingConfigMethodDescriptor); + methodDescriptors.add(listServingConfigsMethodDescriptor); + methodDescriptors.add(addControlMethodDescriptor); + methodDescriptors.add(removeControlMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createServingConfigCallable() { + return createServingConfigCallable; + } + + @Override + public UnaryCallable deleteServingConfigCallable() { + return deleteServingConfigCallable; + } + + @Override + public UnaryCallable updateServingConfigCallable() { + return updateServingConfigCallable; + } + + @Override + public UnaryCallable getServingConfigCallable() { + return getServingConfigCallable; + } + + @Override + public UnaryCallable + listServingConfigsCallable() { + return listServingConfigsCallable; + } + + @Override + public UnaryCallable + listServingConfigsPagedCallable() { + return listServingConfigsPagedCallable; + } + + @Override + public UnaryCallable addControlCallable() { + return addControlCallable; + } + + @Override + public UnaryCallable removeControlCallable() { + return removeControlCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceCallableFactory.java new file mode 100644 index 00000000..149417cd --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceCallableFactory.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.retail.v2alpha.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 UserEventService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonUserEventServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceStub.java new file mode 100644 index 00000000..df1eb705 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceStub.java @@ -0,0 +1,481 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.HttpBody; +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.retail.v2alpha.CollectUserEventRequest; +import com.google.cloud.retail.v2alpha.ImportMetadata; +import com.google.cloud.retail.v2alpha.ImportUserEventsRequest; +import com.google.cloud.retail.v2alpha.ImportUserEventsResponse; +import com.google.cloud.retail.v2alpha.PurgeMetadata; +import com.google.cloud.retail.v2alpha.PurgeUserEventsRequest; +import com.google.cloud.retail.v2alpha.PurgeUserEventsResponse; +import com.google.cloud.retail.v2alpha.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2alpha.RejoinUserEventsRequest; +import com.google.cloud.retail.v2alpha.RejoinUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEvent; +import com.google.cloud.retail.v2alpha.WriteUserEventRequest; +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 UserEventService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonUserEventServiceStub extends UserEventServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(RejoinUserEventsResponse.getDescriptor()) + .add(PurgeUserEventsResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .add(ImportUserEventsResponse.getDescriptor()) + .add(RejoinUserEventsMetadata.getDescriptor()) + .add(PurgeMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + writeUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.UserEventService/WriteUserEvent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + 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("userEvent", request.getUserEvent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UserEvent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + collectUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.UserEventService/CollectUserEvent") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect", + 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, "ets", request.getEts()); + serializer.putQueryParam(fields, "uri", request.getUri()); + serializer.putQueryParam(fields, "userEvent", request.getUserEvent()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(HttpBody.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + purgeUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.UserEventService/PurgeUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents: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( + (PurgeUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.UserEventService/ImportUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents: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( + (ImportUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + rejoinUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.UserEventService/RejoinUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + 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( + (RejoinUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable writeUserEventCallable; + private final UnaryCallable collectUserEventCallable; + private final UnaryCallable purgeUserEventsCallable; + private final OperationCallable + purgeUserEventsOperationCallable; + private final UnaryCallable importUserEventsCallable; + private final OperationCallable + importUserEventsOperationCallable; + private final UnaryCallable rejoinUserEventsCallable; + private final OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonUserEventServiceStub create(UserEventServiceStubSettings settings) + throws IOException { + return new HttpJsonUserEventServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonUserEventServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonUserEventServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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 HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonUserEventServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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 HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings writeUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(writeUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings collectUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(collectUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings purgeUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(purgeUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings rejoinUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(rejoinUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.writeUserEventCallable = + callableFactory.createUnaryCallable( + writeUserEventTransportSettings, settings.writeUserEventSettings(), clientContext); + this.collectUserEventCallable = + callableFactory.createUnaryCallable( + collectUserEventTransportSettings, settings.collectUserEventSettings(), clientContext); + this.purgeUserEventsCallable = + callableFactory.createUnaryCallable( + purgeUserEventsTransportSettings, settings.purgeUserEventsSettings(), clientContext); + this.purgeUserEventsOperationCallable = + callableFactory.createOperationCallable( + purgeUserEventsTransportSettings, + settings.purgeUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importUserEventsCallable = + callableFactory.createUnaryCallable( + importUserEventsTransportSettings, settings.importUserEventsSettings(), clientContext); + this.importUserEventsOperationCallable = + callableFactory.createOperationCallable( + importUserEventsTransportSettings, + settings.importUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.rejoinUserEventsCallable = + callableFactory.createUnaryCallable( + rejoinUserEventsTransportSettings, settings.rejoinUserEventsSettings(), clientContext); + this.rejoinUserEventsOperationCallable = + callableFactory.createOperationCallable( + rejoinUserEventsTransportSettings, + settings.rejoinUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(writeUserEventMethodDescriptor); + methodDescriptors.add(collectUserEventMethodDescriptor); + methodDescriptors.add(purgeUserEventsMethodDescriptor); + methodDescriptors.add(importUserEventsMethodDescriptor); + methodDescriptors.add(rejoinUserEventsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable writeUserEventCallable() { + return writeUserEventCallable; + } + + @Override + public UnaryCallable collectUserEventCallable() { + return collectUserEventCallable; + } + + @Override + public UnaryCallable purgeUserEventsCallable() { + return purgeUserEventsCallable; + } + + @Override + public OperationCallable + purgeUserEventsOperationCallable() { + return purgeUserEventsOperationCallable; + } + + @Override + public UnaryCallable importUserEventsCallable() { + return importUserEventsCallable; + } + + @Override + public OperationCallable + importUserEventsOperationCallable() { + return importUserEventsOperationCallable; + } + + @Override + public UnaryCallable rejoinUserEventsCallable() { + return rejoinUserEventsCallable; + } + + @Override + public OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable() { + return rejoinUserEventsOperationCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/PredictionServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/PredictionServiceStubSettings.java index edc0d9e1..4cb6f0fd 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/PredictionServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/PredictionServiceStubSettings.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; @@ -97,6 +100,11 @@ public PredictionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcPredictionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonPredictionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -129,18 +137,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(PredictionServiceStubSettings.class)) @@ -148,11 +163,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(PredictionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PredictionServiceStubSettings.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); @@ -242,6 +276,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 .predictSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStub.java index 5f5f0e8f..a3f6076d 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStub.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStub.java @@ -66,7 +66,11 @@ public abstract class ProductServiceStub 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 createProductCallable() { diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStubSettings.java index c8b64468..2e084492 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStubSettings.java @@ -28,6 +28,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; @@ -339,6 +342,11 @@ public ProductServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcProductServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonProductServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -371,18 +379,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(ProductServiceStubSettings.class)) @@ -390,11 +405,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(ProductServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ProductServiceStubSettings.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); @@ -629,6 +663,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 .createProductSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/SearchServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/SearchServiceStubSettings.java index 8d50bddf..f75f284e 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/SearchServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/SearchServiceStubSettings.java @@ -27,6 +27,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.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -158,6 +161,11 @@ public SearchServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSearchServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSearchServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -190,18 +198,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(SearchServiceStubSettings.class)) @@ -209,11 +224,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(SearchServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SearchServiceStubSettings.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); @@ -304,6 +338,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 .searchSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ServingConfigServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ServingConfigServiceStubSettings.java index 78dd0b11..a1fd03f7 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ServingConfigServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ServingConfigServiceStubSettings.java @@ -27,6 +27,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.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -219,6 +222,11 @@ public ServingConfigServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcServingConfigServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonServingConfigServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -251,18 +259,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(ServingConfigServiceStubSettings.class)) @@ -270,11 +285,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(ServingConfigServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ServingConfigServiceStubSettings.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); @@ -397,6 +431,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 .createServingConfigSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStub.java index ff715613..ffa15cbf 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStub.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStub.java @@ -48,7 +48,11 @@ public abstract class UserEventServiceStub 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 writeUserEventCallable() { diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStubSettings.java index 70384ba3..33f425bf 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStubSettings.java @@ -26,6 +26,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; @@ -164,6 +167,11 @@ public UserEventServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcUserEventServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonUserEventServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -196,18 +204,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(UserEventServiceStubSettings.class)) @@ -215,11 +230,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(UserEventServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return UserEventServiceStubSettings.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); @@ -390,6 +424,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 .writeUserEventSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceClient.java index 32a3f1b7..c9e39df8 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceClient.java @@ -100,6 +100,20 @@ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); * } * + *

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.
+ * CatalogServiceSettings catalogServiceSettings =
+ *     CatalogServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceSettings.java index 071fbcd0..09c6f2b2 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceSettings.java @@ -23,6 +23,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; @@ -162,11 +163,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CatalogServiceStubSettings.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 CatalogServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CatalogServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CatalogServiceStubSettings.defaultTransportChannelProvider(); } @@ -176,11 +184,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CatalogServiceStubSettings.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); @@ -218,6 +232,11 @@ private static Builder createDefault() { return new Builder(CatalogServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CatalogServiceStubSettings.newHttpJsonBuilder()); + } + public CatalogServiceStubSettings.Builder getStubSettingsBuilder() { return ((CatalogServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceClient.java index cb4be1ee..2f7eb20b 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceClient.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.retail.v2beta.stub.CompletionServiceStub; import com.google.cloud.retail.v2beta.stub.CompletionServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -108,6 +108,21 @@ * CompletionServiceClient.create(completionServiceSettings); * } * + *

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.
+ * CompletionServiceSettings completionServiceSettings =
+ *     CompletionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CompletionServiceClient completionServiceClient =
+ *     CompletionServiceClient.create(completionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -115,7 +130,8 @@ public class CompletionServiceClient implements BackgroundResource { private final CompletionServiceSettings settings; private final CompletionServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of CompletionServiceClient with default settings. */ public static final CompletionServiceClient create() throws IOException { @@ -147,13 +163,17 @@ public static final CompletionServiceClient create(CompletionServiceStub stub) { protected CompletionServiceClient(CompletionServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((CompletionServiceStubSettings) 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()); } protected CompletionServiceClient(CompletionServiceStub 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 CompletionServiceSettings getSettings() { @@ -168,10 +188,18 @@ public CompletionServiceStub 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. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Completes the specified prefix with keyword suggestions. diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceSettings.java index c6d4c94a..8d7abe19 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceSettings.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; @@ -114,11 +115,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CompletionServiceStubSettings.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 CompletionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CompletionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CompletionServiceStubSettings.defaultTransportChannelProvider(); } @@ -128,11 +136,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CompletionServiceStubSettings.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); @@ -170,6 +184,11 @@ private static Builder createDefault() { return new Builder(CompletionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CompletionServiceStubSettings.newHttpJsonBuilder()); + } + public CompletionServiceStubSettings.Builder getStubSettingsBuilder() { return ((CompletionServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceClient.java index 6de06b99..f4639666 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceClient.java @@ -101,6 +101,20 @@ * ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); * } * + *

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.
+ * ControlServiceSettings controlServiceSettings =
+ *     ControlServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ControlServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceSettings.java index bf76392d..dad65f88 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceSettings.java @@ -23,6 +23,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; @@ -124,11 +125,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ControlServiceStubSettings.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 ControlServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ControlServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ControlServiceStubSettings.defaultTransportChannelProvider(); } @@ -138,11 +146,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ControlServiceStubSettings.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); @@ -180,6 +194,11 @@ private static Builder createDefault() { return new Builder(ControlServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ControlServiceStubSettings.newHttpJsonBuilder()); + } + public ControlServiceStubSettings.Builder getStubSettingsBuilder() { return ((ControlServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceClient.java index 6819b8ca..d7f3b524 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceClient.java @@ -102,6 +102,21 @@ * PredictionServiceClient.create(predictionServiceSettings); * } * + *

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.
+ * PredictionServiceSettings predictionServiceSettings =
+ *     PredictionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * PredictionServiceClient predictionServiceClient =
+ *     PredictionServiceClient.create(predictionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceSettings.java index f822c478..540b33d9 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceSettings.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; @@ -99,11 +100,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return PredictionServiceStubSettings.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 PredictionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return PredictionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return PredictionServiceStubSettings.defaultTransportChannelProvider(); } @@ -113,11 +121,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return PredictionServiceStubSettings.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); @@ -155,6 +169,11 @@ private static Builder createDefault() { return new Builder(PredictionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(PredictionServiceStubSettings.newHttpJsonBuilder()); + } + public PredictionServiceStubSettings.Builder getStubSettingsBuilder() { return ((PredictionServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceClient.java index 57c536d2..137157fa 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceClient.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.retail.v2beta.stub.ProductServiceStubSettings; 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; @@ -106,6 +106,20 @@ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); * } * + *

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.
+ * ProductServiceSettings productServiceSettings =
+ *     ProductServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -113,7 +127,8 @@ public class ProductServiceClient implements BackgroundResource { private final ProductServiceSettings settings; private final ProductServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ProductServiceClient with default settings. */ public static final ProductServiceClient create() throws IOException { @@ -145,13 +160,17 @@ public static final ProductServiceClient create(ProductServiceStub stub) { protected ProductServiceClient(ProductServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((ProductServiceStubSettings) 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()); } protected ProductServiceClient(ProductServiceStub 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 ProductServiceSettings getSettings() { @@ -166,10 +185,18 @@ public ProductServiceStub 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. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a [Product][google.cloud.retail.v2beta.Product]. diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceSettings.java index fb3b0c17..0beba68d 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceSettings.java @@ -23,6 +23,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; @@ -204,11 +205,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ProductServiceStubSettings.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 ProductServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ProductServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ProductServiceStubSettings.defaultTransportChannelProvider(); } @@ -218,11 +226,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ProductServiceStubSettings.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); @@ -260,6 +274,11 @@ private static Builder createDefault() { return new Builder(ProductServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ProductServiceStubSettings.newHttpJsonBuilder()); + } + public ProductServiceStubSettings.Builder getStubSettingsBuilder() { return ((ProductServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceClient.java index 49c69616..c2c045a2 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceClient.java @@ -123,6 +123,20 @@ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); * } * + *

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.
+ * SearchServiceSettings searchServiceSettings =
+ *     SearchServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceSettings.java index 2546b5a7..408f51be 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceSettings.java @@ -23,6 +23,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; @@ -101,11 +102,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SearchServiceStubSettings.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 SearchServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SearchServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SearchServiceStubSettings.defaultTransportChannelProvider(); } @@ -115,11 +123,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SearchServiceStubSettings.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); @@ -157,6 +171,11 @@ private static Builder createDefault() { return new Builder(SearchServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SearchServiceStubSettings.newHttpJsonBuilder()); + } + public SearchServiceStubSettings.Builder getStubSettingsBuilder() { return ((SearchServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceClient.java index 17c513cd..393fbcc8 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceClient.java @@ -106,6 +106,21 @@ * ServingConfigServiceClient.create(servingConfigServiceSettings); * } * + *

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.
+ * ServingConfigServiceSettings servingConfigServiceSettings =
+ *     ServingConfigServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ServingConfigServiceClient servingConfigServiceClient =
+ *     ServingConfigServiceClient.create(servingConfigServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceSettings.java index 60d56863..641d2d3f 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceSettings.java @@ -23,6 +23,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; @@ -138,11 +139,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ServingConfigServiceStubSettings.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 ServingConfigServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ServingConfigServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ServingConfigServiceStubSettings.defaultTransportChannelProvider(); } @@ -152,11 +160,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ServingConfigServiceStubSettings.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); @@ -195,6 +209,11 @@ private static Builder createDefault() { return new Builder(ServingConfigServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ServingConfigServiceStubSettings.newHttpJsonBuilder()); + } + public ServingConfigServiceStubSettings.Builder getStubSettingsBuilder() { return ((ServingConfigServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceClient.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceClient.java index 7ee1b39c..8454f02b 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceClient.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceClient.java @@ -19,13 +19,13 @@ import com.google.api.HttpBody; 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.retail.v2beta.stub.UserEventServiceStub; import com.google.cloud.retail.v2beta.stub.UserEventServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -101,6 +101,21 @@ * UserEventServiceClient.create(userEventServiceSettings); * } * + *

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.
+ * UserEventServiceSettings userEventServiceSettings =
+ *     UserEventServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * UserEventServiceClient userEventServiceClient =
+ *     UserEventServiceClient.create(userEventServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -108,7 +123,8 @@ public class UserEventServiceClient implements BackgroundResource { private final UserEventServiceSettings settings; private final UserEventServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of UserEventServiceClient with default settings. */ public static final UserEventServiceClient create() throws IOException { @@ -140,13 +156,17 @@ public static final UserEventServiceClient create(UserEventServiceStub stub) { protected UserEventServiceClient(UserEventServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((UserEventServiceStubSettings) 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()); } protected UserEventServiceClient(UserEventServiceStub 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 UserEventServiceSettings getSettings() { @@ -161,10 +181,18 @@ public UserEventServiceStub 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. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Writes a single user event. diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceSettings.java index 68ae15b2..527b38cf 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceSettings.java @@ -22,6 +22,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; @@ -141,11 +142,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return UserEventServiceStubSettings.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 UserEventServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return UserEventServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return UserEventServiceStubSettings.defaultTransportChannelProvider(); } @@ -155,11 +163,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return UserEventServiceStubSettings.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); @@ -197,6 +211,11 @@ private static Builder createDefault() { return new Builder(UserEventServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(UserEventServiceStubSettings.newHttpJsonBuilder()); + } + public UserEventServiceStubSettings.Builder getStubSettingsBuilder() { return ((UserEventServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CatalogServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CatalogServiceStubSettings.java index eb8c5830..ea6b765d 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CatalogServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CatalogServiceStubSettings.java @@ -27,6 +27,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.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -252,6 +255,11 @@ public CatalogServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCatalogServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCatalogServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -284,18 +292,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(CatalogServiceStubSettings.class)) @@ -303,11 +318,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(CatalogServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CatalogServiceStubSettings.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); @@ -470,6 +504,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 .listCatalogsSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStub.java index 055478f2..76673725 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStub.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStub.java @@ -40,7 +40,11 @@ public abstract class CompletionServiceStub 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 completeQueryCallable() { diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStubSettings.java index 4fe5cbbc..db28316a 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStubSettings.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; @@ -123,6 +126,11 @@ public CompletionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCompletionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCompletionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -155,18 +163,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(CompletionServiceStubSettings.class)) @@ -174,11 +189,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(CompletionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CompletionServiceStubSettings.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); @@ -284,6 +318,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 .completeQuerySettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ControlServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ControlServiceStubSettings.java index 8014e8b7..70f48e46 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ControlServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ControlServiceStubSettings.java @@ -27,6 +27,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.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -190,6 +193,11 @@ public ControlServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcControlServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonControlServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -222,18 +230,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(ControlServiceStubSettings.class)) @@ -241,11 +256,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(ControlServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ControlServiceStubSettings.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); @@ -350,6 +384,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 .createControlSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceCallableFactory.java new file mode 100644 index 00000000..02be2d9d --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceCallableFactory.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.retail.v2beta.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 CatalogService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCatalogServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceStub.java new file mode 100644 index 00000000..f1021c22 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceStub.java @@ -0,0 +1,769 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.stub; + +import static com.google.cloud.retail.v2beta.CatalogServiceClient.ListCatalogsPagedResponse; + +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.retail.v2beta.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.GetAttributesConfigRequest; +import com.google.cloud.retail.v2beta.GetCompletionConfigRequest; +import com.google.cloud.retail.v2beta.GetDefaultBranchRequest; +import com.google.cloud.retail.v2beta.GetDefaultBranchResponse; +import com.google.cloud.retail.v2beta.ListCatalogsRequest; +import com.google.cloud.retail.v2beta.ListCatalogsResponse; +import com.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest; +import com.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest; +import com.google.cloud.retail.v2beta.SetDefaultBranchRequest; +import com.google.cloud.retail.v2beta.UpdateAttributesConfigRequest; +import com.google.cloud.retail.v2beta.UpdateCatalogRequest; +import com.google.cloud.retail.v2beta.UpdateCompletionConfigRequest; +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 CatalogService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCatalogServiceStub extends CatalogServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listCatalogsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/ListCatalogs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*}/catalogs", + 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(ListCatalogsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateCatalogMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/UpdateCatalog") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{catalog.name=projects/*/locations/*/catalogs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "catalog.name", request.getCatalog().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("catalog", request.getCatalog())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Catalog.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/SetDefaultBranch") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearCatalog().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/GetDefaultBranch") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GetDefaultBranchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getCompletionConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/GetCompletionConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/completionConfig}", + 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(CompletionConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateCompletionConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/UpdateCompletionConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{completionConfig.name=projects/*/locations/*/catalogs/*/completionConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "completionConfig.name", + request.getCompletionConfig().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("completionConfig", request.getCompletionConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompletionConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getAttributesConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/GetAttributesConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/attributesConfig}", + 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(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateAttributesConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/UpdateAttributesConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{attributesConfig.name=projects/*/locations/*/catalogs/*/attributesConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "attributesConfig.name", + request.getAttributesConfig().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("attributesConfig", request.getAttributesConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/AddCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/RemoveCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + replaceCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.CatalogService/ReplaceCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listCatalogsCallable; + private final UnaryCallable + listCatalogsPagedCallable; + private final UnaryCallable updateCatalogCallable; + private final UnaryCallable setDefaultBranchCallable; + private final UnaryCallable + getDefaultBranchCallable; + private final UnaryCallable + getCompletionConfigCallable; + private final UnaryCallable + updateCompletionConfigCallable; + private final UnaryCallable + getAttributesConfigCallable; + private final UnaryCallable + updateAttributesConfigCallable; + private final UnaryCallable + addCatalogAttributeCallable; + private final UnaryCallable + removeCatalogAttributeCallable; + private final UnaryCallable + replaceCatalogAttributeCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCatalogServiceStub create(CatalogServiceStubSettings settings) + throws IOException { + return new HttpJsonCatalogServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCatalogServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCatalogServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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 HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCatalogServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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 HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listCatalogsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listCatalogsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateCatalogTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateCatalogMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getCompletionConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getCompletionConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateCompletionConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateCompletionConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getAttributesConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getAttributesConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateAttributesConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateAttributesConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + replaceCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(replaceCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listCatalogsCallable = + callableFactory.createUnaryCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.listCatalogsPagedCallable = + callableFactory.createPagedCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.updateCatalogCallable = + callableFactory.createUnaryCallable( + updateCatalogTransportSettings, settings.updateCatalogSettings(), clientContext); + this.setDefaultBranchCallable = + callableFactory.createUnaryCallable( + setDefaultBranchTransportSettings, settings.setDefaultBranchSettings(), clientContext); + this.getDefaultBranchCallable = + callableFactory.createUnaryCallable( + getDefaultBranchTransportSettings, settings.getDefaultBranchSettings(), clientContext); + this.getCompletionConfigCallable = + callableFactory.createUnaryCallable( + getCompletionConfigTransportSettings, + settings.getCompletionConfigSettings(), + clientContext); + this.updateCompletionConfigCallable = + callableFactory.createUnaryCallable( + updateCompletionConfigTransportSettings, + settings.updateCompletionConfigSettings(), + clientContext); + this.getAttributesConfigCallable = + callableFactory.createUnaryCallable( + getAttributesConfigTransportSettings, + settings.getAttributesConfigSettings(), + clientContext); + this.updateAttributesConfigCallable = + callableFactory.createUnaryCallable( + updateAttributesConfigTransportSettings, + settings.updateAttributesConfigSettings(), + clientContext); + this.addCatalogAttributeCallable = + callableFactory.createUnaryCallable( + addCatalogAttributeTransportSettings, + settings.addCatalogAttributeSettings(), + clientContext); + this.removeCatalogAttributeCallable = + callableFactory.createUnaryCallable( + removeCatalogAttributeTransportSettings, + settings.removeCatalogAttributeSettings(), + clientContext); + this.replaceCatalogAttributeCallable = + callableFactory.createUnaryCallable( + replaceCatalogAttributeTransportSettings, + settings.replaceCatalogAttributeSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listCatalogsMethodDescriptor); + methodDescriptors.add(updateCatalogMethodDescriptor); + methodDescriptors.add(setDefaultBranchMethodDescriptor); + methodDescriptors.add(getDefaultBranchMethodDescriptor); + methodDescriptors.add(getCompletionConfigMethodDescriptor); + methodDescriptors.add(updateCompletionConfigMethodDescriptor); + methodDescriptors.add(getAttributesConfigMethodDescriptor); + methodDescriptors.add(updateAttributesConfigMethodDescriptor); + methodDescriptors.add(addCatalogAttributeMethodDescriptor); + methodDescriptors.add(removeCatalogAttributeMethodDescriptor); + methodDescriptors.add(replaceCatalogAttributeMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listCatalogsCallable() { + return listCatalogsCallable; + } + + @Override + public UnaryCallable listCatalogsPagedCallable() { + return listCatalogsPagedCallable; + } + + @Override + public UnaryCallable updateCatalogCallable() { + return updateCatalogCallable; + } + + @Override + public UnaryCallable setDefaultBranchCallable() { + return setDefaultBranchCallable; + } + + @Override + public UnaryCallable + getDefaultBranchCallable() { + return getDefaultBranchCallable; + } + + @Override + public UnaryCallable getCompletionConfigCallable() { + return getCompletionConfigCallable; + } + + @Override + public UnaryCallable + updateCompletionConfigCallable() { + return updateCompletionConfigCallable; + } + + @Override + public UnaryCallable getAttributesConfigCallable() { + return getAttributesConfigCallable; + } + + @Override + public UnaryCallable + updateAttributesConfigCallable() { + return updateAttributesConfigCallable; + } + + @Override + public UnaryCallable addCatalogAttributeCallable() { + return addCatalogAttributeCallable; + } + + @Override + public UnaryCallable + removeCatalogAttributeCallable() { + return removeCatalogAttributeCallable; + } + + @Override + public UnaryCallable + replaceCatalogAttributeCallable() { + return replaceCatalogAttributeCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceCallableFactory.java new file mode 100644 index 00000000..b60b3b26 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceCallableFactory.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.retail.v2beta.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 CompletionService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCompletionServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceStub.java new file mode 100644 index 00000000..7fe1921c --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceStub.java @@ -0,0 +1,292 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.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.retail.v2beta.CompleteQueryRequest; +import com.google.cloud.retail.v2beta.CompleteQueryResponse; +import com.google.cloud.retail.v2beta.ImportCompletionDataRequest; +import com.google.cloud.retail.v2beta.ImportCompletionDataResponse; +import com.google.cloud.retail.v2beta.ImportMetadata; +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 CompletionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCompletionServiceStub extends CompletionServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportMetadata.getDescriptor()) + .add(ImportCompletionDataResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + completeQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CompletionService/CompleteQuery") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:completeQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "dataset", request.getDataset()); + serializer.putQueryParam(fields, "deviceType", request.getDeviceType()); + serializer.putQueryParam( + fields, "languageCodes", request.getLanguageCodesList()); + serializer.putQueryParam( + fields, "maxSuggestions", request.getMaxSuggestions()); + serializer.putQueryParam(fields, "query", request.getQuery()); + serializer.putQueryParam(fields, "visitorId", request.getVisitorId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompleteQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + importCompletionDataMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.CompletionService/ImportCompletionData") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/completionData: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( + (ImportCompletionDataRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable completeQueryCallable; + private final UnaryCallable importCompletionDataCallable; + private final OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCompletionServiceStub create(CompletionServiceStubSettings settings) + throws IOException { + return new HttpJsonCompletionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCompletionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCompletionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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 HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCompletionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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 HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + completeQueryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(completeQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + importCompletionDataTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importCompletionDataMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.completeQueryCallable = + callableFactory.createUnaryCallable( + completeQueryTransportSettings, settings.completeQuerySettings(), clientContext); + this.importCompletionDataCallable = + callableFactory.createUnaryCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataSettings(), + clientContext); + this.importCompletionDataOperationCallable = + callableFactory.createOperationCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(completeQueryMethodDescriptor); + methodDescriptors.add(importCompletionDataMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable completeQueryCallable() { + return completeQueryCallable; + } + + @Override + public UnaryCallable importCompletionDataCallable() { + return importCompletionDataCallable; + } + + @Override + public OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable() { + return importCompletionDataOperationCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceCallableFactory.java new file mode 100644 index 00000000..596a6db1 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceCallableFactory.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.retail.v2beta.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 ControlService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonControlServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceStub.java new file mode 100644 index 00000000..cb2b790c --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceStub.java @@ -0,0 +1,410 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.stub; + +import static com.google.cloud.retail.v2beta.ControlServiceClient.ListControlsPagedResponse; + +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.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.CreateControlRequest; +import com.google.cloud.retail.v2beta.DeleteControlRequest; +import com.google.cloud.retail.v2beta.GetControlRequest; +import com.google.cloud.retail.v2beta.ListControlsRequest; +import com.google.cloud.retail.v2beta.ListControlsResponse; +import com.google.cloud.retail.v2beta.UpdateControlRequest; +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 ControlService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonControlServiceStub extends ControlServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ControlService/CreateControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls", + 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, "controlId", request.getControlId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("control", request.getControl())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ControlService/DeleteControl") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}", + 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 + updateControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ControlService/UpdateControl") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{control.name=projects/*/locations/*/catalogs/*/controls/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "control.name", request.getControl().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("control", request.getControl())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ControlService/GetControl") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}", + 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(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listControlsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ControlService/ListControls") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls", + 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, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListControlsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createControlCallable; + private final UnaryCallable deleteControlCallable; + private final UnaryCallable updateControlCallable; + private final UnaryCallable getControlCallable; + private final UnaryCallable listControlsCallable; + private final UnaryCallable + listControlsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonControlServiceStub create(ControlServiceStubSettings settings) + throws IOException { + return new HttpJsonControlServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonControlServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonControlServiceStub( + ControlServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonControlServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonControlServiceStub( + ControlServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonControlServiceStub, 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 HttpJsonControlServiceStub( + ControlServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonControlServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonControlServiceStub, 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 HttpJsonControlServiceStub( + ControlServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listControlsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listControlsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createControlCallable = + callableFactory.createUnaryCallable( + createControlTransportSettings, settings.createControlSettings(), clientContext); + this.deleteControlCallable = + callableFactory.createUnaryCallable( + deleteControlTransportSettings, settings.deleteControlSettings(), clientContext); + this.updateControlCallable = + callableFactory.createUnaryCallable( + updateControlTransportSettings, settings.updateControlSettings(), clientContext); + this.getControlCallable = + callableFactory.createUnaryCallable( + getControlTransportSettings, settings.getControlSettings(), clientContext); + this.listControlsCallable = + callableFactory.createUnaryCallable( + listControlsTransportSettings, settings.listControlsSettings(), clientContext); + this.listControlsPagedCallable = + callableFactory.createPagedCallable( + listControlsTransportSettings, settings.listControlsSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createControlMethodDescriptor); + methodDescriptors.add(deleteControlMethodDescriptor); + methodDescriptors.add(updateControlMethodDescriptor); + methodDescriptors.add(getControlMethodDescriptor); + methodDescriptors.add(listControlsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createControlCallable() { + return createControlCallable; + } + + @Override + public UnaryCallable deleteControlCallable() { + return deleteControlCallable; + } + + @Override + public UnaryCallable updateControlCallable() { + return updateControlCallable; + } + + @Override + public UnaryCallable getControlCallable() { + return getControlCallable; + } + + @Override + public UnaryCallable listControlsCallable() { + return listControlsCallable; + } + + @Override + public UnaryCallable listControlsPagedCallable() { + return listControlsPagedCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceCallableFactory.java new file mode 100644 index 00000000..040d5d1c --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceCallableFactory.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.retail.v2beta.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 PredictionService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPredictionServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceStub.java new file mode 100644 index 00000000..56364869 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceStub.java @@ -0,0 +1,194 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.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.retail.v2beta.PredictRequest; +import com.google.cloud.retail.v2beta.PredictResponse; +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 PredictionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPredictionServiceStub extends PredictionServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + predictMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.PredictionService/Predict") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PredictResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable predictCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonPredictionServiceStub create(PredictionServiceStubSettings settings) + throws IOException { + return new HttpJsonPredictionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonPredictionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonPredictionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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 HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonPredictionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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 HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings predictTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(predictMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.predictCallable = + callableFactory.createUnaryCallable( + predictTransportSettings, settings.predictSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(predictMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable predictCallable() { + return predictCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceCallableFactory.java new file mode 100644 index 00000000..e04094ad --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceCallableFactory.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.retail.v2beta.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 ProductService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceStub.java new file mode 100644 index 00000000..91057013 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceStub.java @@ -0,0 +1,896 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.stub; + +import static com.google.cloud.retail.v2beta.ProductServiceClient.ListProductsPagedResponse; + +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.retail.v2beta.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2beta.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.CreateProductRequest; +import com.google.cloud.retail.v2beta.DeleteProductRequest; +import com.google.cloud.retail.v2beta.GetProductRequest; +import com.google.cloud.retail.v2beta.ImportMetadata; +import com.google.cloud.retail.v2beta.ImportProductsRequest; +import com.google.cloud.retail.v2beta.ImportProductsResponse; +import com.google.cloud.retail.v2beta.ListProductsRequest; +import com.google.cloud.retail.v2beta.ListProductsResponse; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.SetInventoryMetadata; +import com.google.cloud.retail.v2beta.SetInventoryRequest; +import com.google.cloud.retail.v2beta.SetInventoryResponse; +import com.google.cloud.retail.v2beta.UpdateProductRequest; +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 ProductService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductServiceStub extends ProductServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(RemoveLocalInventoriesResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .add(AddFulfillmentPlacesMetadata.getDescriptor()) + .add(ImportProductsResponse.getDescriptor()) + .add(SetInventoryResponse.getDescriptor()) + .add(AddLocalInventoriesMetadata.getDescriptor()) + .add(RemoveFulfillmentPlacesMetadata.getDescriptor()) + .add(AddFulfillmentPlacesResponse.getDescriptor()) + .add(SetInventoryMetadata.getDescriptor()) + .add(RemoveFulfillmentPlacesResponse.getDescriptor()) + .add(AddLocalInventoriesResponse.getDescriptor()) + .add(RemoveLocalInventoriesMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/CreateProduct") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/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 getProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/GetProduct") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/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 + listProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/ListProducts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/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, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readMask", request.getReadMask()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/UpdateProduct") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{product.name=projects/*/locations/*/catalogs/*/branches/*/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, "allowMissing", request.getAllowMissing()); + 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.retail.v2beta.ProductService/DeleteProduct") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/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 + importProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/ImportProducts") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products: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( + (ImportProductsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + setInventoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/SetInventory") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "inventory.name", request.getInventory().getName()); + 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( + (SetInventoryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/AddFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.ProductService/RemoveFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/AddLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/RemoveLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createProductCallable; + private final UnaryCallable getProductCallable; + private final UnaryCallable listProductsCallable; + private final UnaryCallable + listProductsPagedCallable; + private final UnaryCallable updateProductCallable; + private final UnaryCallable deleteProductCallable; + private final UnaryCallable importProductsCallable; + private final OperationCallable + importProductsOperationCallable; + private final UnaryCallable setInventoryCallable; + private final OperationCallable + setInventoryOperationCallable; + private final UnaryCallable addFulfillmentPlacesCallable; + private final OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable; + private final UnaryCallable + removeFulfillmentPlacesCallable; + private final OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable; + private final UnaryCallable addLocalInventoriesCallable; + private final OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable; + private final UnaryCallable + removeLocalInventoriesCallable; + private final OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonProductServiceStub create(ProductServiceStubSettings settings) + throws IOException { + return new HttpJsonProductServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonProductServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonProductServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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 HttpJsonProductServiceStub( + ProductServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonProductServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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 HttpJsonProductServiceStub( + ProductServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setInventoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setInventoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createProductCallable = + callableFactory.createUnaryCallable( + createProductTransportSettings, settings.createProductSettings(), clientContext); + this.getProductCallable = + callableFactory.createUnaryCallable( + getProductTransportSettings, settings.getProductSettings(), clientContext); + this.listProductsCallable = + callableFactory.createUnaryCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.listProductsPagedCallable = + callableFactory.createPagedCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.updateProductCallable = + callableFactory.createUnaryCallable( + updateProductTransportSettings, settings.updateProductSettings(), clientContext); + this.deleteProductCallable = + callableFactory.createUnaryCallable( + deleteProductTransportSettings, settings.deleteProductSettings(), clientContext); + this.importProductsCallable = + callableFactory.createUnaryCallable( + importProductsTransportSettings, settings.importProductsSettings(), clientContext); + this.importProductsOperationCallable = + callableFactory.createOperationCallable( + importProductsTransportSettings, + settings.importProductsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.setInventoryCallable = + callableFactory.createUnaryCallable( + setInventoryTransportSettings, settings.setInventorySettings(), clientContext); + this.setInventoryOperationCallable = + callableFactory.createOperationCallable( + setInventoryTransportSettings, + settings.setInventoryOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesSettings(), + clientContext); + this.addFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesSettings(), + clientContext); + this.removeFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addLocalInventoriesCallable = + callableFactory.createUnaryCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesSettings(), + clientContext); + this.addLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeLocalInventoriesCallable = + callableFactory.createUnaryCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesSettings(), + clientContext); + this.removeLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createProductMethodDescriptor); + methodDescriptors.add(getProductMethodDescriptor); + methodDescriptors.add(listProductsMethodDescriptor); + methodDescriptors.add(updateProductMethodDescriptor); + methodDescriptors.add(deleteProductMethodDescriptor); + methodDescriptors.add(importProductsMethodDescriptor); + methodDescriptors.add(setInventoryMethodDescriptor); + methodDescriptors.add(addFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(removeFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(addLocalInventoriesMethodDescriptor); + methodDescriptors.add(removeLocalInventoriesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createProductCallable() { + return createProductCallable; + } + + @Override + public UnaryCallable getProductCallable() { + return getProductCallable; + } + + @Override + public UnaryCallable listProductsCallable() { + return listProductsCallable; + } + + @Override + public UnaryCallable listProductsPagedCallable() { + return listProductsPagedCallable; + } + + @Override + public UnaryCallable updateProductCallable() { + return updateProductCallable; + } + + @Override + public UnaryCallable deleteProductCallable() { + return deleteProductCallable; + } + + @Override + public UnaryCallable importProductsCallable() { + return importProductsCallable; + } + + @Override + public OperationCallable + importProductsOperationCallable() { + return importProductsOperationCallable; + } + + @Override + public UnaryCallable setInventoryCallable() { + return setInventoryCallable; + } + + @Override + public OperationCallable + setInventoryOperationCallable() { + return setInventoryOperationCallable; + } + + @Override + public UnaryCallable addFulfillmentPlacesCallable() { + return addFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable() { + return addFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable + removeFulfillmentPlacesCallable() { + return removeFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable() { + return removeFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable addLocalInventoriesCallable() { + return addLocalInventoriesCallable; + } + + @Override + public OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable() { + return addLocalInventoriesOperationCallable; + } + + @Override + public UnaryCallable removeLocalInventoriesCallable() { + return removeLocalInventoriesCallable; + } + + @Override + public OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable() { + return removeLocalInventoriesOperationCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceCallableFactory.java new file mode 100644 index 00000000..68b6b4b9 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceCallableFactory.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.retail.v2beta.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 SearchService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSearchServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceStub.java new file mode 100644 index 00000000..01eb416d --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceStub.java @@ -0,0 +1,204 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.stub; + +import static com.google.cloud.retail.v2beta.SearchServiceClient.SearchPagedResponse; + +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.retail.v2beta.SearchRequest; +import com.google.cloud.retail.v2beta.SearchResponse; +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 SearchService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSearchServiceStub extends SearchServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor searchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.SearchService/Search") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SearchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable searchCallable; + private final UnaryCallable searchPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSearchServiceStub create(SearchServiceStubSettings settings) + throws IOException { + return new HttpJsonSearchServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSearchServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSearchServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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 HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSearchServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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 HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings searchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(searchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.searchCallable = + callableFactory.createUnaryCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + this.searchPagedCallable = + callableFactory.createPagedCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(searchMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable searchCallable() { + return searchCallable; + } + + @Override + public UnaryCallable searchPagedCallable() { + return searchPagedCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceCallableFactory.java new file mode 100644 index 00000000..fc8281bf --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceCallableFactory.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.retail.v2beta.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 ServingConfigService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonServingConfigServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceStub.java new file mode 100644 index 00000000..26f39556 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceStub.java @@ -0,0 +1,543 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.stub; + +import static com.google.cloud.retail.v2beta.ServingConfigServiceClient.ListServingConfigsPagedResponse; + +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.retail.v2beta.AddControlRequest; +import com.google.cloud.retail.v2beta.CreateServingConfigRequest; +import com.google.cloud.retail.v2beta.DeleteServingConfigRequest; +import com.google.cloud.retail.v2beta.GetServingConfigRequest; +import com.google.cloud.retail.v2beta.ListServingConfigsRequest; +import com.google.cloud.retail.v2beta.ListServingConfigsResponse; +import com.google.cloud.retail.v2beta.RemoveControlRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.UpdateServingConfigRequest; +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 ServingConfigService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonServingConfigServiceStub extends ServingConfigServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.ServingConfigService/CreateServingConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + 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, "servingConfigId", request.getServingConfigId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("servingConfig", request.getServingConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.ServingConfigService/DeleteServingConfig") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + 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 + updateServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.ServingConfigService/UpdateServingConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{servingConfig.name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig.name", request.getServingConfig().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("servingConfig", request.getServingConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ServingConfigService/GetServingConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + 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(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listServingConfigsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.ServingConfigService/ListServingConfigs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + 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(ListServingConfigsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ServingConfigService/AddControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{servingConfig=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig", request.getServingConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServingConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ServingConfigService/RemoveControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{servingConfig=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig", request.getServingConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServingConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + createServingConfigCallable; + private final UnaryCallable deleteServingConfigCallable; + private final UnaryCallable + updateServingConfigCallable; + private final UnaryCallable getServingConfigCallable; + private final UnaryCallable + listServingConfigsCallable; + private final UnaryCallable + listServingConfigsPagedCallable; + private final UnaryCallable addControlCallable; + private final UnaryCallable removeControlCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonServingConfigServiceStub create( + ServingConfigServiceStubSettings settings) throws IOException { + return new HttpJsonServingConfigServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonServingConfigServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonServingConfigServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonServingConfigServiceStub, 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 HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonServingConfigServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonServingConfigServiceStub, 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 HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + createServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listServingConfigsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listServingConfigsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings addControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings removeControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createServingConfigCallable = + callableFactory.createUnaryCallable( + createServingConfigTransportSettings, + settings.createServingConfigSettings(), + clientContext); + this.deleteServingConfigCallable = + callableFactory.createUnaryCallable( + deleteServingConfigTransportSettings, + settings.deleteServingConfigSettings(), + clientContext); + this.updateServingConfigCallable = + callableFactory.createUnaryCallable( + updateServingConfigTransportSettings, + settings.updateServingConfigSettings(), + clientContext); + this.getServingConfigCallable = + callableFactory.createUnaryCallable( + getServingConfigTransportSettings, settings.getServingConfigSettings(), clientContext); + this.listServingConfigsCallable = + callableFactory.createUnaryCallable( + listServingConfigsTransportSettings, + settings.listServingConfigsSettings(), + clientContext); + this.listServingConfigsPagedCallable = + callableFactory.createPagedCallable( + listServingConfigsTransportSettings, + settings.listServingConfigsSettings(), + clientContext); + this.addControlCallable = + callableFactory.createUnaryCallable( + addControlTransportSettings, settings.addControlSettings(), clientContext); + this.removeControlCallable = + callableFactory.createUnaryCallable( + removeControlTransportSettings, settings.removeControlSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createServingConfigMethodDescriptor); + methodDescriptors.add(deleteServingConfigMethodDescriptor); + methodDescriptors.add(updateServingConfigMethodDescriptor); + methodDescriptors.add(getServingConfigMethodDescriptor); + methodDescriptors.add(listServingConfigsMethodDescriptor); + methodDescriptors.add(addControlMethodDescriptor); + methodDescriptors.add(removeControlMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createServingConfigCallable() { + return createServingConfigCallable; + } + + @Override + public UnaryCallable deleteServingConfigCallable() { + return deleteServingConfigCallable; + } + + @Override + public UnaryCallable updateServingConfigCallable() { + return updateServingConfigCallable; + } + + @Override + public UnaryCallable getServingConfigCallable() { + return getServingConfigCallable; + } + + @Override + public UnaryCallable + listServingConfigsCallable() { + return listServingConfigsCallable; + } + + @Override + public UnaryCallable + listServingConfigsPagedCallable() { + return listServingConfigsPagedCallable; + } + + @Override + public UnaryCallable addControlCallable() { + return addControlCallable; + } + + @Override + public UnaryCallable removeControlCallable() { + return removeControlCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceCallableFactory.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceCallableFactory.java new file mode 100644 index 00000000..8b4856cf --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceCallableFactory.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.retail.v2beta.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 UserEventService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonUserEventServiceCallableFactory + 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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceStub.java new file mode 100644 index 00000000..743bdbd1 --- /dev/null +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceStub.java @@ -0,0 +1,481 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.HttpBody; +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.retail.v2beta.CollectUserEventRequest; +import com.google.cloud.retail.v2beta.ImportMetadata; +import com.google.cloud.retail.v2beta.ImportUserEventsRequest; +import com.google.cloud.retail.v2beta.ImportUserEventsResponse; +import com.google.cloud.retail.v2beta.PurgeMetadata; +import com.google.cloud.retail.v2beta.PurgeUserEventsRequest; +import com.google.cloud.retail.v2beta.PurgeUserEventsResponse; +import com.google.cloud.retail.v2beta.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2beta.RejoinUserEventsRequest; +import com.google.cloud.retail.v2beta.RejoinUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEvent; +import com.google.cloud.retail.v2beta.WriteUserEventRequest; +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 UserEventService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonUserEventServiceStub extends UserEventServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportMetadata.getDescriptor()) + .add(PurgeMetadata.getDescriptor()) + .add(ImportUserEventsResponse.getDescriptor()) + .add(RejoinUserEventsMetadata.getDescriptor()) + .add(RejoinUserEventsResponse.getDescriptor()) + .add(PurgeUserEventsResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + writeUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.UserEventService/WriteUserEvent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + 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("userEvent", request.getUserEvent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UserEvent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + collectUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.UserEventService/CollectUserEvent") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect", + 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, "ets", request.getEts()); + serializer.putQueryParam(fields, "uri", request.getUri()); + serializer.putQueryParam(fields, "userEvent", request.getUserEvent()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(HttpBody.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + purgeUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.UserEventService/PurgeUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents: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( + (PurgeUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.UserEventService/ImportUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents: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( + (ImportUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + rejoinUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.UserEventService/RejoinUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + 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( + (RejoinUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable writeUserEventCallable; + private final UnaryCallable collectUserEventCallable; + private final UnaryCallable purgeUserEventsCallable; + private final OperationCallable + purgeUserEventsOperationCallable; + private final UnaryCallable importUserEventsCallable; + private final OperationCallable + importUserEventsOperationCallable; + private final UnaryCallable rejoinUserEventsCallable; + private final OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonUserEventServiceStub create(UserEventServiceStubSettings settings) + throws IOException { + return new HttpJsonUserEventServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonUserEventServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonUserEventServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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 HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonUserEventServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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 HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings writeUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(writeUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings collectUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(collectUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings purgeUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(purgeUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings rejoinUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(rejoinUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.writeUserEventCallable = + callableFactory.createUnaryCallable( + writeUserEventTransportSettings, settings.writeUserEventSettings(), clientContext); + this.collectUserEventCallable = + callableFactory.createUnaryCallable( + collectUserEventTransportSettings, settings.collectUserEventSettings(), clientContext); + this.purgeUserEventsCallable = + callableFactory.createUnaryCallable( + purgeUserEventsTransportSettings, settings.purgeUserEventsSettings(), clientContext); + this.purgeUserEventsOperationCallable = + callableFactory.createOperationCallable( + purgeUserEventsTransportSettings, + settings.purgeUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importUserEventsCallable = + callableFactory.createUnaryCallable( + importUserEventsTransportSettings, settings.importUserEventsSettings(), clientContext); + this.importUserEventsOperationCallable = + callableFactory.createOperationCallable( + importUserEventsTransportSettings, + settings.importUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.rejoinUserEventsCallable = + callableFactory.createUnaryCallable( + rejoinUserEventsTransportSettings, settings.rejoinUserEventsSettings(), clientContext); + this.rejoinUserEventsOperationCallable = + callableFactory.createOperationCallable( + rejoinUserEventsTransportSettings, + settings.rejoinUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(writeUserEventMethodDescriptor); + methodDescriptors.add(collectUserEventMethodDescriptor); + methodDescriptors.add(purgeUserEventsMethodDescriptor); + methodDescriptors.add(importUserEventsMethodDescriptor); + methodDescriptors.add(rejoinUserEventsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable writeUserEventCallable() { + return writeUserEventCallable; + } + + @Override + public UnaryCallable collectUserEventCallable() { + return collectUserEventCallable; + } + + @Override + public UnaryCallable purgeUserEventsCallable() { + return purgeUserEventsCallable; + } + + @Override + public OperationCallable + purgeUserEventsOperationCallable() { + return purgeUserEventsOperationCallable; + } + + @Override + public UnaryCallable importUserEventsCallable() { + return importUserEventsCallable; + } + + @Override + public OperationCallable + importUserEventsOperationCallable() { + return importUserEventsOperationCallable; + } + + @Override + public UnaryCallable rejoinUserEventsCallable() { + return rejoinUserEventsCallable; + } + + @Override + public OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable() { + return rejoinUserEventsOperationCallable; + } + + @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-retail/src/main/java/com/google/cloud/retail/v2beta/stub/PredictionServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/PredictionServiceStubSettings.java index 3af1061b..241806eb 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/PredictionServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/PredictionServiceStubSettings.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; @@ -97,6 +100,11 @@ public PredictionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcPredictionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonPredictionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -129,18 +137,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(PredictionServiceStubSettings.class)) @@ -148,11 +163,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(PredictionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PredictionServiceStubSettings.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); @@ -242,6 +276,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 .predictSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStub.java index 52979a6a..2d3264f2 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStub.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStub.java @@ -63,7 +63,11 @@ public abstract class ProductServiceStub 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 createProductCallable() { diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStubSettings.java index 2a16e4e8..502ecab7 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStubSettings.java @@ -28,6 +28,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; @@ -321,6 +324,11 @@ public ProductServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcProductServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonProductServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -353,18 +361,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(ProductServiceStubSettings.class)) @@ -372,11 +387,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(ProductServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ProductServiceStubSettings.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); @@ -599,6 +633,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 .createProductSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/SearchServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/SearchServiceStubSettings.java index 5f1296a4..ac829cbe 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/SearchServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/SearchServiceStubSettings.java @@ -27,6 +27,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.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -158,6 +161,11 @@ public SearchServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSearchServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSearchServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -190,18 +198,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(SearchServiceStubSettings.class)) @@ -209,11 +224,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(SearchServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SearchServiceStubSettings.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); @@ -304,6 +338,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 .searchSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ServingConfigServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ServingConfigServiceStubSettings.java index 8b39f4b4..94504ec4 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ServingConfigServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ServingConfigServiceStubSettings.java @@ -27,6 +27,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.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -219,6 +222,11 @@ public ServingConfigServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcServingConfigServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonServingConfigServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -251,18 +259,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(ServingConfigServiceStubSettings.class)) @@ -270,11 +285,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(ServingConfigServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ServingConfigServiceStubSettings.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); @@ -397,6 +431,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 .createServingConfigSettings() diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStub.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStub.java index d1661d09..9b664359 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStub.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStub.java @@ -48,7 +48,11 @@ public abstract class UserEventServiceStub 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 writeUserEventCallable() { diff --git a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStubSettings.java b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStubSettings.java index 7fb8a01c..94c823c4 100644 --- a/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStubSettings.java +++ b/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStubSettings.java @@ -26,6 +26,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; @@ -164,6 +167,11 @@ public UserEventServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcUserEventServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonUserEventServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -196,18 +204,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(UserEventServiceStubSettings.class)) @@ -215,11 +230,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(UserEventServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return UserEventServiceStubSettings.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); @@ -390,6 +424,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 .writeUserEventSettings() diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CatalogServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CatalogServiceClientHttpJsonTest.java new file mode 100644 index 00000000..2dfe6eba --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CatalogServiceClientHttpJsonTest.java @@ -0,0 +1,410 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2; + +import static com.google.cloud.retail.v2.CatalogServiceClient.ListCatalogsPagedResponse; + +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.retail.v2.stub.HttpJsonCatalogServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +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 CatalogServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CatalogServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCatalogServiceStub.getMethodDescriptors(), + CatalogServiceSettings.getDefaultEndpoint()); + CatalogServiceSettings settings = + CatalogServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CatalogServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listCatalogsTest() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().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 listCatalogsExceptionTest() 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.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listCatalogsTest2() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().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 listCatalogsExceptionTest2() 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.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateCatalogTest() throws Exception { + Catalog expectedResponse = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Catalog actualResponse = client.updateCatalog(catalog, 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 updateCatalogExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateCatalog(catalog, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + client.setDefaultBranch(catalog); + + 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 setDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + client.setDefaultBranch(catalog); + + 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 setDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + 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 getDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest2() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + 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 getDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CompletionServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CompletionServiceClientHttpJsonTest.java new file mode 100644 index 00000000..b41da0f2 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CompletionServiceClientHttpJsonTest.java @@ -0,0 +1,201 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2; + +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.retail.v2.stub.HttpJsonCompletionServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.rpc.Status; +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 CompletionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CompletionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCompletionServiceStub.getMethodDescriptors(), + CompletionServiceSettings.getDefaultEndpoint()); + CompletionServiceSettings settings = + CompletionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CompletionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void completeQueryTest() throws Exception { + CompleteQueryResponse expectedResponse = + CompleteQueryResponse.newBuilder() + .addAllCompletionResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllRecentSearchResults(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + + CompleteQueryResponse actualResponse = client.completeQuery(request); + 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 completeQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + client.completeQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importCompletionDataTest() throws Exception { + ImportCompletionDataResponse expectedResponse = + ImportCompletionDataResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importCompletionDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportCompletionDataResponse actualResponse = client.importCompletionDataAsync(request).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 importCompletionDataExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importCompletionDataAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/PredictionServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/PredictionServiceClientHttpJsonTest.java new file mode 100644 index 00000000..35ec335a --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/PredictionServiceClientHttpJsonTest.java @@ -0,0 +1,145 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2; + +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.retail.v2.stub.HttpJsonPredictionServiceStub; +import com.google.protobuf.Value; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +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 PredictionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static PredictionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonPredictionServiceStub.getMethodDescriptors(), + PredictionServiceSettings.getDefaultEndpoint()); + PredictionServiceSettings settings = + PredictionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PredictionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void predictTest() throws Exception { + PredictResponse expectedResponse = + PredictResponse.newBuilder() + .addAllResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllMissingIds(new ArrayList()) + .setValidateOnly(true) + .build(); + mockService.addResponse(expectedResponse); + + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + + PredictResponse actualResponse = client.predict(request); + 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 predictExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + client.predict(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/ProductServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/ProductServiceClientHttpJsonTest.java new file mode 100644 index 00000000..d6d5296c --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/ProductServiceClientHttpJsonTest.java @@ -0,0 +1,1300 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2; + +import static com.google.cloud.retail.v2.ProductServiceClient.ListProductsPagedResponse; + +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.retail.v2.stub.HttpJsonProductServiceStub; +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.Int32Value; +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.HashMap; +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 ProductServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ProductServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonProductServiceStub.getMethodDescriptors(), + ProductServiceSettings.getDefaultEndpoint()); + ProductServiceSettings settings = + ProductServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ProductServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + 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 { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + 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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + 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-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + 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 getProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[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]", "[CATALOG]", "[BRANCH]", "[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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + 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-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.getProduct(name); + 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); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + + 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 { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + 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-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + + 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-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + client.listProducts(parent); + 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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Product product = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(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]", "[CATALOG]", "[BRANCH]", "[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]", "[CATALOG]", "[BRANCH]", "[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-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + 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-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importProductsTest() throws Exception { + ImportProductsResponse expectedResponse = + ImportProductsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportProductsResponse actualResponse = client.importProductsAsync(request).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 importProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importProductsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void setInventoryTest() throws Exception { + SetInventoryResponse expectedResponse = SetInventoryResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("setInventoryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + + SetInventoryResponse actualResponse = client.setInventoryAsync(inventory, setMask).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 setInventoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + client.setInventoryAsync(inventory, setMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).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 addFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest2() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).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 addFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).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 removeFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest2() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).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 removeFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).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 addLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest2() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).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 addLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).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 removeLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest2() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).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 removeLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/SearchServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/SearchServiceClientHttpJsonTest.java new file mode 100644 index 00000000..38e50c21 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/SearchServiceClientHttpJsonTest.java @@ -0,0 +1,177 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2; + +import static com.google.cloud.retail.v2.SearchServiceClient.SearchPagedResponse; + +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.retail.v2.stub.HttpJsonSearchServiceStub; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +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 SearchServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static SearchServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSearchServiceStub.getMethodDescriptors(), + SearchServiceSettings.getDefaultEndpoint()); + SearchServiceSettings settings = + SearchServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SearchServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void searchTest() throws Exception { + SearchResponse.SearchResult responsesElement = SearchResponse.SearchResult.newBuilder().build(); + SearchResponse expectedResponse = + SearchResponse.newBuilder() + .setNextPageToken("") + .addAllResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .putAllLabels(new HashMap()) + .setSpellCorrectionSpec(SearchRequest.SpellCorrectionSpec.newBuilder().build()) + .build(); + + SearchPagedResponse pagedListResponse = client.search(request); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getResultsList().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 searchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .putAllLabels(new HashMap()) + .setSpellCorrectionSpec(SearchRequest.SpellCorrectionSpec.newBuilder().build()) + .build(); + client.search(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/UserEventServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/UserEventServiceClientHttpJsonTest.java new file mode 100644 index 00000000..73544d3f --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/UserEventServiceClientHttpJsonTest.java @@ -0,0 +1,382 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2; + +import com.google.api.HttpBody; +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.retail.v2.stub.HttpJsonUserEventServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +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 UserEventServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static UserEventServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonUserEventServiceStub.getMethodDescriptors(), + UserEventServiceSettings.getDefaultEndpoint()); + UserEventServiceSettings settings = + UserEventServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = UserEventServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void writeUserEventTest() throws Exception { + UserEvent expectedResponse = + UserEvent.newBuilder() + .setEventType("eventType31430900") + .setVisitorId("visitorId1880545833") + .setSessionId("sessionId607796817") + .setEventTime(Timestamp.newBuilder().build()) + .addAllExperimentIds(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllProductDetails(new ArrayList()) + .setCompletionDetail(CompletionDetail.newBuilder().build()) + .putAllAttributes(new HashMap()) + .setCartId("cartId-1367589797") + .setPurchaseTransaction(PurchaseTransaction.newBuilder().build()) + .setSearchQuery("searchQuery-552137728") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setOffset(-1019779949) + .addAllPageCategories(new ArrayList()) + .setUserInfo(UserInfo.newBuilder().build()) + .setUri("uri116076") + .setReferrerUri("referrerUri348088525") + .setPageViewId("pageViewId1362499087") + .build(); + mockService.addResponse(expectedResponse); + + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + + UserEvent actualResponse = client.writeUserEvent(request); + 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 writeUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + client.writeUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void collectUserEventTest() throws Exception { + HttpBody expectedResponse = + HttpBody.newBuilder() + .setContentType("contentType-389131437") + .setData(ByteString.EMPTY) + .addAllExtensions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + + HttpBody actualResponse = client.collectUserEvent(request); + 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 collectUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + client.collectUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void purgeUserEventsTest() throws Exception { + PurgeUserEventsResponse expectedResponse = + PurgeUserEventsResponse.newBuilder().setPurgedEventsCount(-310774833).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + + PurgeUserEventsResponse actualResponse = client.purgeUserEventsAsync(request).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 purgeUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + client.purgeUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importUserEventsTest() throws Exception { + ImportUserEventsResponse expectedResponse = + ImportUserEventsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setImportSummary(UserEventImportSummary.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + + ImportUserEventsResponse actualResponse = client.importUserEventsAsync(request).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 importUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + client.importUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void rejoinUserEventsTest() throws Exception { + RejoinUserEventsResponse expectedResponse = + RejoinUserEventsResponse.newBuilder().setRejoinedUserEventsCount(-1152281574).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("rejoinUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + + RejoinUserEventsResponse actualResponse = client.rejoinUserEventsAsync(request).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 rejoinUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + client.rejoinUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CatalogServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CatalogServiceClientHttpJsonTest.java new file mode 100644 index 00000000..0356ab45 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CatalogServiceClientHttpJsonTest.java @@ -0,0 +1,928 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha; + +import static com.google.cloud.retail.v2alpha.CatalogServiceClient.ListCatalogsPagedResponse; + +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.retail.v2alpha.stub.HttpJsonCatalogServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +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 CatalogServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CatalogServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCatalogServiceStub.getMethodDescriptors(), + CatalogServiceSettings.getDefaultEndpoint()); + CatalogServiceSettings settings = + CatalogServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CatalogServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listCatalogsTest() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().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 listCatalogsExceptionTest() 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.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listCatalogsTest2() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().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 listCatalogsExceptionTest2() 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.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateCatalogTest() throws Exception { + Catalog expectedResponse = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Catalog actualResponse = client.updateCatalog(catalog, 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 updateCatalogExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateCatalog(catalog, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + client.setDefaultBranch(catalog); + + 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 setDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + client.setDefaultBranch(catalog); + + 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 setDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + 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 getDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest2() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + 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 getDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getCompletionConfigTest() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + CompletionConfig actualResponse = client.getCompletionConfig(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 getCompletionConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getCompletionConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getCompletionConfigTest2() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6627/locations/location-6627/catalogs/catalog-6627/completionConfig"; + + CompletionConfig actualResponse = client.getCompletionConfig(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 getCompletionConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6627/locations/location-6627/catalogs/catalog-6627/completionConfig"; + client.getCompletionConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateCompletionConfigTest() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + CompletionConfig completionConfig = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + CompletionConfig actualResponse = client.updateCompletionConfig(completionConfig, 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 updateCompletionConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompletionConfig completionConfig = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateCompletionConfig(completionConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAttributesConfigTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + AttributesConfig actualResponse = client.getAttributesConfig(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 getAttributesConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getAttributesConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAttributesConfigTest2() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9790/locations/location-9790/catalogs/catalog-9790/attributesConfig"; + + AttributesConfig actualResponse = client.getAttributesConfig(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 getAttributesConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9790/locations/location-9790/catalogs/catalog-9790/attributesConfig"; + client.getAttributesConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateAttributesConfigTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AttributesConfig attributesConfig = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + AttributesConfig actualResponse = client.updateAttributesConfig(attributesConfig, 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 updateAttributesConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AttributesConfig attributesConfig = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateAttributesConfig(attributesConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + + AttributesConfig actualResponse = client.addCatalogAttribute(request); + 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 addCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + client.addCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + + AttributesConfig actualResponse = client.removeCatalogAttribute(request); + 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 removeCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + client.removeCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void replaceCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + AttributesConfig actualResponse = client.replaceCatalogAttribute(request); + 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 replaceCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.replaceCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CompletionServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CompletionServiceClientHttpJsonTest.java new file mode 100644 index 00000000..e35582ea --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CompletionServiceClientHttpJsonTest.java @@ -0,0 +1,201 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha; + +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.retail.v2alpha.stub.HttpJsonCompletionServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.rpc.Status; +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 CompletionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CompletionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCompletionServiceStub.getMethodDescriptors(), + CompletionServiceSettings.getDefaultEndpoint()); + CompletionServiceSettings settings = + CompletionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CompletionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void completeQueryTest() throws Exception { + CompleteQueryResponse expectedResponse = + CompleteQueryResponse.newBuilder() + .addAllCompletionResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllRecentSearchResults(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + + CompleteQueryResponse actualResponse = client.completeQuery(request); + 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 completeQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + client.completeQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importCompletionDataTest() throws Exception { + ImportCompletionDataResponse expectedResponse = + ImportCompletionDataResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importCompletionDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportCompletionDataResponse actualResponse = client.importCompletionDataAsync(request).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 importCompletionDataExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importCompletionDataAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ControlServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ControlServiceClientHttpJsonTest.java new file mode 100644 index 00000000..e02761d6 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ControlServiceClientHttpJsonTest.java @@ -0,0 +1,529 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha; + +import static com.google.cloud.retail.v2alpha.ControlServiceClient.ListControlsPagedResponse; + +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.retail.v2alpha.stub.HttpJsonControlServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +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 ControlServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ControlServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonControlServiceStub.getMethodDescriptors(), + ControlServiceSettings.getDefaultEndpoint()); + ControlServiceSettings settings = + ControlServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ControlServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ControlServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + + Control actualResponse = client.createControl(parent, control, controlId); + 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 createControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + client.createControl(parent, control, controlId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createControlTest2() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + + Control actualResponse = client.createControl(parent, control, controlId); + 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 createControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + client.createControl(parent, control, controlId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteControlTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + + client.deleteControl(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 deleteControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + client.deleteControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteControlTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + + client.deleteControl(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 deleteControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + client.deleteControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Control control = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Control actualResponse = client.updateControl(control, 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 updateControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Control control = + Control.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateControl(control, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + + Control actualResponse = client.getControl(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 getControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + client.getControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getControlTest2() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + + Control actualResponse = client.getControl(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 getControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + client.getControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listControlsTest() throws Exception { + Control responsesElement = Control.newBuilder().build(); + ListControlsResponse expectedResponse = + ListControlsResponse.newBuilder() + .setNextPageToken("") + .addAllControls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + ListControlsPagedResponse pagedListResponse = client.listControls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getControlsList().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 listControlsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.listControls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listControlsTest2() throws Exception { + Control responsesElement = Control.newBuilder().build(); + ListControlsResponse expectedResponse = + ListControlsResponse.newBuilder() + .setNextPageToken("") + .addAllControls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + + ListControlsPagedResponse pagedListResponse = client.listControls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getControlsList().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 listControlsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + client.listControls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/PredictionServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/PredictionServiceClientHttpJsonTest.java new file mode 100644 index 00000000..45375173 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/PredictionServiceClientHttpJsonTest.java @@ -0,0 +1,145 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha; + +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.retail.v2alpha.stub.HttpJsonPredictionServiceStub; +import com.google.protobuf.Value; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +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 PredictionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static PredictionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonPredictionServiceStub.getMethodDescriptors(), + PredictionServiceSettings.getDefaultEndpoint()); + PredictionServiceSettings settings = + PredictionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PredictionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void predictTest() throws Exception { + PredictResponse expectedResponse = + PredictResponse.newBuilder() + .addAllResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllMissingIds(new ArrayList()) + .setValidateOnly(true) + .build(); + mockService.addResponse(expectedResponse); + + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + + PredictResponse actualResponse = client.predict(request); + 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 predictExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + client.predict(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ProductServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ProductServiceClientHttpJsonTest.java new file mode 100644 index 00000000..41f64d76 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ProductServiceClientHttpJsonTest.java @@ -0,0 +1,1361 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha; + +import static com.google.cloud.retail.v2alpha.ProductServiceClient.ListProductsPagedResponse; + +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.retail.v2alpha.stub.HttpJsonProductServiceStub; +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.Int32Value; +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.HashMap; +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 ProductServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ProductServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonProductServiceStub.getMethodDescriptors(), + ProductServiceSettings.getDefaultEndpoint()); + ProductServiceSettings settings = + ProductServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ProductServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + 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 { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + 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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + 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-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + 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 getProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[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]", "[CATALOG]", "[BRANCH]", "[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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + 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-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.getProduct(name); + 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); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + + 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 { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + 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-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + + 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-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + client.listProducts(parent); + 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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Product product = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(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]", "[CATALOG]", "[BRANCH]", "[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]", "[CATALOG]", "[BRANCH]", "[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-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + 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-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void purgeProductsTest() throws Exception { + PurgeProductsResponse expectedResponse = + PurgeProductsResponse.newBuilder() + .setPurgeCount(575305851) + .addAllPurgeSample(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + + PurgeProductsResponse actualResponse = client.purgeProductsAsync(request).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 purgeProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + client.purgeProductsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importProductsTest() throws Exception { + ImportProductsResponse expectedResponse = + ImportProductsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportProductsResponse actualResponse = client.importProductsAsync(request).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 importProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importProductsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void setInventoryTest() throws Exception { + SetInventoryResponse expectedResponse = SetInventoryResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("setInventoryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + + SetInventoryResponse actualResponse = client.setInventoryAsync(inventory, setMask).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 setInventoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + client.setInventoryAsync(inventory, setMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).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 addFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest2() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).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 addFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).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 removeFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest2() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).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 removeFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).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 addLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest2() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).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 addLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).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 removeLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest2() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).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 removeLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/SearchServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/SearchServiceClientHttpJsonTest.java new file mode 100644 index 00000000..508ee667 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/SearchServiceClientHttpJsonTest.java @@ -0,0 +1,172 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha; + +import static com.google.cloud.retail.v2alpha.SearchServiceClient.SearchPagedResponse; + +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.retail.v2alpha.stub.HttpJsonSearchServiceStub; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +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 SearchServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static SearchServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSearchServiceStub.getMethodDescriptors(), + SearchServiceSettings.getDefaultEndpoint()); + SearchServiceSettings settings = + SearchServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SearchServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void searchTest() throws Exception { + SearchResponse.SearchResult responsesElement = SearchResponse.SearchResult.newBuilder().build(); + SearchResponse expectedResponse = + SearchResponse.newBuilder() + .setNextPageToken("") + .addAllResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + + SearchPagedResponse pagedListResponse = client.search(request); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getResultsList().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 searchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + client.search(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClientHttpJsonTest.java new file mode 100644 index 00000000..25d4041d --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClientHttpJsonTest.java @@ -0,0 +1,888 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha; + +import static com.google.cloud.retail.v2alpha.ServingConfigServiceClient.ListServingConfigsPagedResponse; + +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.retail.v2alpha.stub.HttpJsonServingConfigServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +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 ServingConfigServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ServingConfigServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonServingConfigServiceStub.getMethodDescriptors(), + ServingConfigServiceSettings.getDefaultEndpoint()); + ServingConfigServiceSettings settings = + ServingConfigServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ServingConfigServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + + ServingConfig actualResponse = + client.createServingConfig(parent, servingConfig, servingConfigId); + 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 createServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServingConfigTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + + ServingConfig actualResponse = + client.createServingConfig(parent, servingConfig, servingConfigId); + 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 createServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServingConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + client.deleteServingConfig(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 deleteServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.deleteServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServingConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + + client.deleteServingConfig(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 deleteServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + client.deleteServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfig servingConfig = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ServingConfig actualResponse = client.updateServingConfig(servingConfig, 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 updateServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfig servingConfig = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateServingConfig(servingConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.getServingConfig(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 getServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.getServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServingConfigTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + + ServingConfig actualResponse = client.getServingConfig(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 getServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + client.getServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServingConfigsTest() throws Exception { + ServingConfig responsesElement = ServingConfig.newBuilder().build(); + ListServingConfigsResponse expectedResponse = + ListServingConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllServingConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + ListServingConfigsPagedResponse pagedListResponse = client.listServingConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServingConfigsList().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 listServingConfigsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.listServingConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServingConfigsTest2() throws Exception { + ServingConfig responsesElement = ServingConfig.newBuilder().build(); + ListServingConfigsResponse expectedResponse = + ListServingConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllServingConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + + ListServingConfigsPagedResponse pagedListResponse = client.listServingConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServingConfigsList().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 listServingConfigsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + client.listServingConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addControlTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.addControl(servingConfig); + 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 addControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.addControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addControlTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + + ServingConfig actualResponse = client.addControl(servingConfig); + 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 addControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + client.addControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeControlTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.removeControl(servingConfig); + 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 removeControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.removeControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeControlTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + + ServingConfig actualResponse = client.removeControl(servingConfig); + 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 removeControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + client.removeControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/UserEventServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/UserEventServiceClientHttpJsonTest.java new file mode 100644 index 00000000..27f1e1c4 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/UserEventServiceClientHttpJsonTest.java @@ -0,0 +1,382 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha; + +import com.google.api.HttpBody; +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.retail.v2alpha.stub.HttpJsonUserEventServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +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 UserEventServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static UserEventServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonUserEventServiceStub.getMethodDescriptors(), + UserEventServiceSettings.getDefaultEndpoint()); + UserEventServiceSettings settings = + UserEventServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = UserEventServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void writeUserEventTest() throws Exception { + UserEvent expectedResponse = + UserEvent.newBuilder() + .setEventType("eventType31430900") + .setVisitorId("visitorId1880545833") + .setSessionId("sessionId607796817") + .setEventTime(Timestamp.newBuilder().build()) + .addAllExperimentIds(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllProductDetails(new ArrayList()) + .setCompletionDetail(CompletionDetail.newBuilder().build()) + .putAllAttributes(new HashMap()) + .setCartId("cartId-1367589797") + .setPurchaseTransaction(PurchaseTransaction.newBuilder().build()) + .setSearchQuery("searchQuery-552137728") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setOffset(-1019779949) + .addAllPageCategories(new ArrayList()) + .setUserInfo(UserInfo.newBuilder().build()) + .setUri("uri116076") + .setReferrerUri("referrerUri348088525") + .setPageViewId("pageViewId1362499087") + .build(); + mockService.addResponse(expectedResponse); + + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + + UserEvent actualResponse = client.writeUserEvent(request); + 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 writeUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + client.writeUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void collectUserEventTest() throws Exception { + HttpBody expectedResponse = + HttpBody.newBuilder() + .setContentType("contentType-389131437") + .setData(ByteString.EMPTY) + .addAllExtensions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + + HttpBody actualResponse = client.collectUserEvent(request); + 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 collectUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + client.collectUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void purgeUserEventsTest() throws Exception { + PurgeUserEventsResponse expectedResponse = + PurgeUserEventsResponse.newBuilder().setPurgedEventsCount(-310774833).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + + PurgeUserEventsResponse actualResponse = client.purgeUserEventsAsync(request).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 purgeUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + client.purgeUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importUserEventsTest() throws Exception { + ImportUserEventsResponse expectedResponse = + ImportUserEventsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setImportSummary(UserEventImportSummary.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + + ImportUserEventsResponse actualResponse = client.importUserEventsAsync(request).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 importUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + client.importUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void rejoinUserEventsTest() throws Exception { + RejoinUserEventsResponse expectedResponse = + RejoinUserEventsResponse.newBuilder().setRejoinedUserEventsCount(-1152281574).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("rejoinUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + + RejoinUserEventsResponse actualResponse = client.rejoinUserEventsAsync(request).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 rejoinUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + client.rejoinUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CatalogServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CatalogServiceClientHttpJsonTest.java new file mode 100644 index 00000000..83ae3ee5 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CatalogServiceClientHttpJsonTest.java @@ -0,0 +1,928 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta; + +import static com.google.cloud.retail.v2beta.CatalogServiceClient.ListCatalogsPagedResponse; + +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.retail.v2beta.stub.HttpJsonCatalogServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +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 CatalogServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CatalogServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCatalogServiceStub.getMethodDescriptors(), + CatalogServiceSettings.getDefaultEndpoint()); + CatalogServiceSettings settings = + CatalogServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CatalogServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listCatalogsTest() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().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 listCatalogsExceptionTest() 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.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listCatalogsTest2() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().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 listCatalogsExceptionTest2() 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.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateCatalogTest() throws Exception { + Catalog expectedResponse = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Catalog actualResponse = client.updateCatalog(catalog, 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 updateCatalogExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateCatalog(catalog, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + client.setDefaultBranch(catalog); + + 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 setDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + client.setDefaultBranch(catalog); + + 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 setDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + 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 getDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest2() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + 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 getDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getCompletionConfigTest() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + CompletionConfig actualResponse = client.getCompletionConfig(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 getCompletionConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getCompletionConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getCompletionConfigTest2() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6627/locations/location-6627/catalogs/catalog-6627/completionConfig"; + + CompletionConfig actualResponse = client.getCompletionConfig(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 getCompletionConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6627/locations/location-6627/catalogs/catalog-6627/completionConfig"; + client.getCompletionConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateCompletionConfigTest() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + CompletionConfig completionConfig = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + CompletionConfig actualResponse = client.updateCompletionConfig(completionConfig, 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 updateCompletionConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompletionConfig completionConfig = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateCompletionConfig(completionConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAttributesConfigTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + AttributesConfig actualResponse = client.getAttributesConfig(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 getAttributesConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getAttributesConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAttributesConfigTest2() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9790/locations/location-9790/catalogs/catalog-9790/attributesConfig"; + + AttributesConfig actualResponse = client.getAttributesConfig(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 getAttributesConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9790/locations/location-9790/catalogs/catalog-9790/attributesConfig"; + client.getAttributesConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateAttributesConfigTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AttributesConfig attributesConfig = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + AttributesConfig actualResponse = client.updateAttributesConfig(attributesConfig, 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 updateAttributesConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AttributesConfig attributesConfig = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateAttributesConfig(attributesConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + + AttributesConfig actualResponse = client.addCatalogAttribute(request); + 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 addCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + client.addCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + + AttributesConfig actualResponse = client.removeCatalogAttribute(request); + 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 removeCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + client.removeCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void replaceCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + AttributesConfig actualResponse = client.replaceCatalogAttribute(request); + 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 replaceCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.replaceCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CompletionServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CompletionServiceClientHttpJsonTest.java new file mode 100644 index 00000000..286acd1f --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CompletionServiceClientHttpJsonTest.java @@ -0,0 +1,201 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta; + +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.retail.v2beta.stub.HttpJsonCompletionServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.rpc.Status; +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 CompletionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CompletionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCompletionServiceStub.getMethodDescriptors(), + CompletionServiceSettings.getDefaultEndpoint()); + CompletionServiceSettings settings = + CompletionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CompletionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void completeQueryTest() throws Exception { + CompleteQueryResponse expectedResponse = + CompleteQueryResponse.newBuilder() + .addAllCompletionResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllRecentSearchResults(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + + CompleteQueryResponse actualResponse = client.completeQuery(request); + 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 completeQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + client.completeQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importCompletionDataTest() throws Exception { + ImportCompletionDataResponse expectedResponse = + ImportCompletionDataResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importCompletionDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportCompletionDataResponse actualResponse = client.importCompletionDataAsync(request).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 importCompletionDataExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importCompletionDataAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ControlServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ControlServiceClientHttpJsonTest.java new file mode 100644 index 00000000..78d3f2e4 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ControlServiceClientHttpJsonTest.java @@ -0,0 +1,522 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta; + +import static com.google.cloud.retail.v2beta.ControlServiceClient.ListControlsPagedResponse; + +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.retail.v2beta.stub.HttpJsonControlServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +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 ControlServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ControlServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonControlServiceStub.getMethodDescriptors(), + ControlServiceSettings.getDefaultEndpoint()); + ControlServiceSettings settings = + ControlServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ControlServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ControlServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + + Control actualResponse = client.createControl(parent, control, controlId); + 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 createControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + client.createControl(parent, control, controlId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createControlTest2() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + + Control actualResponse = client.createControl(parent, control, controlId); + 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 createControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + client.createControl(parent, control, controlId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteControlTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + + client.deleteControl(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 deleteControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + client.deleteControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteControlTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + + client.deleteControl(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 deleteControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + client.deleteControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Control control = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Control actualResponse = client.updateControl(control, 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 updateControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Control control = + Control.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateControl(control, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + + Control actualResponse = client.getControl(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 getControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + client.getControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getControlTest2() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + + Control actualResponse = client.getControl(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 getControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + client.getControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listControlsTest() throws Exception { + Control responsesElement = Control.newBuilder().build(); + ListControlsResponse expectedResponse = + ListControlsResponse.newBuilder() + .setNextPageToken("") + .addAllControls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + ListControlsPagedResponse pagedListResponse = client.listControls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getControlsList().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 listControlsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.listControls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listControlsTest2() throws Exception { + Control responsesElement = Control.newBuilder().build(); + ListControlsResponse expectedResponse = + ListControlsResponse.newBuilder() + .setNextPageToken("") + .addAllControls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + + ListControlsPagedResponse pagedListResponse = client.listControls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getControlsList().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 listControlsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + client.listControls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/PredictionServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/PredictionServiceClientHttpJsonTest.java new file mode 100644 index 00000000..db9a6ead --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/PredictionServiceClientHttpJsonTest.java @@ -0,0 +1,145 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta; + +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.retail.v2beta.stub.HttpJsonPredictionServiceStub; +import com.google.protobuf.Value; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +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 PredictionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static PredictionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonPredictionServiceStub.getMethodDescriptors(), + PredictionServiceSettings.getDefaultEndpoint()); + PredictionServiceSettings settings = + PredictionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PredictionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void predictTest() throws Exception { + PredictResponse expectedResponse = + PredictResponse.newBuilder() + .addAllResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllMissingIds(new ArrayList()) + .setValidateOnly(true) + .build(); + mockService.addResponse(expectedResponse); + + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + + PredictResponse actualResponse = client.predict(request); + 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 predictExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + client.predict(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ProductServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ProductServiceClientHttpJsonTest.java new file mode 100644 index 00000000..ae36ae72 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ProductServiceClientHttpJsonTest.java @@ -0,0 +1,1300 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta; + +import static com.google.cloud.retail.v2beta.ProductServiceClient.ListProductsPagedResponse; + +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.retail.v2beta.stub.HttpJsonProductServiceStub; +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.Int32Value; +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.HashMap; +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 ProductServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ProductServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonProductServiceStub.getMethodDescriptors(), + ProductServiceSettings.getDefaultEndpoint()); + ProductServiceSettings settings = + ProductServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ProductServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + 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 { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + 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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + 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-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + 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 getProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[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]", "[CATALOG]", "[BRANCH]", "[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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + 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-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.getProduct(name); + 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); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + + 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 { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + 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-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + + 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-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + client.listProducts(parent); + 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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Product product = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(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]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(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]", "[CATALOG]", "[BRANCH]", "[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]", "[CATALOG]", "[BRANCH]", "[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-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + 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-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importProductsTest() throws Exception { + ImportProductsResponse expectedResponse = + ImportProductsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportProductsResponse actualResponse = client.importProductsAsync(request).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 importProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importProductsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void setInventoryTest() throws Exception { + SetInventoryResponse expectedResponse = SetInventoryResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("setInventoryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + + SetInventoryResponse actualResponse = client.setInventoryAsync(inventory, setMask).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 setInventoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + client.setInventoryAsync(inventory, setMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).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 addFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest2() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).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 addFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).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 removeFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest2() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).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 removeFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).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 addLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest2() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).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 addLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).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 removeLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest2() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).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 removeLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/SearchServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/SearchServiceClientHttpJsonTest.java new file mode 100644 index 00000000..c2e28c52 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/SearchServiceClientHttpJsonTest.java @@ -0,0 +1,172 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta; + +import static com.google.cloud.retail.v2beta.SearchServiceClient.SearchPagedResponse; + +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.retail.v2beta.stub.HttpJsonSearchServiceStub; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +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 SearchServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static SearchServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSearchServiceStub.getMethodDescriptors(), + SearchServiceSettings.getDefaultEndpoint()); + SearchServiceSettings settings = + SearchServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SearchServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void searchTest() throws Exception { + SearchResponse.SearchResult responsesElement = SearchResponse.SearchResult.newBuilder().build(); + SearchResponse expectedResponse = + SearchResponse.newBuilder() + .setNextPageToken("") + .addAllResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + + SearchPagedResponse pagedListResponse = client.search(request); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getResultsList().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 searchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + client.search(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ServingConfigServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ServingConfigServiceClientHttpJsonTest.java new file mode 100644 index 00000000..218b82d1 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ServingConfigServiceClientHttpJsonTest.java @@ -0,0 +1,888 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta; + +import static com.google.cloud.retail.v2beta.ServingConfigServiceClient.ListServingConfigsPagedResponse; + +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.retail.v2beta.stub.HttpJsonServingConfigServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +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 ServingConfigServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ServingConfigServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonServingConfigServiceStub.getMethodDescriptors(), + ServingConfigServiceSettings.getDefaultEndpoint()); + ServingConfigServiceSettings settings = + ServingConfigServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ServingConfigServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + + ServingConfig actualResponse = + client.createServingConfig(parent, servingConfig, servingConfigId); + 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 createServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServingConfigTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + + ServingConfig actualResponse = + client.createServingConfig(parent, servingConfig, servingConfigId); + 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 createServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServingConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + client.deleteServingConfig(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 deleteServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.deleteServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServingConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + + client.deleteServingConfig(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 deleteServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + client.deleteServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfig servingConfig = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ServingConfig actualResponse = client.updateServingConfig(servingConfig, 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 updateServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfig servingConfig = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateServingConfig(servingConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.getServingConfig(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 getServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.getServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServingConfigTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + + ServingConfig actualResponse = client.getServingConfig(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 getServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + client.getServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServingConfigsTest() throws Exception { + ServingConfig responsesElement = ServingConfig.newBuilder().build(); + ListServingConfigsResponse expectedResponse = + ListServingConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllServingConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + ListServingConfigsPagedResponse pagedListResponse = client.listServingConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServingConfigsList().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 listServingConfigsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.listServingConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServingConfigsTest2() throws Exception { + ServingConfig responsesElement = ServingConfig.newBuilder().build(); + ListServingConfigsResponse expectedResponse = + ListServingConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllServingConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + + ListServingConfigsPagedResponse pagedListResponse = client.listServingConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServingConfigsList().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 listServingConfigsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + client.listServingConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addControlTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.addControl(servingConfig); + 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 addControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.addControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addControlTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + + ServingConfig actualResponse = client.addControl(servingConfig); + 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 addControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + client.addControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeControlTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.removeControl(servingConfig); + 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 removeControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.removeControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeControlTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + + ServingConfig actualResponse = client.removeControl(servingConfig); + 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 removeControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + client.removeControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/UserEventServiceClientHttpJsonTest.java b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/UserEventServiceClientHttpJsonTest.java new file mode 100644 index 00000000..3cb9e378 --- /dev/null +++ b/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/UserEventServiceClientHttpJsonTest.java @@ -0,0 +1,382 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta; + +import com.google.api.HttpBody; +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.retail.v2beta.stub.HttpJsonUserEventServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +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 UserEventServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static UserEventServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonUserEventServiceStub.getMethodDescriptors(), + UserEventServiceSettings.getDefaultEndpoint()); + UserEventServiceSettings settings = + UserEventServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = UserEventServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void writeUserEventTest() throws Exception { + UserEvent expectedResponse = + UserEvent.newBuilder() + .setEventType("eventType31430900") + .setVisitorId("visitorId1880545833") + .setSessionId("sessionId607796817") + .setEventTime(Timestamp.newBuilder().build()) + .addAllExperimentIds(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllProductDetails(new ArrayList()) + .setCompletionDetail(CompletionDetail.newBuilder().build()) + .putAllAttributes(new HashMap()) + .setCartId("cartId-1367589797") + .setPurchaseTransaction(PurchaseTransaction.newBuilder().build()) + .setSearchQuery("searchQuery-552137728") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setOffset(-1019779949) + .addAllPageCategories(new ArrayList()) + .setUserInfo(UserInfo.newBuilder().build()) + .setUri("uri116076") + .setReferrerUri("referrerUri348088525") + .setPageViewId("pageViewId1362499087") + .build(); + mockService.addResponse(expectedResponse); + + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + + UserEvent actualResponse = client.writeUserEvent(request); + 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 writeUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + client.writeUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void collectUserEventTest() throws Exception { + HttpBody expectedResponse = + HttpBody.newBuilder() + .setContentType("contentType-389131437") + .setData(ByteString.EMPTY) + .addAllExtensions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + + HttpBody actualResponse = client.collectUserEvent(request); + 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 collectUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + client.collectUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void purgeUserEventsTest() throws Exception { + PurgeUserEventsResponse expectedResponse = + PurgeUserEventsResponse.newBuilder().setPurgedEventsCount(-310774833).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + + PurgeUserEventsResponse actualResponse = client.purgeUserEventsAsync(request).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 purgeUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + client.purgeUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importUserEventsTest() throws Exception { + ImportUserEventsResponse expectedResponse = + ImportUserEventsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setImportSummary(UserEventImportSummary.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + + ImportUserEventsResponse actualResponse = client.importUserEventsAsync(request).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 importUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + client.importUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void rejoinUserEventsTest() throws Exception { + RejoinUserEventsResponse expectedResponse = + RejoinUserEventsResponse.newBuilder().setRejoinedUserEventsCount(-1152281574).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("rejoinUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + + RejoinUserEventsResponse actualResponse = client.rejoinUserEventsAsync(request).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 rejoinUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + client.rejoinUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..213b179d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.CatalogServiceSettings; +import com.google.cloud.retail.v2.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. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2_generated_catalogserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..681344e3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.CatalogServiceSettings; + +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. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2_generated_catalogserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..e0e3954b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.CatalogServiceSettings; +import com.google.cloud.retail.v2.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. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2_generated_catalogserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java new file mode 100644 index 00000000..4623f875 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_getdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.GetDefaultBranchRequest; +import com.google.cloud.retail.v2.GetDefaultBranchResponse; + +public class AsyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncGetDefaultBranch(); + } + + public static void asyncGetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetDefaultBranchRequest request = + GetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + ApiFuture future = + catalogServiceClient.getDefaultBranchCallable().futureCall(request); + // Do something. + GetDefaultBranchResponse response = future.get(); + } + } +} +// [END retail_v2_generated_catalogserviceclient_getdefaultbranch_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java new file mode 100644 index 00000000..f04e784c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_getdefaultbranch_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.GetDefaultBranchRequest; +import com.google.cloud.retail.v2.GetDefaultBranchResponse; + +public class SyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranch(); + } + + public static void syncGetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetDefaultBranchRequest request = + GetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(request); + } + } +} +// [END retail_v2_generated_catalogserviceclient_getdefaultbranch_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java new file mode 100644 index 00000000..777cfc44 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchCatalogname(); + } + + public static void syncGetDefaultBranchCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(catalog); + } + } +} +// [END retail_v2_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java new file mode 100644 index 00000000..f572a6ab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_getdefaultbranch_string_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchString(); + } + + public static void syncGetDefaultBranchString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(catalog); + } + } +} +// [END retail_v2_generated_catalogserviceclient_getdefaultbranch_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogs.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogs.java new file mode 100644 index 00000000..777b11bb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogs.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_listcatalogs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.ListCatalogsRequest; +import com.google.cloud.retail.v2.LocationName; + +public class AsyncListCatalogs { + + public static void main(String[] args) throws Exception { + asyncListCatalogs(); + } + + public static void asyncListCatalogs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ListCatalogsRequest request = + ListCatalogsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + catalogServiceClient.listCatalogsPagedCallable().futureCall(request); + // Do something. + for (Catalog element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_catalogserviceclient_listcatalogs_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java new file mode 100644 index 00000000..da1fe655 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_listcatalogs_paged_async] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.ListCatalogsRequest; +import com.google.cloud.retail.v2.ListCatalogsResponse; +import com.google.cloud.retail.v2.LocationName; +import com.google.common.base.Strings; + +public class AsyncListCatalogsPaged { + + public static void main(String[] args) throws Exception { + asyncListCatalogsPaged(); + } + + public static void asyncListCatalogsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ListCatalogsRequest request = + ListCatalogsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListCatalogsResponse response = catalogServiceClient.listCatalogsCallable().call(request); + for (Catalog element : response.getCatalogsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2_generated_catalogserviceclient_listcatalogs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogs.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogs.java new file mode 100644 index 00000000..0ec31dfc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogs.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_listcatalogs_sync] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.ListCatalogsRequest; +import com.google.cloud.retail.v2.LocationName; + +public class SyncListCatalogs { + + public static void main(String[] args) throws Exception { + syncListCatalogs(); + } + + public static void syncListCatalogs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ListCatalogsRequest request = + ListCatalogsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Catalog element : catalogServiceClient.listCatalogs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_catalogserviceclient_listcatalogs_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java new file mode 100644 index 00000000..1cc7c893 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_listcatalogs_locationname_sync] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.LocationName; + +public class SyncListCatalogsLocationname { + + public static void main(String[] args) throws Exception { + syncListCatalogsLocationname(); + } + + public static void syncListCatalogsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Catalog element : catalogServiceClient.listCatalogs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_catalogserviceclient_listcatalogs_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsString.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsString.java new file mode 100644 index 00000000..b5b5abfe --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsString.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_listcatalogs_string_sync] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.LocationName; + +public class SyncListCatalogsString { + + public static void main(String[] args) throws Exception { + syncListCatalogsString(); + } + + public static void syncListCatalogsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Catalog element : catalogServiceClient.listCatalogs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_catalogserviceclient_listcatalogs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java new file mode 100644 index 00000000..e3555dcb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_setdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class AsyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncSetDefaultBranch(); + } + + public static void asyncSetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + SetDefaultBranchRequest request = + SetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setBranchId( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setNote("note3387378") + .setForce(true) + .build(); + ApiFuture future = catalogServiceClient.setDefaultBranchCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2_generated_catalogserviceclient_setdefaultbranch_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java new file mode 100644 index 00000000..ecab749e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_setdefaultbranch_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranch(); + } + + public static void syncSetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + SetDefaultBranchRequest request = + SetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setBranchId( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setNote("note3387378") + .setForce(true) + .build(); + catalogServiceClient.setDefaultBranch(request); + } + } +} +// [END retail_v2_generated_catalogserviceclient_setdefaultbranch_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java new file mode 100644 index 00000000..eb670199 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchCatalogname(); + } + + public static void syncSetDefaultBranchCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + catalogServiceClient.setDefaultBranch(catalog); + } + } +} +// [END retail_v2_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java new file mode 100644 index 00000000..55407bc0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_setdefaultbranch_string_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchString(); + } + + public static void syncSetDefaultBranchString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + catalogServiceClient.setDefaultBranch(catalog); + } + } +} +// [END retail_v2_generated_catalogserviceclient_setdefaultbranch_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java new file mode 100644 index 00000000..265bbe02 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_updatecatalog_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + asyncUpdateCatalog(); + } + + public static void asyncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCatalogRequest request = + UpdateCatalogRequest.newBuilder() + .setCatalog(Catalog.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = catalogServiceClient.updateCatalogCallable().futureCall(request); + // Do something. + Catalog response = future.get(); + } + } +} +// [END retail_v2_generated_catalogserviceclient_updatecatalog_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 00000000..f16c6391 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalog.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_updatecatalog_sync] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCatalogRequest request = + UpdateCatalogRequest.newBuilder() + .setCatalog(Catalog.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Catalog response = catalogServiceClient.updateCatalog(request); + } + } +} +// [END retail_v2_generated_catalogserviceclient_updatecatalog_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java new file mode 100644 index 00000000..874e774c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.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.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalogCatalogFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateCatalogCatalogFieldmask(); + } + + public static void syncUpdateCatalogCatalogFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + Catalog catalog = Catalog.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Catalog response = catalogServiceClient.updateCatalog(catalog, updateMask); + } + } +} +// [END retail_v2_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 00000000..4234849a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/catalogservicesettings/updatecatalog/SyncUpdateCatalog.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.retail.v2.samples; + +// [START retail_v2_generated_catalogservicesettings_updatecatalog_sync] +import com.google.cloud.retail.v2.CatalogServiceSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_catalogservicesettings_updatecatalog_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/AsyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/AsyncCompleteQuery.java new file mode 100644 index 00000000..8bc7306a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/AsyncCompleteQuery.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_completequery_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CompleteQueryRequest; +import com.google.cloud.retail.v2.CompleteQueryResponse; +import com.google.cloud.retail.v2.CompletionServiceClient; +import java.util.ArrayList; + +public class AsyncCompleteQuery { + + public static void main(String[] args) throws Exception { + asyncCompleteQuery(); + } + + public static void asyncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + ApiFuture future = + completionServiceClient.completeQueryCallable().futureCall(request); + // Do something. + CompleteQueryResponse response = future.get(); + } + } +} +// [END retail_v2_generated_completionserviceclient_completequery_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/SyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/SyncCompleteQuery.java new file mode 100644 index 00000000..374718c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/SyncCompleteQuery.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.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_completequery_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CompleteQueryRequest; +import com.google.cloud.retail.v2.CompleteQueryResponse; +import com.google.cloud.retail.v2.CompletionServiceClient; +import java.util.ArrayList; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + CompleteQueryResponse response = completionServiceClient.completeQuery(request); + } + } +} +// [END retail_v2_generated_completionserviceclient_completequery_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..1160a482 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider.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.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.CompletionServiceSettings; +import com.google.cloud.retail.v2.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. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2_generated_completionserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..d0eb8e1e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider1.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.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.CompletionServiceSettings; + +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. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2_generated_completionserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..7f5bd37d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetEndpoint.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.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.CompletionServiceSettings; +import com.google.cloud.retail.v2.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. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2_generated_completionserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java new file mode 100644 index 00000000..92d0eb44 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionData.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.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_importcompletiondata_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CompletionDataInputConfig; +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.ImportCompletionDataRequest; +import com.google.longrunning.Operation; + +public class AsyncImportCompletionData { + + public static void main(String[] args) throws Exception { + asyncImportCompletionData(); + } + + public static void asyncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + completionServiceClient.importCompletionDataCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_completionserviceclient_importcompletiondata_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java new file mode 100644 index 00000000..4c6d8143 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.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.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_importcompletiondata_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CompletionDataInputConfig; +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.ImportCompletionDataRequest; +import com.google.cloud.retail.v2.ImportCompletionDataResponse; +import com.google.cloud.retail.v2.ImportMetadata; + +public class AsyncImportCompletionDataLRO { + + public static void main(String[] args) throws Exception { + asyncImportCompletionDataLRO(); + } + + public static void asyncImportCompletionDataLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + completionServiceClient.importCompletionDataOperationCallable().futureCall(request); + // Do something. + ImportCompletionDataResponse response = future.get(); + } + } +} +// [END retail_v2_generated_completionserviceclient_importcompletiondata_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/SyncImportCompletionData.java b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/SyncImportCompletionData.java new file mode 100644 index 00000000..0640ce07 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/SyncImportCompletionData.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.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_importcompletiondata_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CompletionDataInputConfig; +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.ImportCompletionDataRequest; +import com.google.cloud.retail.v2.ImportCompletionDataResponse; + +public class SyncImportCompletionData { + + public static void main(String[] args) throws Exception { + syncImportCompletionData(); + } + + public static void syncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportCompletionDataResponse response = + completionServiceClient.importCompletionDataAsync(request).get(); + } + } +} +// [END retail_v2_generated_completionserviceclient_importcompletiondata_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/completionservicesettings/completequery/SyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2/completionservicesettings/completequery/SyncCompleteQuery.java new file mode 100644 index 00000000..ee8cc26f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/completionservicesettings/completequery/SyncCompleteQuery.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.retail.v2.samples; + +// [START retail_v2_generated_completionservicesettings_completequery_sync] +import com.google.cloud.retail.v2.CompletionServiceSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings.Builder completionServiceSettingsBuilder = + CompletionServiceSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceSettings completionServiceSettings = completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_completionservicesettings_completequery_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..df790553 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider.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.retail.v2.samples; + +// [START retail_v2_generated_predictionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.PredictionServiceClient; +import com.google.cloud.retail.v2.PredictionServiceSettings; +import com.google.cloud.retail.v2.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. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2_generated_predictionserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..6145428b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.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.retail.v2.samples; + +// [START retail_v2_generated_predictionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.PredictionServiceClient; +import com.google.cloud.retail.v2.PredictionServiceSettings; + +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. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2_generated_predictionserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..a0181304 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetEndpoint.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.retail.v2.samples; + +// [START retail_v2_generated_predictionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.PredictionServiceClient; +import com.google.cloud.retail.v2.PredictionServiceSettings; +import com.google.cloud.retail.v2.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. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2_generated_predictionserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/AsyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/AsyncPredict.java new file mode 100644 index 00000000..bcf63d22 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/AsyncPredict.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_predictionserviceclient_predict_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.PredictRequest; +import com.google.cloud.retail.v2.PredictResponse; +import com.google.cloud.retail.v2.PredictionServiceClient; +import com.google.cloud.retail.v2.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class AsyncPredict { + + public static void main(String[] args) throws Exception { + asyncPredict(); + } + + public static void asyncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + predictionServiceClient.predictCallable().futureCall(request); + // Do something. + PredictResponse response = future.get(); + } + } +} +// [END retail_v2_generated_predictionserviceclient_predict_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/SyncPredict.java new file mode 100644 index 00000000..e7892b77 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/SyncPredict.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.retail.v2.samples; + +// [START retail_v2_generated_predictionserviceclient_predict_sync] +import com.google.cloud.retail.v2.PredictRequest; +import com.google.cloud.retail.v2.PredictResponse; +import com.google.cloud.retail.v2.PredictionServiceClient; +import com.google.cloud.retail.v2.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + PredictResponse response = predictionServiceClient.predict(request); + } + } +} +// [END retail_v2_generated_predictionserviceclient_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/predictionservicesettings/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2/predictionservicesettings/predict/SyncPredict.java new file mode 100644 index 00000000..4fcbd0c7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/predictionservicesettings/predict/SyncPredict.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.retail.v2.samples; + +// [START retail_v2_generated_predictionservicesettings_predict_sync] +import com.google.cloud.retail.v2.PredictionServiceSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceSettings predictionServiceSettings = predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_predictionservicesettings_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java new file mode 100644 index 00000000..b86d2b10 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addfulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlaces(); + } + + public static void asyncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addfulfillmentplaces_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java new file mode 100644 index 00000000..751a3821 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addfulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlacesLRO(); + } + + public static void asyncAddFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + AddFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addfulfillmentplaces_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java new file mode 100644 index 00000000..922a6700 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addfulfillmentplaces_sync] +import com.google.cloud.retail.v2.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlaces(); + } + + public static void syncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addfulfillmentplaces_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java new file mode 100644 index 00000000..00890d1c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addfulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncAddFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesProductname(); + } + + public static void syncAddFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addfulfillmentplaces_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java new file mode 100644 index 00000000..9c0abfa5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addfulfillmentplaces_string_sync] +import com.google.cloud.retail.v2.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncAddFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesString(); + } + + public static void syncAddFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addfulfillmentplaces_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java new file mode 100644 index 00000000..806295dc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addlocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2.LocalInventory; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventories(); + } + + public static void asyncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addlocalinventories_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java new file mode 100644 index 00000000..0392d8bf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addlocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2.LocalInventory; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventoriesLRO(); + } + + public static void asyncAddLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addLocalInventoriesOperationCallable().futureCall(request); + // Do something. + AddLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addlocalinventories_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventories.java new file mode 100644 index 00000000..5e7e76ba --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addlocalinventories_sync] +import com.google.cloud.retail.v2.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2.LocalInventory; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + syncAddLocalInventories(); + } + + public static void syncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addlocalinventories_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java new file mode 100644 index 00000000..588b3ea5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addlocalinventories_productname_sync] +import com.google.cloud.retail.v2.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncAddLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesProductname(); + } + + public static void syncAddLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addlocalinventories_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java new file mode 100644 index 00000000..0fd56bef --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addlocalinventories_string_sync] +import com.google.cloud.retail.v2.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncAddLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesString(); + } + + public static void syncAddLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addlocalinventories_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..544d12a9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.ProductServiceSettings; +import com.google.cloud.retail.v2.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. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2_generated_productserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..ac022062 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.ProductServiceSettings; + +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. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2_generated_productserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..ed296bc5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.ProductServiceSettings; +import com.google.cloud.retail.v2.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. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2_generated_productserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/AsyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/AsyncCreateProduct.java new file mode 100644 index 00000000..9f55451a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/AsyncCreateProduct.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_createproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.CreateProductRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + ApiFuture future = productServiceClient.createProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_createproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProduct.java new file mode 100644 index 00000000..b2574409 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProduct.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_createproduct_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.CreateProductRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + Product response = productServiceClient.createProduct(request); + } + } +} +// [END retail_v2_generated_productserviceclient_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java new file mode 100644 index 00000000..39b84f6a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_createproduct_branchnameproductstring_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncCreateProductBranchnameProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductBranchnameProductString(); + } + + public static void syncCreateProductBranchnameProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2_generated_productserviceclient_createproduct_branchnameproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductStringProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductStringProductString.java new file mode 100644 index 00000000..9efaa3ba --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_createproduct_stringproductstring_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2_generated_productserviceclient_createproduct_stringproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/AsyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/AsyncDeleteProduct.java new file mode 100644 index 00000000..1b7eb9e2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/AsyncDeleteProduct.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_deleteproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.DeleteProductRequest; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.deleteProductCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_deleteproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProduct.java new file mode 100644 index 00000000..a0f6e454 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProduct.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_deleteproduct_sync] +import com.google.cloud.retail.v2.DeleteProductRequest; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.Empty; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + productServiceClient.deleteProduct(request); + } + } +} +// [END retail_v2_generated_productserviceclient_deleteproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductProductname.java new file mode 100644 index 00000000..fac9b0d3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductProductname.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_deleteproduct_productname_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.Empty; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2_generated_productserviceclient_deleteproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductString.java new file mode 100644 index 00000000..016875ad --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductString.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_deleteproduct_string_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.Empty; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2_generated_productserviceclient_deleteproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/AsyncGetProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/AsyncGetProduct.java new file mode 100644 index 00000000..f0a052d1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/AsyncGetProduct.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_getproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.GetProductRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.getProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_getproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProduct.java new file mode 100644 index 00000000..27bde94e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProduct.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_getproduct_sync] +import com.google.cloud.retail.v2.GetProductRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + Product response = productServiceClient.getProduct(request); + } + } +} +// [END retail_v2_generated_productserviceclient_getproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductProductname.java new file mode 100644 index 00000000..b3552c64 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductProductname.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_getproduct_productname_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2_generated_productserviceclient_getproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductString.java new file mode 100644 index 00000000..b4f4a21d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductString.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_getproduct_string_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2_generated_productserviceclient_getproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProducts.java new file mode 100644 index 00000000..4565e534 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProducts.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_importproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportProductsRequest; +import com.google.cloud.retail.v2.ProductInputConfig; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncImportProducts { + + public static void main(String[] args) throws Exception { + asyncImportProducts(); + } + + public static void asyncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + productServiceClient.importProductsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_importproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProductsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProductsLRO.java new file mode 100644 index 00000000..44115d87 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProductsLRO.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_importproducts_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportMetadata; +import com.google.cloud.retail.v2.ImportProductsRequest; +import com.google.cloud.retail.v2.ImportProductsResponse; +import com.google.cloud.retail.v2.ProductInputConfig; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class AsyncImportProductsLRO { + + public static void main(String[] args) throws Exception { + asyncImportProductsLRO(); + } + + public static void asyncImportProductsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + productServiceClient.importProductsOperationCallable().futureCall(request); + // Do something. + ImportProductsResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_importproducts_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/SyncImportProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/SyncImportProducts.java new file mode 100644 index 00000000..f0d74b8a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/SyncImportProducts.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_importproducts_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportProductsRequest; +import com.google.cloud.retail.v2.ImportProductsResponse; +import com.google.cloud.retail.v2.ProductInputConfig; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncImportProducts { + + public static void main(String[] args) throws Exception { + syncImportProducts(); + } + + public static void syncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportProductsResponse response = productServiceClient.importProductsAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_importproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProducts.java new file mode 100644 index 00000000..44b243d4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProducts.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_listproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ListProductsRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + productServiceClient.listProductsPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_productserviceclient_listproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProductsPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProductsPaged.java new file mode 100644 index 00000000..f156b90b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProductsPaged.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_listproducts_paged_async] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ListProductsRequest; +import com.google.cloud.retail.v2.ListProductsResponse; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.common.base.Strings; +import com.google.protobuf.FieldMask; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + while (true) { + ListProductsResponse response = productServiceClient.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 retail_v2_generated_productserviceclient_listproducts_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProducts.java new file mode 100644 index 00000000..cd748e1a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProducts.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_listproducts_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ListProductsRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + for (Product element : productServiceClient.listProducts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_productserviceclient_listproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsBranchname.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsBranchname.java new file mode 100644 index 00000000..e3a9fb37 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsBranchname.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_listproducts_branchname_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncListProductsBranchname { + + public static void main(String[] args) throws Exception { + syncListProductsBranchname(); + } + + public static void syncListProductsBranchname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_productserviceclient_listproducts_branchname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsString.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsString.java new file mode 100644 index 00000000..8e3d4ceb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_listproducts_string_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_productserviceclient_listproducts_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java new file mode 100644 index 00000000..9b3c1f6f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removefulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlaces(); + } + + public static void asyncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removefulfillmentplaces_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java new file mode 100644 index 00000000..43ca1285 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removefulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlacesLRO(); + } + + public static void asyncRemoveFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + RemoveFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removefulfillmentplaces_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java new file mode 100644 index 00000000..27a695a8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removefulfillmentplaces_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlaces(); + } + + public static void syncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removefulfillmentplaces_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java new file mode 100644 index 00000000..11bc11da --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removefulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesProductname(); + } + + public static void syncRemoveFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removefulfillmentplaces_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java new file mode 100644 index 00000000..9814b7a4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removefulfillmentplaces_string_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesString(); + } + + public static void syncRemoveFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removefulfillmentplaces_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java new file mode 100644 index 00000000..e42c81f3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removelocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveLocalInventoriesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventories(); + } + + public static void asyncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removelocalinventories_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java new file mode 100644 index 00000000..a4447d03 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removelocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventoriesLRO(); + } + + public static void asyncRemoveLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeLocalInventoriesOperationCallable().futureCall(request); + // Do something. + RemoveLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removelocalinventories_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java new file mode 100644 index 00000000..e6059c61 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removelocalinventories_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventories(); + } + + public static void syncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removelocalinventories_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java new file mode 100644 index 00000000..ba6b8a17 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removelocalinventories_productname_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesProductname(); + } + + public static void syncRemoveLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removelocalinventories_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java new file mode 100644 index 00000000..e6a003ae --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removelocalinventories_string_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesString(); + } + + public static void syncRemoveLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removelocalinventories_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventory.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventory.java new file mode 100644 index 00000000..55edfe0e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventory.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_setinventory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.SetInventoryRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventory { + + public static void main(String[] args) throws Exception { + asyncSetInventory(); + } + + public static void asyncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.setInventoryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_setinventory_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventoryLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventoryLRO.java new file mode 100644 index 00000000..99544069 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventoryLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_setinventory_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.SetInventoryMetadata; +import com.google.cloud.retail.v2.SetInventoryRequest; +import com.google.cloud.retail.v2.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventoryLRO { + + public static void main(String[] args) throws Exception { + asyncSetInventoryLRO(); + } + + public static void asyncSetInventoryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.setInventoryOperationCallable().futureCall(request); + // Do something. + SetInventoryResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_setinventory_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventory.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventory.java new file mode 100644 index 00000000..87696f9d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventory.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_setinventory_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.SetInventoryRequest; +import com.google.cloud.retail.v2.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncSetInventory { + + public static void main(String[] args) throws Exception { + syncSetInventory(); + } + + public static void syncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + SetInventoryResponse response = productServiceClient.setInventoryAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_setinventory_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java new file mode 100644 index 00000000..ca30faba --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_setinventory_productfieldmask_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.SetInventoryResponse; +import com.google.protobuf.FieldMask; + +public class SyncSetInventoryProductFieldmask { + + public static void main(String[] args) throws Exception { + syncSetInventoryProductFieldmask(); + } + + public static void syncSetInventoryProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product inventory = Product.newBuilder().build(); + FieldMask setMask = FieldMask.newBuilder().build(); + SetInventoryResponse response = + productServiceClient.setInventoryAsync(inventory, setMask).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_setinventory_productfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/AsyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/AsyncUpdateProduct.java new file mode 100644 index 00000000..d8640a10 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/AsyncUpdateProduct.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_updateproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.updateProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_updateproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProduct.java new file mode 100644 index 00000000..e0e6d1a1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProduct.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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_updateproduct_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + Product response = productServiceClient.updateProduct(request); + } + } +} +// [END retail_v2_generated_productserviceclient_updateproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java new file mode 100644 index 00000000..7dd7ebff --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_updateproduct_productfieldmask_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product product = Product.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Product response = productServiceClient.updateProduct(product, updateMask); + } + } +} +// [END retail_v2_generated_productserviceclient_updateproduct_productfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/productservicesettings/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2/productservicesettings/createproduct/SyncCreateProduct.java new file mode 100644 index 00000000..f7acec58 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/productservicesettings/createproduct/SyncCreateProduct.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.retail.v2.samples; + +// [START retail_v2_generated_productservicesettings_createproduct_sync] +import com.google.cloud.retail.v2.ProductServiceSettings; +import java.time.Duration; + +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. + ProductServiceSettings.Builder productServiceSettingsBuilder = + ProductServiceSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_productservicesettings_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..9918465b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.SearchServiceSettings; +import com.google.cloud.retail.v2.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. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2_generated_searchserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..156129eb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.SearchServiceSettings; + +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. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2_generated_searchserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..a4df307a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/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.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.SearchServiceSettings; +import com.google.cloud.retail.v2.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. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2_generated_searchserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearch.java new file mode 100644 index 00000000..3d7850f3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearch.java @@ -0,0 +1,72 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_search_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.SearchRequest; +import com.google.cloud.retail.v2.SearchResponse; +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.UserInfo; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncSearch { + + public static void main(String[] args) throws Exception { + asyncSearch(); + } + + public static void asyncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .putAllLabels(new HashMap()) + .setSpellCorrectionSpec(SearchRequest.SpellCorrectionSpec.newBuilder().build()) + .build(); + ApiFuture future = + searchServiceClient.searchPagedCallable().futureCall(request); + // Do something. + for (SearchResponse.SearchResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_searchserviceclient_search_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearchPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearchPaged.java new file mode 100644 index 00000000..c5d485cb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearchPaged.java @@ -0,0 +1,78 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_search_paged_async] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.SearchRequest; +import com.google.cloud.retail.v2.SearchResponse; +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.UserInfo; +import com.google.common.base.Strings; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncSearchPaged { + + public static void main(String[] args) throws Exception { + asyncSearchPaged(); + } + + public static void asyncSearchPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .putAllLabels(new HashMap()) + .setSpellCorrectionSpec(SearchRequest.SpellCorrectionSpec.newBuilder().build()) + .build(); + while (true) { + SearchResponse response = searchServiceClient.searchCallable().call(request); + for (SearchResponse.SearchResult element : response.getResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2_generated_searchserviceclient_search_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/SyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/SyncSearch.java new file mode 100644 index 00000000..f03bf0ce --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/SyncSearch.java @@ -0,0 +1,68 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_search_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.SearchRequest; +import com.google.cloud.retail.v2.SearchResponse; +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.UserInfo; +import java.util.ArrayList; +import java.util.HashMap; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .putAllLabels(new HashMap()) + .setSpellCorrectionSpec(SearchRequest.SpellCorrectionSpec.newBuilder().build()) + .build(); + for (SearchResponse.SearchResult element : searchServiceClient.search(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_searchserviceclient_search_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/searchservicesettings/search/SyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2/searchservicesettings/search/SyncSearch.java new file mode 100644 index 00000000..a240556a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/searchservicesettings/search/SyncSearch.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.retail.v2.samples; + +// [START retail_v2_generated_searchservicesettings_search_sync] +import com.google.cloud.retail.v2.SearchServiceSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings.Builder searchServiceSettingsBuilder = SearchServiceSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_searchservicesettings_search_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 00000000..30150799 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.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.retail.v2.stub.samples; + +// [START retail_v2_generated_catalogservicestubsettings_updatecatalog_sync] +import com.google.cloud.retail.v2.stub.CatalogServiceStubSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceStubSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceStubSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceStubSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_catalogservicestubsettings_updatecatalog_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java new file mode 100644 index 00000000..035c3f00 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/stub/completionservicestubsettings/completequery/SyncCompleteQuery.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.retail.v2.stub.samples; + +// [START retail_v2_generated_completionservicestubsettings_completequery_sync] +import com.google.cloud.retail.v2.stub.CompletionServiceStubSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceStubSettings.Builder completionServiceSettingsBuilder = + CompletionServiceStubSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceStubSettings completionServiceSettings = + completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_completionservicestubsettings_completequery_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/stub/predictionservicestubsettings/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2/stub/predictionservicestubsettings/predict/SyncPredict.java new file mode 100644 index 00000000..cfc9f7cd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/stub/predictionservicestubsettings/predict/SyncPredict.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.retail.v2.stub.samples; + +// [START retail_v2_generated_predictionservicestubsettings_predict_sync] +import com.google.cloud.retail.v2.stub.PredictionServiceStubSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceStubSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceStubSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceStubSettings predictionServiceSettings = + predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_predictionservicestubsettings_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/stub/productservicestubsettings/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2/stub/productservicestubsettings/createproduct/SyncCreateProduct.java new file mode 100644 index 00000000..5dd52b9a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/stub/productservicestubsettings/createproduct/SyncCreateProduct.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.retail.v2.stub.samples; + +// [START retail_v2_generated_productservicestubsettings_createproduct_sync] +import com.google.cloud.retail.v2.stub.ProductServiceStubSettings; +import java.time.Duration; + +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. + ProductServiceStubSettings.Builder productServiceSettingsBuilder = + ProductServiceStubSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceStubSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_productservicestubsettings_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/stub/searchservicestubsettings/search/SyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2/stub/searchservicestubsettings/search/SyncSearch.java new file mode 100644 index 00000000..61a39787 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/stub/searchservicestubsettings/search/SyncSearch.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.retail.v2.stub.samples; + +// [START retail_v2_generated_searchservicestubsettings_search_sync] +import com.google.cloud.retail.v2.stub.SearchServiceStubSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceStubSettings.Builder searchServiceSettingsBuilder = + SearchServiceStubSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceStubSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_searchservicestubsettings_search_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 00000000..c6f601c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.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.retail.v2.stub.samples; + +// [START retail_v2_generated_usereventservicestubsettings_writeuserevent_sync] +import com.google.cloud.retail.v2.stub.UserEventServiceStubSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceStubSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceStubSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceStubSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_usereventservicestubsettings_writeuserevent_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java new file mode 100644 index 00000000..2dc7618c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_collectuserevent_async] +import com.google.api.HttpBody; +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CollectUserEventRequest; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class AsyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + asyncCollectUserEvent(); + } + + public static void asyncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + ApiFuture future = + userEventServiceClient.collectUserEventCallable().futureCall(request); + // Do something. + HttpBody response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_collectuserevent_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java new file mode 100644 index 00000000..d8877b3c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/SyncCollectUserEvent.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_collectuserevent_sync] +import com.google.api.HttpBody; +import com.google.cloud.retail.v2.CollectUserEventRequest; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class SyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + syncCollectUserEvent(); + } + + public static void syncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + HttpBody response = userEventServiceClient.collectUserEvent(request); + } + } +} +// [END retail_v2_generated_usereventserviceclient_collectuserevent_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..e48c52a5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.cloud.retail.v2.UserEventServiceSettings; +import com.google.cloud.retail.v2.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. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2_generated_usereventserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..503196d6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.cloud.retail.v2.UserEventServiceSettings; + +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. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2_generated_usereventserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..ab23c7c2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetEndpoint.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.cloud.retail.v2.UserEventServiceSettings; +import com.google.cloud.retail.v2.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. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2_generated_usereventserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEvents.java new file mode 100644 index 00000000..77a16c76 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEvents.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_importuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportUserEventsRequest; +import com.google.cloud.retail.v2.UserEventInputConfig; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncImportUserEvents { + + public static void main(String[] args) throws Exception { + asyncImportUserEvents(); + } + + public static void asyncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.importUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_importuserevents_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java new file mode 100644 index 00000000..7ea122a3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_importuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportMetadata; +import com.google.cloud.retail.v2.ImportUserEventsRequest; +import com.google.cloud.retail.v2.ImportUserEventsResponse; +import com.google.cloud.retail.v2.UserEventInputConfig; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class AsyncImportUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncImportUserEventsLRO(); + } + + public static void asyncImportUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + OperationFuture future = + userEventServiceClient.importUserEventsOperationCallable().futureCall(request); + // Do something. + ImportUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_importuserevents_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/SyncImportUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/SyncImportUserEvents.java new file mode 100644 index 00000000..db6e00da --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/SyncImportUserEvents.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_importuserevents_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportUserEventsRequest; +import com.google.cloud.retail.v2.ImportUserEventsResponse; +import com.google.cloud.retail.v2.UserEventInputConfig; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class SyncImportUserEvents { + + public static void main(String[] args) throws Exception { + syncImportUserEvents(); + } + + public static void syncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ImportUserEventsResponse response = + userEventServiceClient.importUserEventsAsync(request).get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_importuserevents_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java new file mode 100644 index 00000000..79672927 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_purgeuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.PurgeUserEventsRequest; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEvents(); + } + + public static void asyncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + ApiFuture future = + userEventServiceClient.purgeUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_purgeuserevents_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java new file mode 100644 index 00000000..0ef970d5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_purgeuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.PurgeMetadata; +import com.google.cloud.retail.v2.PurgeUserEventsRequest; +import com.google.cloud.retail.v2.PurgeUserEventsResponse; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class AsyncPurgeUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEventsLRO(); + } + + public static void asyncPurgeUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + OperationFuture future = + userEventServiceClient.purgeUserEventsOperationCallable().futureCall(request); + // Do something. + PurgeUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_purgeuserevents_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java new file mode 100644 index 00000000..ec051793 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_purgeuserevents_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.PurgeUserEventsRequest; +import com.google.cloud.retail.v2.PurgeUserEventsResponse; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class SyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + syncPurgeUserEvents(); + } + + public static void syncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + PurgeUserEventsResponse response = userEventServiceClient.purgeUserEventsAsync(request).get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_purgeuserevents_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java new file mode 100644 index 00000000..a35efcfb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_rejoinuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.RejoinUserEventsRequest; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEvents(); + } + + public static void asyncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + ApiFuture future = + userEventServiceClient.rejoinUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_rejoinuserevents_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java new file mode 100644 index 00000000..71f47931 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_rejoinuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2.RejoinUserEventsRequest; +import com.google.cloud.retail.v2.RejoinUserEventsResponse; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class AsyncRejoinUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEventsLRO(); + } + + public static void asyncRejoinUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + OperationFuture future = + userEventServiceClient.rejoinUserEventsOperationCallable().futureCall(request); + // Do something. + RejoinUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_rejoinuserevents_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java new file mode 100644 index 00000000..57cfbdfb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_rejoinuserevents_sync] +import com.google.cloud.retail.v2.RejoinUserEventsRequest; +import com.google.cloud.retail.v2.RejoinUserEventsResponse; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class SyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + syncRejoinUserEvents(); + } + + public static void syncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + RejoinUserEventsResponse response = + userEventServiceClient.rejoinUserEventsAsync(request).get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_rejoinuserevents_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java new file mode 100644 index 00000000..1658e2e5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_writeuserevent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.UserEvent; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.cloud.retail.v2.WriteUserEventRequest; + +public class AsyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + asyncWriteUserEvent(); + } + + public static void asyncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.writeUserEventCallable().futureCall(request); + // Do something. + UserEvent response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_writeuserevent_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 00000000..7e0d3801 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/SyncWriteUserEvent.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.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_writeuserevent_sync] +import com.google.cloud.retail.v2.UserEvent; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.cloud.retail.v2.WriteUserEventRequest; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + UserEvent response = userEventServiceClient.writeUserEvent(request); + } + } +} +// [END retail_v2_generated_usereventserviceclient_writeuserevent_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 00000000..c78dc1ad --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2/usereventservicesettings/writeuserevent/SyncWriteUserEvent.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.retail.v2.samples; + +// [START retail_v2_generated_usereventservicesettings_writeuserevent_sync] +import com.google.cloud.retail.v2.UserEventServiceSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_usereventservicesettings_writeuserevent_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java new file mode 100644 index 00000000..f2ddf1c3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_addcatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogAttribute; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; + +public class AsyncAddCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncAddCatalogAttribute(); + } + + public static void asyncAddCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.addCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_addcatalogattribute_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java new file mode 100644 index 00000000..3bd3a620 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_addcatalogattribute_sync] +import com.google.cloud.retail.v2alpha.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogAttribute; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; + +public class SyncAddCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncAddCatalogAttribute(); + } + + public static void syncAddCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.addCatalogAttribute(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_addcatalogattribute_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..19b4334a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CatalogServiceSettings; +import com.google.cloud.retail.v2alpha.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. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2alpha_generated_catalogserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..cbddda90 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CatalogServiceSettings; + +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. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2alpha_generated_catalogserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..f2439d82 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CatalogServiceSettings; +import com.google.cloud.retail.v2alpha.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. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2alpha_generated_catalogserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java new file mode 100644 index 00000000..40a050c0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getattributesconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetAttributesConfigRequest; + +public class AsyncGetAttributesConfig { + + public static void main(String[] args) throws Exception { + asyncGetAttributesConfig(); + } + + public static void asyncGetAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetAttributesConfigRequest request = + GetAttributesConfigRequest.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + ApiFuture future = + catalogServiceClient.getAttributesConfigCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getattributesconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java new file mode 100644 index 00000000..97fd6b8e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getattributesconfig_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetAttributesConfigRequest; + +public class SyncGetAttributesConfig { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfig(); + } + + public static void syncGetAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetAttributesConfigRequest request = + GetAttributesConfigRequest.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + AttributesConfig response = catalogServiceClient.getAttributesConfig(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getattributesconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java new file mode 100644 index 00000000..e248cd3b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getattributesconfig_attributesconfigname_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; + +public class SyncGetAttributesConfigAttributesconfigname { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfigAttributesconfigname(); + } + + public static void syncGetAttributesConfigAttributesconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + AttributesConfig response = catalogServiceClient.getAttributesConfig(name); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getattributesconfig_attributesconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java new file mode 100644 index 00000000..6ceaba9d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getattributesconfig_string_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; + +public class SyncGetAttributesConfigString { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfigString(); + } + + public static void syncGetAttributesConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + AttributesConfig response = catalogServiceClient.getAttributesConfig(name); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getattributesconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java new file mode 100644 index 00000000..fcc35a59 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.CompletionConfigName; +import com.google.cloud.retail.v2alpha.GetCompletionConfigRequest; + +public class AsyncGetCompletionConfig { + + public static void main(String[] args) throws Exception { + asyncGetCompletionConfig(); + } + + public static void asyncGetCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetCompletionConfigRequest request = + GetCompletionConfigRequest.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + ApiFuture future = + catalogServiceClient.getCompletionConfigCallable().futureCall(request); + // Do something. + CompletionConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java new file mode 100644 index 00000000..df66713f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.CompletionConfigName; +import com.google.cloud.retail.v2alpha.GetCompletionConfigRequest; + +public class SyncGetCompletionConfig { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfig(); + } + + public static void syncGetCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetCompletionConfigRequest request = + GetCompletionConfigRequest.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + CompletionConfig response = catalogServiceClient.getCompletionConfig(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java new file mode 100644 index 00000000..ef084d63 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_completionconfigname_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.CompletionConfigName; + +public class SyncGetCompletionConfigCompletionconfigname { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfigCompletionconfigname(); + } + + public static void syncGetCompletionConfigCompletionconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + CompletionConfig response = catalogServiceClient.getCompletionConfig(name); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_completionconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java new file mode 100644 index 00000000..ab4d9e4c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_string_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.CompletionConfigName; + +public class SyncGetCompletionConfigString { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfigString(); + } + + public static void syncGetCompletionConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + CompletionConfig response = catalogServiceClient.getCompletionConfig(name); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java new file mode 100644 index 00000000..f237b8de --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetDefaultBranchRequest; +import com.google.cloud.retail.v2alpha.GetDefaultBranchResponse; + +public class AsyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncGetDefaultBranch(); + } + + public static void asyncGetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetDefaultBranchRequest request = + GetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + ApiFuture future = + catalogServiceClient.getDefaultBranchCallable().futureCall(request); + // Do something. + GetDefaultBranchResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java new file mode 100644 index 00000000..b279f1f4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetDefaultBranchRequest; +import com.google.cloud.retail.v2alpha.GetDefaultBranchResponse; + +public class SyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranch(); + } + + public static void syncGetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetDefaultBranchRequest request = + GetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java new file mode 100644 index 00000000..88652dc1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchCatalogname(); + } + + public static void syncGetDefaultBranchCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(catalog); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java new file mode 100644 index 00000000..919d9056 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_string_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchString(); + } + + public static void syncGetDefaultBranchString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(catalog); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogs.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogs.java new file mode 100644 index 00000000..5da2583a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogs.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_listcatalogs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.ListCatalogsRequest; +import com.google.cloud.retail.v2alpha.LocationName; + +public class AsyncListCatalogs { + + public static void main(String[] args) throws Exception { + asyncListCatalogs(); + } + + public static void asyncListCatalogs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ListCatalogsRequest request = + ListCatalogsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + catalogServiceClient.listCatalogsPagedCallable().futureCall(request); + // Do something. + for (Catalog element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_listcatalogs_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java new file mode 100644 index 00000000..9c7dadd2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_listcatalogs_paged_async] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.ListCatalogsRequest; +import com.google.cloud.retail.v2alpha.ListCatalogsResponse; +import com.google.cloud.retail.v2alpha.LocationName; +import com.google.common.base.Strings; + +public class AsyncListCatalogsPaged { + + public static void main(String[] args) throws Exception { + asyncListCatalogsPaged(); + } + + public static void asyncListCatalogsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ListCatalogsRequest request = + ListCatalogsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListCatalogsResponse response = catalogServiceClient.listCatalogsCallable().call(request); + for (Catalog element : response.getCatalogsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_listcatalogs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogs.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogs.java new file mode 100644 index 00000000..c4190187 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogs.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_listcatalogs_sync] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.ListCatalogsRequest; +import com.google.cloud.retail.v2alpha.LocationName; + +public class SyncListCatalogs { + + public static void main(String[] args) throws Exception { + syncListCatalogs(); + } + + public static void syncListCatalogs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ListCatalogsRequest request = + ListCatalogsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Catalog element : catalogServiceClient.listCatalogs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_listcatalogs_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java new file mode 100644 index 00000000..93dee5a9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_listcatalogs_locationname_sync] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.LocationName; + +public class SyncListCatalogsLocationname { + + public static void main(String[] args) throws Exception { + syncListCatalogsLocationname(); + } + + public static void syncListCatalogsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Catalog element : catalogServiceClient.listCatalogs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_listcatalogs_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsString.java new file mode 100644 index 00000000..b4a4cdca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_listcatalogs_string_sync] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.LocationName; + +public class SyncListCatalogsString { + + public static void main(String[] args) throws Exception { + syncListCatalogsString(); + } + + public static void syncListCatalogsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Catalog element : catalogServiceClient.listCatalogs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_listcatalogs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java new file mode 100644 index 00000000..b4545e2a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_removecatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest; + +public class AsyncRemoveCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncRemoveCatalogAttribute(); + } + + public static void asyncRemoveCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + ApiFuture future = + catalogServiceClient.removeCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_removecatalogattribute_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java new file mode 100644 index 00000000..21f18c85 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_removecatalogattribute_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest; + +public class SyncRemoveCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncRemoveCatalogAttribute(); + } + + public static void syncRemoveCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + AttributesConfig response = catalogServiceClient.removeCatalogAttribute(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_removecatalogattribute_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java new file mode 100644 index 00000000..b9bc1b80 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_replacecatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogAttribute; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest; +import com.google.protobuf.FieldMask; + +public class AsyncReplaceCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncReplaceCatalogAttribute(); + } + + public static void asyncReplaceCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.replaceCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_replacecatalogattribute_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java new file mode 100644 index 00000000..772df146 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_replacecatalogattribute_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogAttribute; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest; +import com.google.protobuf.FieldMask; + +public class SyncReplaceCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncReplaceCatalogAttribute(); + } + + public static void syncReplaceCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.replaceCatalogAttribute(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_replacecatalogattribute_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java new file mode 100644 index 00000000..51b78de8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class AsyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncSetDefaultBranch(); + } + + public static void asyncSetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + SetDefaultBranchRequest request = + SetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setBranchId( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setNote("note3387378") + .setForce(true) + .build(); + ApiFuture future = catalogServiceClient.setDefaultBranchCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java new file mode 100644 index 00000000..f8bf628b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranch(); + } + + public static void syncSetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + SetDefaultBranchRequest request = + SetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setBranchId( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setNote("note3387378") + .setForce(true) + .build(); + catalogServiceClient.setDefaultBranch(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java new file mode 100644 index 00000000..ea4642d6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchCatalogname(); + } + + public static void syncSetDefaultBranchCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + catalogServiceClient.setDefaultBranch(catalog); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java new file mode 100644 index 00000000..0d4394f1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_string_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchString(); + } + + public static void syncSetDefaultBranchString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + catalogServiceClient.setDefaultBranch(catalog); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java new file mode 100644 index 00000000..c978d53b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateAttributesConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateAttributesConfig(); + } + + public static void asyncUpdateAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateAttributesConfigRequest request = + UpdateAttributesConfigRequest.newBuilder() + .setAttributesConfig(AttributesConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.updateAttributesConfigCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java new file mode 100644 index 00000000..cafd9362 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAttributesConfig { + + public static void main(String[] args) throws Exception { + syncUpdateAttributesConfig(); + } + + public static void syncUpdateAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateAttributesConfigRequest request = + UpdateAttributesConfigRequest.newBuilder() + .setAttributesConfig(AttributesConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.updateAttributesConfig(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java new file mode 100644 index 00000000..3e7c8880 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_attributesconfigfieldmask_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAttributesConfigAttributesconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateAttributesConfigAttributesconfigFieldmask(); + } + + public static void syncUpdateAttributesConfigAttributesconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AttributesConfig attributesConfig = AttributesConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + AttributesConfig response = + catalogServiceClient.updateAttributesConfig(attributesConfig, updateMask); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_attributesconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java new file mode 100644 index 00000000..abd91066 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecatalog_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + asyncUpdateCatalog(); + } + + public static void asyncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCatalogRequest request = + UpdateCatalogRequest.newBuilder() + .setCatalog(Catalog.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = catalogServiceClient.updateCatalogCallable().futureCall(request); + // Do something. + Catalog response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecatalog_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 00000000..2eb43ab8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalog.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecatalog_sync] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCatalogRequest request = + UpdateCatalogRequest.newBuilder() + .setCatalog(Catalog.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Catalog response = catalogServiceClient.updateCatalog(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecatalog_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java new file mode 100644 index 00000000..bdf2a792 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalogCatalogFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateCatalogCatalogFieldmask(); + } + + public static void syncUpdateCatalogCatalogFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + Catalog catalog = Catalog.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Catalog response = catalogServiceClient.updateCatalog(catalog, updateMask); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java new file mode 100644 index 00000000..90bc3b28 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateCompletionConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateCompletionConfig(); + } + + public static void asyncUpdateCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCompletionConfigRequest request = + UpdateCompletionConfigRequest.newBuilder() + .setCompletionConfig(CompletionConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.updateCompletionConfigCallable().futureCall(request); + // Do something. + CompletionConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java new file mode 100644 index 00000000..a0848487 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCompletionConfig { + + public static void main(String[] args) throws Exception { + syncUpdateCompletionConfig(); + } + + public static void syncUpdateCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCompletionConfigRequest request = + UpdateCompletionConfigRequest.newBuilder() + .setCompletionConfig(CompletionConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + CompletionConfig response = catalogServiceClient.updateCompletionConfig(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java new file mode 100644 index 00000000..4b964dc6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_completionconfigfieldmask_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCompletionConfigCompletionconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateCompletionConfigCompletionconfigFieldmask(); + } + + public static void syncUpdateCompletionConfigCompletionconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CompletionConfig completionConfig = CompletionConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + CompletionConfig response = + catalogServiceClient.updateCompletionConfig(completionConfig, updateMask); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_completionconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 00000000..39b25303 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogservicesettings/updatecatalog/SyncUpdateCatalog.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogservicesettings_updatecatalog_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_catalogservicesettings_updatecatalog_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/AsyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/AsyncCompleteQuery.java new file mode 100644 index 00000000..78f162b9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/AsyncCompleteQuery.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_completequery_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CompleteQueryRequest; +import com.google.cloud.retail.v2alpha.CompleteQueryResponse; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import java.util.ArrayList; + +public class AsyncCompleteQuery { + + public static void main(String[] args) throws Exception { + asyncCompleteQuery(); + } + + public static void asyncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + ApiFuture future = + completionServiceClient.completeQueryCallable().futureCall(request); + // Do something. + CompleteQueryResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_completionserviceclient_completequery_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/SyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/SyncCompleteQuery.java new file mode 100644 index 00000000..aad8166e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/SyncCompleteQuery.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_completequery_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CompleteQueryRequest; +import com.google.cloud.retail.v2alpha.CompleteQueryResponse; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import java.util.ArrayList; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + CompleteQueryResponse response = completionServiceClient.completeQuery(request); + } + } +} +// [END retail_v2alpha_generated_completionserviceclient_completequery_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..0cda9136 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.CompletionServiceSettings; +import com.google.cloud.retail.v2alpha.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. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2alpha_generated_completionserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..ac2af2e9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider1.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.CompletionServiceSettings; + +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. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2alpha_generated_completionserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..7b64939b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetEndpoint.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.CompletionServiceSettings; +import com.google.cloud.retail.v2alpha.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. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2alpha_generated_completionserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java new file mode 100644 index 00000000..9cc53c72 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionData.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_importcompletiondata_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CompletionDataInputConfig; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.ImportCompletionDataRequest; +import com.google.longrunning.Operation; + +public class AsyncImportCompletionData { + + public static void main(String[] args) throws Exception { + asyncImportCompletionData(); + } + + public static void asyncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + completionServiceClient.importCompletionDataCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_completionserviceclient_importcompletiondata_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java new file mode 100644 index 00000000..f13a03ab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_importcompletiondata_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CompletionDataInputConfig; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.ImportCompletionDataRequest; +import com.google.cloud.retail.v2alpha.ImportCompletionDataResponse; +import com.google.cloud.retail.v2alpha.ImportMetadata; + +public class AsyncImportCompletionDataLRO { + + public static void main(String[] args) throws Exception { + asyncImportCompletionDataLRO(); + } + + public static void asyncImportCompletionDataLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + completionServiceClient.importCompletionDataOperationCallable().futureCall(request); + // Do something. + ImportCompletionDataResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_completionserviceclient_importcompletiondata_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/SyncImportCompletionData.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/SyncImportCompletionData.java new file mode 100644 index 00000000..580e3c00 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/SyncImportCompletionData.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_importcompletiondata_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CompletionDataInputConfig; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.ImportCompletionDataRequest; +import com.google.cloud.retail.v2alpha.ImportCompletionDataResponse; + +public class SyncImportCompletionData { + + public static void main(String[] args) throws Exception { + syncImportCompletionData(); + } + + public static void syncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportCompletionDataResponse response = + completionServiceClient.importCompletionDataAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_completionserviceclient_importcompletiondata_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionservicesettings/completequery/SyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionservicesettings/completequery/SyncCompleteQuery.java new file mode 100644 index 00000000..a9fca5a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionservicesettings/completequery/SyncCompleteQuery.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionservicesettings_completequery_sync] +import com.google.cloud.retail.v2alpha.CompletionServiceSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings.Builder completionServiceSettingsBuilder = + CompletionServiceSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceSettings completionServiceSettings = completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_completionservicesettings_completequery_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..48ad1aa8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ControlServiceSettings; +import com.google.cloud.retail.v2alpha.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. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2alpha_generated_controlserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..a214b068 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ControlServiceSettings; + +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. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder() + .setTransportChannelProvider( + ControlServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2alpha_generated_controlserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..b5ba69f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ControlServiceSettings; +import com.google.cloud.retail.v2alpha.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. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2alpha_generated_controlserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/AsyncCreateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/AsyncCreateControl.java new file mode 100644 index 00000000..7542a545 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/AsyncCreateControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_createcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.CreateControlRequest; + +public class AsyncCreateControl { + + public static void main(String[] args) throws Exception { + asyncCreateControl(); + } + + public static void asyncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CreateControlRequest request = + CreateControlRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setControl(Control.newBuilder().build()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = controlServiceClient.createControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_createcontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControl.java new file mode 100644 index 00000000..2a8c5987 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_createcontrol_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.CreateControlRequest; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CreateControlRequest request = + CreateControlRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setControl(Control.newBuilder().build()) + .setControlId("controlId-395080872") + .build(); + Control response = controlServiceClient.createControl(request); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_createcontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java new file mode 100644 index 00000000..d19bb294 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_createcontrol_catalognamecontrolstring_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncCreateControlCatalognameControlString { + + public static void main(String[] args) throws Exception { + syncCreateControlCatalognameControlString(); + } + + public static void syncCreateControlCatalognameControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + Control response = controlServiceClient.createControl(parent, control, controlId); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_createcontrol_catalognamecontrolstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java new file mode 100644 index 00000000..84d88a23 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlStringControlString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_createcontrol_stringcontrolstring_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncCreateControlStringControlString { + + public static void main(String[] args) throws Exception { + syncCreateControlStringControlString(); + } + + public static void syncCreateControlStringControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + Control response = controlServiceClient.createControl(parent, control, controlId); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_createcontrol_stringcontrolstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/AsyncDeleteControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/AsyncDeleteControl.java new file mode 100644 index 00000000..359a9b5f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/AsyncDeleteControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_deletecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.DeleteControlRequest; +import com.google.protobuf.Empty; + +public class AsyncDeleteControl { + + public static void main(String[] args) throws Exception { + asyncDeleteControl(); + } + + public static void asyncDeleteControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + DeleteControlRequest request = + DeleteControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + ApiFuture future = controlServiceClient.deleteControlCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_deletecontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControl.java new file mode 100644 index 00000000..fccdc58b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_deletecontrol_sync] +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.DeleteControlRequest; +import com.google.protobuf.Empty; + +public class SyncDeleteControl { + + public static void main(String[] args) throws Exception { + syncDeleteControl(); + } + + public static void syncDeleteControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + DeleteControlRequest request = + DeleteControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + controlServiceClient.deleteControl(request); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_deletecontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java new file mode 100644 index 00000000..36d93eec --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlControlname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_deletecontrol_controlname_sync] +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteControlControlname { + + public static void main(String[] args) throws Exception { + syncDeleteControlControlname(); + } + + public static void syncDeleteControlControlname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + controlServiceClient.deleteControl(name); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_deletecontrol_controlname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlString.java new file mode 100644 index 00000000..102964eb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_deletecontrol_string_sync] +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteControlString { + + public static void main(String[] args) throws Exception { + syncDeleteControlString(); + } + + public static void syncDeleteControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString(); + controlServiceClient.deleteControl(name); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_deletecontrol_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/AsyncGetControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/AsyncGetControl.java new file mode 100644 index 00000000..1eeec4bf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/AsyncGetControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_getcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.GetControlRequest; + +public class AsyncGetControl { + + public static void main(String[] args) throws Exception { + asyncGetControl(); + } + + public static void asyncGetControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + GetControlRequest request = + GetControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + ApiFuture future = controlServiceClient.getControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_getcontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControl.java new file mode 100644 index 00000000..613195b5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_getcontrol_sync] +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.GetControlRequest; + +public class SyncGetControl { + + public static void main(String[] args) throws Exception { + syncGetControl(); + } + + public static void syncGetControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + GetControlRequest request = + GetControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + Control response = controlServiceClient.getControl(request); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_getcontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlControlname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlControlname.java new file mode 100644 index 00000000..4d38c2b9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlControlname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_getcontrol_controlname_sync] +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncGetControlControlname { + + public static void main(String[] args) throws Exception { + syncGetControlControlname(); + } + + public static void syncGetControlControlname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + Control response = controlServiceClient.getControl(name); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_getcontrol_controlname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlString.java new file mode 100644 index 00000000..105cf049 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_getcontrol_string_sync] +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncGetControlString { + + public static void main(String[] args) throws Exception { + syncGetControlString(); + } + + public static void syncGetControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString(); + Control response = controlServiceClient.getControl(name); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_getcontrol_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControls.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControls.java new file mode 100644 index 00000000..590aa457 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControls.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_listcontrols_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ListControlsRequest; + +public class AsyncListControls { + + public static void main(String[] args) throws Exception { + asyncListControls(); + } + + public static void asyncListControls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + controlServiceClient.listControlsPagedCallable().futureCall(request); + // Do something. + for (Control element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_listcontrols_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControlsPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControlsPaged.java new file mode 100644 index 00000000..f418b443 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControlsPaged.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_listcontrols_paged_async] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ListControlsRequest; +import com.google.cloud.retail.v2alpha.ListControlsResponse; +import com.google.common.base.Strings; + +public class AsyncListControlsPaged { + + public static void main(String[] args) throws Exception { + asyncListControlsPaged(); + } + + public static void asyncListControlsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListControlsResponse response = controlServiceClient.listControlsCallable().call(request); + for (Control element : response.getControlsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_listcontrols_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControls.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControls.java new file mode 100644 index 00000000..c10195c0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControls.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_listcontrols_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ListControlsRequest; + +public class SyncListControls { + + public static void main(String[] args) throws Exception { + syncListControls(); + } + + public static void syncListControls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Control element : controlServiceClient.listControls(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_listcontrols_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsCatalogname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsCatalogname.java new file mode 100644 index 00000000..3c7d2ac6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsCatalogname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_listcontrols_catalogname_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncListControlsCatalogname { + + public static void main(String[] args) throws Exception { + syncListControlsCatalogname(); + } + + public static void syncListControlsCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + for (Control element : controlServiceClient.listControls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_listcontrols_catalogname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsString.java new file mode 100644 index 00000000..a4f9b72b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_listcontrols_string_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncListControlsString { + + public static void main(String[] args) throws Exception { + syncListControlsString(); + } + + public static void syncListControlsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + for (Control element : controlServiceClient.listControls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_listcontrols_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/AsyncUpdateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/AsyncUpdateControl.java new file mode 100644 index 00000000..d0b62aea --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/AsyncUpdateControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_updatecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.UpdateControlRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateControl { + + public static void main(String[] args) throws Exception { + asyncUpdateControl(); + } + + public static void asyncUpdateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + UpdateControlRequest request = + UpdateControlRequest.newBuilder() + .setControl(Control.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = controlServiceClient.updateControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_updatecontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControl.java new file mode 100644 index 00000000..18c0ed68 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_updatecontrol_sync] +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.UpdateControlRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateControl { + + public static void main(String[] args) throws Exception { + syncUpdateControl(); + } + + public static void syncUpdateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + UpdateControlRequest request = + UpdateControlRequest.newBuilder() + .setControl(Control.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Control response = controlServiceClient.updateControl(request); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_updatecontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java new file mode 100644 index 00000000..38f4c6ca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_updatecontrol_controlfieldmask_sync] +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateControlControlFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateControlControlFieldmask(); + } + + public static void syncUpdateControlControlFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + Control control = Control.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Control response = controlServiceClient.updateControl(control, updateMask); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_updatecontrol_controlfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlservicesettings/createcontrol/SyncCreateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlservicesettings/createcontrol/SyncCreateControl.java new file mode 100644 index 00000000..7101eecc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlservicesettings/createcontrol/SyncCreateControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlservicesettings_createcontrol_sync] +import com.google.cloud.retail.v2alpha.ControlServiceSettings; +import java.time.Duration; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceSettings.Builder controlServiceSettingsBuilder = + ControlServiceSettings.newBuilder(); + controlServiceSettingsBuilder + .createControlSettings() + .setRetrySettings( + controlServiceSettingsBuilder + .createControlSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ControlServiceSettings controlServiceSettings = controlServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_controlservicesettings_createcontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..21f14490 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.PredictionServiceClient; +import com.google.cloud.retail.v2alpha.PredictionServiceSettings; +import com.google.cloud.retail.v2alpha.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. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2alpha_generated_predictionserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..30bd9e49 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.PredictionServiceClient; +import com.google.cloud.retail.v2alpha.PredictionServiceSettings; + +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. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2alpha_generated_predictionserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..a31180b1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetEndpoint.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.PredictionServiceClient; +import com.google.cloud.retail.v2alpha.PredictionServiceSettings; +import com.google.cloud.retail.v2alpha.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. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2alpha_generated_predictionserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/AsyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/AsyncPredict.java new file mode 100644 index 00000000..f65f66ab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/AsyncPredict.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionserviceclient_predict_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.PredictRequest; +import com.google.cloud.retail.v2alpha.PredictResponse; +import com.google.cloud.retail.v2alpha.PredictionServiceClient; +import com.google.cloud.retail.v2alpha.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class AsyncPredict { + + public static void main(String[] args) throws Exception { + asyncPredict(); + } + + public static void asyncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + predictionServiceClient.predictCallable().futureCall(request); + // Do something. + PredictResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_predictionserviceclient_predict_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/SyncPredict.java new file mode 100644 index 00000000..0db5b880 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/SyncPredict.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionserviceclient_predict_sync] +import com.google.cloud.retail.v2alpha.PredictRequest; +import com.google.cloud.retail.v2alpha.PredictResponse; +import com.google.cloud.retail.v2alpha.PredictionServiceClient; +import com.google.cloud.retail.v2alpha.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + PredictResponse response = predictionServiceClient.predict(request); + } + } +} +// [END retail_v2alpha_generated_predictionserviceclient_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionservicesettings/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionservicesettings/predict/SyncPredict.java new file mode 100644 index 00000000..92c81f94 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionservicesettings/predict/SyncPredict.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionservicesettings_predict_sync] +import com.google.cloud.retail.v2alpha.PredictionServiceSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceSettings predictionServiceSettings = predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_predictionservicesettings_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java new file mode 100644 index 00000000..ff690b51 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlaces(); + } + + public static void asyncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java new file mode 100644 index 00000000..db3d5a3f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlacesLRO(); + } + + public static void asyncAddFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + AddFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java new file mode 100644 index 00000000..5b78e051 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_sync] +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlaces(); + } + + public static void syncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java new file mode 100644 index 00000000..7f9706f2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncAddFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesProductname(); + } + + public static void syncAddFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java new file mode 100644 index 00000000..7ca6dd07 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_string_sync] +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncAddFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesString(); + } + + public static void syncAddFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java new file mode 100644 index 00000000..ce11cc78 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addlocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.LocalInventory; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventories(); + } + + public static void asyncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addlocalinventories_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java new file mode 100644 index 00000000..b05daa80 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addlocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.LocalInventory; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventoriesLRO(); + } + + public static void asyncAddLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addLocalInventoriesOperationCallable().futureCall(request); + // Do something. + AddLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addlocalinventories_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventories.java new file mode 100644 index 00000000..3ebc5729 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addlocalinventories_sync] +import com.google.cloud.retail.v2alpha.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.LocalInventory; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + syncAddLocalInventories(); + } + + public static void syncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addlocalinventories_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java new file mode 100644 index 00000000..2bc807b4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addlocalinventories_productname_sync] +import com.google.cloud.retail.v2alpha.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncAddLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesProductname(); + } + + public static void syncAddLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addlocalinventories_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java new file mode 100644 index 00000000..5bf5d212 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addlocalinventories_string_sync] +import com.google.cloud.retail.v2alpha.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncAddLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesString(); + } + + public static void syncAddLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addlocalinventories_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..baae0b77 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.ProductServiceSettings; +import com.google.cloud.retail.v2alpha.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. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2alpha_generated_productserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..ece0b90b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.ProductServiceSettings; + +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. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2alpha_generated_productserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..474b2e35 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.ProductServiceSettings; +import com.google.cloud.retail.v2alpha.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. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2alpha_generated_productserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/AsyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/AsyncCreateProduct.java new file mode 100644 index 00000000..a003dfc2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/AsyncCreateProduct.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_createproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.CreateProductRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + ApiFuture future = productServiceClient.createProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_createproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProduct.java new file mode 100644 index 00000000..bff10c64 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProduct.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_createproduct_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.CreateProductRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + Product response = productServiceClient.createProduct(request); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java new file mode 100644 index 00000000..da17e00b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_createproduct_branchnameproductstring_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncCreateProductBranchnameProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductBranchnameProductString(); + } + + public static void syncCreateProductBranchnameProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_createproduct_branchnameproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductStringProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductStringProductString.java new file mode 100644 index 00000000..c8744a38 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_createproduct_stringproductstring_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_createproduct_stringproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/AsyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/AsyncDeleteProduct.java new file mode 100644 index 00000000..c83106ab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/AsyncDeleteProduct.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_deleteproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.DeleteProductRequest; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.deleteProductCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_deleteproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProduct.java new file mode 100644 index 00000000..e804a6cf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProduct.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_deleteproduct_sync] +import com.google.cloud.retail.v2alpha.DeleteProductRequest; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.Empty; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + productServiceClient.deleteProduct(request); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_deleteproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductProductname.java new file mode 100644 index 00000000..1ef70bb4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductProductname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_deleteproduct_productname_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.Empty; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_deleteproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductString.java new file mode 100644 index 00000000..a0928115 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_deleteproduct_string_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.Empty; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_deleteproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/AsyncGetProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/AsyncGetProduct.java new file mode 100644 index 00000000..78d6ec83 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/AsyncGetProduct.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_getproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.GetProductRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.getProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_getproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProduct.java new file mode 100644 index 00000000..adeba2d3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProduct.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_getproduct_sync] +import com.google.cloud.retail.v2alpha.GetProductRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + Product response = productServiceClient.getProduct(request); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_getproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductProductname.java new file mode 100644 index 00000000..ccf07b4e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductProductname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_getproduct_productname_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_getproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductString.java new file mode 100644 index 00000000..dba9f928 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_getproduct_string_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_getproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProducts.java new file mode 100644 index 00000000..ba69ccfc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProducts.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_importproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportProductsRequest; +import com.google.cloud.retail.v2alpha.ProductInputConfig; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncImportProducts { + + public static void main(String[] args) throws Exception { + asyncImportProducts(); + } + + public static void asyncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + productServiceClient.importProductsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_importproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProductsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProductsLRO.java new file mode 100644 index 00000000..15032ed9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProductsLRO.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_importproducts_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportMetadata; +import com.google.cloud.retail.v2alpha.ImportProductsRequest; +import com.google.cloud.retail.v2alpha.ImportProductsResponse; +import com.google.cloud.retail.v2alpha.ProductInputConfig; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class AsyncImportProductsLRO { + + public static void main(String[] args) throws Exception { + asyncImportProductsLRO(); + } + + public static void asyncImportProductsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + productServiceClient.importProductsOperationCallable().futureCall(request); + // Do something. + ImportProductsResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_importproducts_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/SyncImportProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/SyncImportProducts.java new file mode 100644 index 00000000..7717ec99 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/SyncImportProducts.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_importproducts_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportProductsRequest; +import com.google.cloud.retail.v2alpha.ImportProductsResponse; +import com.google.cloud.retail.v2alpha.ProductInputConfig; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncImportProducts { + + public static void main(String[] args) throws Exception { + syncImportProducts(); + } + + public static void syncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportProductsResponse response = productServiceClient.importProductsAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_importproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProducts.java new file mode 100644 index 00000000..0f6dd1aa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProducts.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_listproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ListProductsRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .setRequireTotalSize(true) + .build(); + ApiFuture future = + productServiceClient.listProductsPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_productserviceclient_listproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProductsPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProductsPaged.java new file mode 100644 index 00000000..b3103652 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProductsPaged.java @@ -0,0 +1,63 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_listproducts_paged_async] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ListProductsRequest; +import com.google.cloud.retail.v2alpha.ListProductsResponse; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.common.base.Strings; +import com.google.protobuf.FieldMask; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .setRequireTotalSize(true) + .build(); + while (true) { + ListProductsResponse response = productServiceClient.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 retail_v2alpha_generated_productserviceclient_listproducts_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProducts.java new file mode 100644 index 00000000..ea47a194 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProducts.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_listproducts_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ListProductsRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .setRequireTotalSize(true) + .build(); + for (Product element : productServiceClient.listProducts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_productserviceclient_listproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsBranchname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsBranchname.java new file mode 100644 index 00000000..c86613f9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsBranchname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_listproducts_branchname_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncListProductsBranchname { + + public static void main(String[] args) throws Exception { + syncListProductsBranchname(); + } + + public static void syncListProductsBranchname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_productserviceclient_listproducts_branchname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsString.java new file mode 100644 index 00000000..5cc1f381 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_listproducts_string_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_productserviceclient_listproducts_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProducts.java new file mode 100644 index 00000000..c1115238 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProducts.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_purgeproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + ApiFuture future = + productServiceClient.purgeProductsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_purgeproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProductsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProductsLRO.java new file mode 100644 index 00000000..8c3b4773 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProductsLRO.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_purgeproducts_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.PurgeProductsMetadata; +import com.google.cloud.retail.v2alpha.PurgeProductsRequest; +import com.google.cloud.retail.v2alpha.PurgeProductsResponse; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + OperationFuture future = + productServiceClient.purgeProductsOperationCallable().futureCall(request); + // Do something. + PurgeProductsResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_purgeproducts_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/SyncPurgeProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/SyncPurgeProducts.java new file mode 100644 index 00000000..3cf1fa1a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/SyncPurgeProducts.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_purgeproducts_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.PurgeProductsRequest; +import com.google.cloud.retail.v2alpha.PurgeProductsResponse; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + PurgeProductsResponse response = productServiceClient.purgeProductsAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_purgeproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java new file mode 100644 index 00000000..18191943 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlaces(); + } + + public static void asyncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java new file mode 100644 index 00000000..4b96f9e0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlacesLRO(); + } + + public static void asyncRemoveFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + RemoveFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java new file mode 100644 index 00000000..849b2750 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlaces(); + } + + public static void syncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java new file mode 100644 index 00000000..bfa7820f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesProductname(); + } + + public static void syncRemoveFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java new file mode 100644 index 00000000..f919d370 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_string_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesString(); + } + + public static void syncRemoveFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java new file mode 100644 index 00000000..1a36ee4e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removelocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventories(); + } + + public static void asyncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removelocalinventories_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java new file mode 100644 index 00000000..8c389038 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removelocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventoriesLRO(); + } + + public static void asyncRemoveLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeLocalInventoriesOperationCallable().futureCall(request); + // Do something. + RemoveLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removelocalinventories_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java new file mode 100644 index 00000000..58d625bb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removelocalinventories_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventories(); + } + + public static void syncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removelocalinventories_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java new file mode 100644 index 00000000..8c496a92 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removelocalinventories_productname_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesProductname(); + } + + public static void syncRemoveLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removelocalinventories_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java new file mode 100644 index 00000000..bc46b494 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removelocalinventories_string_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesString(); + } + + public static void syncRemoveLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removelocalinventories_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventory.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventory.java new file mode 100644 index 00000000..19020c79 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventory.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_setinventory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.SetInventoryRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventory { + + public static void main(String[] args) throws Exception { + asyncSetInventory(); + } + + public static void asyncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.setInventoryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_setinventory_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventoryLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventoryLRO.java new file mode 100644 index 00000000..9e579b19 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventoryLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_setinventory_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.SetInventoryMetadata; +import com.google.cloud.retail.v2alpha.SetInventoryRequest; +import com.google.cloud.retail.v2alpha.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventoryLRO { + + public static void main(String[] args) throws Exception { + asyncSetInventoryLRO(); + } + + public static void asyncSetInventoryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.setInventoryOperationCallable().futureCall(request); + // Do something. + SetInventoryResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_setinventory_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventory.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventory.java new file mode 100644 index 00000000..b3088944 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventory.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_setinventory_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.SetInventoryRequest; +import com.google.cloud.retail.v2alpha.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncSetInventory { + + public static void main(String[] args) throws Exception { + syncSetInventory(); + } + + public static void syncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + SetInventoryResponse response = productServiceClient.setInventoryAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_setinventory_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java new file mode 100644 index 00000000..1e668c88 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_setinventory_productfieldmask_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.SetInventoryResponse; +import com.google.protobuf.FieldMask; + +public class SyncSetInventoryProductFieldmask { + + public static void main(String[] args) throws Exception { + syncSetInventoryProductFieldmask(); + } + + public static void syncSetInventoryProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product inventory = Product.newBuilder().build(); + FieldMask setMask = FieldMask.newBuilder().build(); + SetInventoryResponse response = + productServiceClient.setInventoryAsync(inventory, setMask).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_setinventory_productfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/AsyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/AsyncUpdateProduct.java new file mode 100644 index 00000000..cdb49686 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/AsyncUpdateProduct.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_updateproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.updateProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_updateproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProduct.java new file mode 100644 index 00000000..a8bdaa83 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProduct.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_updateproduct_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + Product response = productServiceClient.updateProduct(request); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_updateproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java new file mode 100644 index 00000000..2f65a2a0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_updateproduct_productfieldmask_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product product = Product.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Product response = productServiceClient.updateProduct(product, updateMask); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_updateproduct_productfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/productservicesettings/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productservicesettings/createproduct/SyncCreateProduct.java new file mode 100644 index 00000000..5a1e4aee --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/productservicesettings/createproduct/SyncCreateProduct.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productservicesettings_createproduct_sync] +import com.google.cloud.retail.v2alpha.ProductServiceSettings; +import java.time.Duration; + +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. + ProductServiceSettings.Builder productServiceSettingsBuilder = + ProductServiceSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_productservicesettings_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..86db9529 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.SearchServiceSettings; +import com.google.cloud.retail.v2alpha.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. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2alpha_generated_searchserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..10124f5b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.SearchServiceSettings; + +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. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2alpha_generated_searchserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..769ee252 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.SearchServiceSettings; +import com.google.cloud.retail.v2alpha.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. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2alpha_generated_searchserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearch.java new file mode 100644 index 00000000..7792d93f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearch.java @@ -0,0 +1,69 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_search_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.SearchRequest; +import com.google.cloud.retail.v2alpha.SearchResponse; +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.UserInfo; +import java.util.ArrayList; + +public class AsyncSearch { + + public static void main(String[] args) throws Exception { + asyncSearch(); + } + + public static void asyncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + ApiFuture future = + searchServiceClient.searchPagedCallable().futureCall(request); + // Do something. + for (SearchResponse.SearchResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_searchserviceclient_search_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearchPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearchPaged.java new file mode 100644 index 00000000..a5666a84 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearchPaged.java @@ -0,0 +1,75 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_search_paged_async] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.SearchRequest; +import com.google.cloud.retail.v2alpha.SearchResponse; +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.UserInfo; +import com.google.common.base.Strings; +import java.util.ArrayList; + +public class AsyncSearchPaged { + + public static void main(String[] args) throws Exception { + asyncSearchPaged(); + } + + public static void asyncSearchPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + while (true) { + SearchResponse response = searchServiceClient.searchCallable().call(request); + for (SearchResponse.SearchResult element : response.getResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2alpha_generated_searchserviceclient_search_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/SyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/SyncSearch.java new file mode 100644 index 00000000..38878c99 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/SyncSearch.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_search_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.SearchRequest; +import com.google.cloud.retail.v2alpha.SearchResponse; +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.UserInfo; +import java.util.ArrayList; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + for (SearchResponse.SearchResult element : searchServiceClient.search(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_searchserviceclient_search_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchservicesettings/search/SyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchservicesettings/search/SyncSearch.java new file mode 100644 index 00000000..e0294354 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchservicesettings/search/SyncSearch.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchservicesettings_search_sync] +import com.google.cloud.retail.v2alpha.SearchServiceSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings.Builder searchServiceSettingsBuilder = SearchServiceSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_searchservicesettings_search_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/AsyncAddControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/AsyncAddControl.java new file mode 100644 index 00000000..992e638d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/AsyncAddControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_addcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AddControlRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class AsyncAddControl { + + public static void main(String[] args) throws Exception { + asyncAddControl(); + } + + public static void asyncAddControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + AddControlRequest request = + AddControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = + servingConfigServiceClient.addControlCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_addcontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControl.java new file mode 100644 index 00000000..a453f1d1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_addcontrol_sync] +import com.google.cloud.retail.v2alpha.AddControlRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncAddControl { + + public static void main(String[] args) throws Exception { + syncAddControl(); + } + + public static void syncAddControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + AddControlRequest request = + AddControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ServingConfig response = servingConfigServiceClient.addControl(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_addcontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java new file mode 100644 index 00000000..3088886b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_addcontrol_servingconfigname_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncAddControlServingconfigname { + + public static void main(String[] args) throws Exception { + syncAddControlServingconfigname(); + } + + public static void syncAddControlServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.addControl(servingConfig); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_addcontrol_servingconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlString.java new file mode 100644 index 00000000..c7b15a7c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_addcontrol_string_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncAddControlString { + + public static void main(String[] args) throws Exception { + syncAddControlString(); + } + + public static void syncAddControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.addControl(servingConfig); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_addcontrol_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..a9a7f8ba --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.cloud.retail.v2alpha.ServingConfigServiceSettings; +import com.google.cloud.retail.v2alpha.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. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..15d508ac --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.cloud.retail.v2alpha.ServingConfigServiceSettings; + +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. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder() + .setTransportChannelProvider( + ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..5733aa8f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetEndpoint.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.cloud.retail.v2alpha.ServingConfigServiceSettings; +import com.google.cloud.retail.v2alpha.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. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java new file mode 100644 index 00000000..2d3ac99e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CreateServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class AsyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + asyncCreateServingConfig(); + } + + public static void asyncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CreateServingConfigRequest request = + CreateServingConfigRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setServingConfig(ServingConfig.newBuilder().build()) + .setServingConfigId("servingConfigId-831052759") + .build(); + ApiFuture future = + servingConfigServiceClient.createServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 00000000..89219d88 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CreateServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CreateServingConfigRequest request = + CreateServingConfigRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setServingConfig(ServingConfig.newBuilder().build()) + .setServingConfigId("servingConfigId-831052759") + .build(); + ServingConfig response = servingConfigServiceClient.createServingConfig(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java new file mode 100644 index 00000000..c2f5a387 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_catalognameservingconfigstring_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncCreateServingConfigCatalognameServingconfigString { + + public static void main(String[] args) throws Exception { + syncCreateServingConfigCatalognameServingconfigString(); + } + + public static void syncCreateServingConfigCatalognameServingconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + ServingConfig response = + servingConfigServiceClient.createServingConfig(parent, servingConfig, servingConfigId); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_catalognameservingconfigstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java new file mode 100644 index 00000000..07956f54 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_stringservingconfigstring_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncCreateServingConfigStringServingconfigString { + + public static void main(String[] args) throws Exception { + syncCreateServingConfigStringServingconfigString(); + } + + public static void syncCreateServingConfigStringServingconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + ServingConfig response = + servingConfigServiceClient.createServingConfig(parent, servingConfig, servingConfigId); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_stringservingconfigstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java new file mode 100644 index 00000000..4d982b38 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.DeleteServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteServingConfig { + + public static void main(String[] args) throws Exception { + asyncDeleteServingConfig(); + } + + public static void asyncDeleteServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + DeleteServingConfigRequest request = + DeleteServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ApiFuture future = + servingConfigServiceClient.deleteServingConfigCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java new file mode 100644 index 00000000..2604f10a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_sync] +import com.google.cloud.retail.v2alpha.DeleteServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfig { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfig(); + } + + public static void syncDeleteServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + DeleteServingConfigRequest request = + DeleteServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + servingConfigServiceClient.deleteServingConfig(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java new file mode 100644 index 00000000..dcee76a7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_servingconfigname_sync] +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfigServingconfigname { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfigServingconfigname(); + } + + public static void syncDeleteServingConfigServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + servingConfigServiceClient.deleteServingConfig(name); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_servingconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java new file mode 100644 index 00000000..51443426 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_string_sync] +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfigString { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfigString(); + } + + public static void syncDeleteServingConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + servingConfigServiceClient.deleteServingConfig(name); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java new file mode 100644 index 00000000..1e6ad4a1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.GetServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class AsyncGetServingConfig { + + public static void main(String[] args) throws Exception { + asyncGetServingConfig(); + } + + public static void asyncGetServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + GetServingConfigRequest request = + GetServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ApiFuture future = + servingConfigServiceClient.getServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java new file mode 100644 index 00000000..eecb25e0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_sync] +import com.google.cloud.retail.v2alpha.GetServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncGetServingConfig { + + public static void main(String[] args) throws Exception { + syncGetServingConfig(); + } + + public static void syncGetServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + GetServingConfigRequest request = + GetServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ServingConfig response = servingConfigServiceClient.getServingConfig(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java new file mode 100644 index 00000000..5740b8b8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_servingconfigname_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncGetServingConfigServingconfigname { + + public static void main(String[] args) throws Exception { + syncGetServingConfigServingconfigname(); + } + + public static void syncGetServingConfigServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.getServingConfig(name); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_servingconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java new file mode 100644 index 00000000..1d90a5a8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_string_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncGetServingConfigString { + + public static void main(String[] args) throws Exception { + syncGetServingConfigString(); + } + + public static void syncGetServingConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.getServingConfig(name); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java new file mode 100644 index 00000000..0752655c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ListServingConfigsRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class AsyncListServingConfigs { + + public static void main(String[] args) throws Exception { + asyncListServingConfigs(); + } + + public static void asyncListServingConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + servingConfigServiceClient.listServingConfigsPagedCallable().futureCall(request); + // Do something. + for (ServingConfig element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java new file mode 100644 index 00000000..18de6567 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_paged_async] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ListServingConfigsRequest; +import com.google.cloud.retail.v2alpha.ListServingConfigsResponse; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.common.base.Strings; + +public class AsyncListServingConfigsPaged { + + public static void main(String[] args) throws Exception { + asyncListServingConfigsPaged(); + } + + public static void asyncListServingConfigsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListServingConfigsResponse response = + servingConfigServiceClient.listServingConfigsCallable().call(request); + for (ServingConfig element : response.getServingConfigsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java new file mode 100644 index 00000000..06072f40 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ListServingConfigsRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncListServingConfigs { + + public static void main(String[] args) throws Exception { + syncListServingConfigs(); + } + + public static void syncListServingConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java new file mode 100644 index 00000000..d812272e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_catalogname_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncListServingConfigsCatalogname { + + public static void main(String[] args) throws Exception { + syncListServingConfigsCatalogname(); + } + + public static void syncListServingConfigsCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_catalogname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java new file mode 100644 index 00000000..732ec149 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_string_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncListServingConfigsString { + + public static void main(String[] args) throws Exception { + syncListServingConfigsString(); + } + + public static void syncListServingConfigsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java new file mode 100644 index 00000000..c9b6ba34 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/AsyncRemoveControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_removecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.RemoveControlRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class AsyncRemoveControl { + + public static void main(String[] args) throws Exception { + asyncRemoveControl(); + } + + public static void asyncRemoveControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + RemoveControlRequest request = + RemoveControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = + servingConfigServiceClient.removeControlCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_removecontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControl.java new file mode 100644 index 00000000..f9c96d55 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControl.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_removecontrol_sync] +import com.google.cloud.retail.v2alpha.RemoveControlRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncRemoveControl { + + public static void main(String[] args) throws Exception { + syncRemoveControl(); + } + + public static void syncRemoveControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + RemoveControlRequest request = + RemoveControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ServingConfig response = servingConfigServiceClient.removeControl(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_removecontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java new file mode 100644 index 00000000..df8b8962 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_removecontrol_servingconfigname_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncRemoveControlServingconfigname { + + public static void main(String[] args) throws Exception { + syncRemoveControlServingconfigname(); + } + + public static void syncRemoveControlServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.removeControl(servingConfig); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_removecontrol_servingconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java new file mode 100644 index 00000000..9a293d67 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlString.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_removecontrol_string_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncRemoveControlString { + + public static void main(String[] args) throws Exception { + syncRemoveControlString(); + } + + public static void syncRemoveControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.removeControl(servingConfig); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_removecontrol_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java new file mode 100644 index 00000000..6d1efdaa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.cloud.retail.v2alpha.UpdateServingConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateServingConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateServingConfig(); + } + + public static void asyncUpdateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + UpdateServingConfigRequest request = + UpdateServingConfigRequest.newBuilder() + .setServingConfig(ServingConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + servingConfigServiceClient.updateServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java new file mode 100644 index 00000000..b8e568a5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.cloud.retail.v2alpha.UpdateServingConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateServingConfig { + + public static void main(String[] args) throws Exception { + syncUpdateServingConfig(); + } + + public static void syncUpdateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + UpdateServingConfigRequest request = + UpdateServingConfigRequest.newBuilder() + .setServingConfig(ServingConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ServingConfig response = servingConfigServiceClient.updateServingConfig(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java new file mode 100644 index 00000000..0da7a95e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_servingconfigfieldmask_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateServingConfigServingconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateServingConfigServingconfigFieldmask(); + } + + public static void syncUpdateServingConfigServingconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ServingConfig response = + servingConfigServiceClient.updateServingConfig(servingConfig, updateMask); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_servingconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 00000000..68512e7b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigservicesettings_createservingconfig_sync] +import com.google.cloud.retail.v2alpha.ServingConfigServiceSettings; +import java.time.Duration; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceSettings.Builder servingConfigServiceSettingsBuilder = + ServingConfigServiceSettings.newBuilder(); + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .setRetrySettings( + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ServingConfigServiceSettings servingConfigServiceSettings = + servingConfigServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_servingconfigservicesettings_createservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 00000000..5133c288 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.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.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_catalogservicestubsettings_updatecatalog_sync] +import com.google.cloud.retail.v2alpha.stub.CatalogServiceStubSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceStubSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceStubSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceStubSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_catalogservicestubsettings_updatecatalog_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java new file mode 100644 index 00000000..9ca8930b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/completionservicestubsettings/completequery/SyncCompleteQuery.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.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_completionservicestubsettings_completequery_sync] +import com.google.cloud.retail.v2alpha.stub.CompletionServiceStubSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceStubSettings.Builder completionServiceSettingsBuilder = + CompletionServiceStubSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceStubSettings completionServiceSettings = + completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_completionservicestubsettings_completequery_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java new file mode 100644 index 00000000..f4c4c7fe --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/controlservicestubsettings/createcontrol/SyncCreateControl.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.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_controlservicestubsettings_createcontrol_sync] +import com.google.cloud.retail.v2alpha.stub.ControlServiceStubSettings; +import java.time.Duration; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceStubSettings.Builder controlServiceSettingsBuilder = + ControlServiceStubSettings.newBuilder(); + controlServiceSettingsBuilder + .createControlSettings() + .setRetrySettings( + controlServiceSettingsBuilder + .createControlSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ControlServiceStubSettings controlServiceSettings = controlServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_controlservicestubsettings_createcontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/predictionservicestubsettings/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/predictionservicestubsettings/predict/SyncPredict.java new file mode 100644 index 00000000..890b642b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/predictionservicestubsettings/predict/SyncPredict.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.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_predictionservicestubsettings_predict_sync] +import com.google.cloud.retail.v2alpha.stub.PredictionServiceStubSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceStubSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceStubSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceStubSettings predictionServiceSettings = + predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_predictionservicestubsettings_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/productservicestubsettings/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/productservicestubsettings/createproduct/SyncCreateProduct.java new file mode 100644 index 00000000..4a3bc6f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/productservicestubsettings/createproduct/SyncCreateProduct.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.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_productservicestubsettings_createproduct_sync] +import com.google.cloud.retail.v2alpha.stub.ProductServiceStubSettings; +import java.time.Duration; + +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. + ProductServiceStubSettings.Builder productServiceSettingsBuilder = + ProductServiceStubSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceStubSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_productservicestubsettings_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/searchservicestubsettings/search/SyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/searchservicestubsettings/search/SyncSearch.java new file mode 100644 index 00000000..8ed8a423 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/searchservicestubsettings/search/SyncSearch.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.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_searchservicestubsettings_search_sync] +import com.google.cloud.retail.v2alpha.stub.SearchServiceStubSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceStubSettings.Builder searchServiceSettingsBuilder = + SearchServiceStubSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceStubSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_searchservicestubsettings_search_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 00000000..f2b8880a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.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.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_servingconfigservicestubsettings_createservingconfig_sync] +import com.google.cloud.retail.v2alpha.stub.ServingConfigServiceStubSettings; +import java.time.Duration; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceStubSettings.Builder servingConfigServiceSettingsBuilder = + ServingConfigServiceStubSettings.newBuilder(); + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .setRetrySettings( + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ServingConfigServiceStubSettings servingConfigServiceSettings = + servingConfigServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_servingconfigservicestubsettings_createservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 00000000..8da2f025 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.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.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_usereventservicestubsettings_writeuserevent_sync] +import com.google.cloud.retail.v2alpha.stub.UserEventServiceStubSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceStubSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceStubSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceStubSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_usereventservicestubsettings_writeuserevent_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java new file mode 100644 index 00000000..5ade671c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_collectuserevent_async] +import com.google.api.HttpBody; +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CollectUserEventRequest; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class AsyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + asyncCollectUserEvent(); + } + + public static void asyncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + ApiFuture future = + userEventServiceClient.collectUserEventCallable().futureCall(request); + // Do something. + HttpBody response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_collectuserevent_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java new file mode 100644 index 00000000..11606861 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/SyncCollectUserEvent.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_collectuserevent_sync] +import com.google.api.HttpBody; +import com.google.cloud.retail.v2alpha.CollectUserEventRequest; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class SyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + syncCollectUserEvent(); + } + + public static void syncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + HttpBody response = userEventServiceClient.collectUserEvent(request); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_collectuserevent_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..183e14bf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.cloud.retail.v2alpha.UserEventServiceSettings; +import com.google.cloud.retail.v2alpha.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. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2alpha_generated_usereventserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..c9839dd3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.cloud.retail.v2alpha.UserEventServiceSettings; + +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. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2alpha_generated_usereventserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..dea987d9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetEndpoint.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.cloud.retail.v2alpha.UserEventServiceSettings; +import com.google.cloud.retail.v2alpha.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. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2alpha_generated_usereventserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEvents.java new file mode 100644 index 00000000..a028e74b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEvents.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_importuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportUserEventsRequest; +import com.google.cloud.retail.v2alpha.UserEventInputConfig; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncImportUserEvents { + + public static void main(String[] args) throws Exception { + asyncImportUserEvents(); + } + + public static void asyncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.importUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_importuserevents_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java new file mode 100644 index 00000000..4bd04e5a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_importuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportMetadata; +import com.google.cloud.retail.v2alpha.ImportUserEventsRequest; +import com.google.cloud.retail.v2alpha.ImportUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventInputConfig; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class AsyncImportUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncImportUserEventsLRO(); + } + + public static void asyncImportUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + OperationFuture future = + userEventServiceClient.importUserEventsOperationCallable().futureCall(request); + // Do something. + ImportUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_importuserevents_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/SyncImportUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/SyncImportUserEvents.java new file mode 100644 index 00000000..28f8f78d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/SyncImportUserEvents.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_importuserevents_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportUserEventsRequest; +import com.google.cloud.retail.v2alpha.ImportUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventInputConfig; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class SyncImportUserEvents { + + public static void main(String[] args) throws Exception { + syncImportUserEvents(); + } + + public static void syncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ImportUserEventsResponse response = + userEventServiceClient.importUserEventsAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_importuserevents_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java new file mode 100644 index 00000000..1f9badbb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_purgeuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.PurgeUserEventsRequest; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEvents(); + } + + public static void asyncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + ApiFuture future = + userEventServiceClient.purgeUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_purgeuserevents_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java new file mode 100644 index 00000000..74cdb4bd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_purgeuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.PurgeMetadata; +import com.google.cloud.retail.v2alpha.PurgeUserEventsRequest; +import com.google.cloud.retail.v2alpha.PurgeUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class AsyncPurgeUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEventsLRO(); + } + + public static void asyncPurgeUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + OperationFuture future = + userEventServiceClient.purgeUserEventsOperationCallable().futureCall(request); + // Do something. + PurgeUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_purgeuserevents_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java new file mode 100644 index 00000000..f2cba1ff --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_purgeuserevents_sync] +import com.google.cloud.retail.v2alpha.PurgeUserEventsRequest; +import com.google.cloud.retail.v2alpha.PurgeUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class SyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + syncPurgeUserEvents(); + } + + public static void syncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + PurgeUserEventsResponse response = userEventServiceClient.purgeUserEventsAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_purgeuserevents_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java new file mode 100644 index 00000000..39f60ef8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.RejoinUserEventsRequest; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEvents(); + } + + public static void asyncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + ApiFuture future = + userEventServiceClient.rejoinUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java new file mode 100644 index 00000000..094dcc4d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2alpha.RejoinUserEventsRequest; +import com.google.cloud.retail.v2alpha.RejoinUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class AsyncRejoinUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEventsLRO(); + } + + public static void asyncRejoinUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + OperationFuture future = + userEventServiceClient.rejoinUserEventsOperationCallable().futureCall(request); + // Do something. + RejoinUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java new file mode 100644 index 00000000..77cffbb6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_sync] +import com.google.cloud.retail.v2alpha.RejoinUserEventsRequest; +import com.google.cloud.retail.v2alpha.RejoinUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class SyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + syncRejoinUserEvents(); + } + + public static void syncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + RejoinUserEventsResponse response = + userEventServiceClient.rejoinUserEventsAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java new file mode 100644 index 00000000..76b3c78a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_writeuserevent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.UserEvent; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.cloud.retail.v2alpha.WriteUserEventRequest; + +public class AsyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + asyncWriteUserEvent(); + } + + public static void asyncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.writeUserEventCallable().futureCall(request); + // Do something. + UserEvent response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_writeuserevent_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 00000000..c9690fc3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/SyncWriteUserEvent.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_writeuserevent_sync] +import com.google.cloud.retail.v2alpha.UserEvent; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.cloud.retail.v2alpha.WriteUserEventRequest; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + UserEvent response = userEventServiceClient.writeUserEvent(request); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_writeuserevent_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 00000000..21d761d1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventservicesettings/writeuserevent/SyncWriteUserEvent.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.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventservicesettings_writeuserevent_sync] +import com.google.cloud.retail.v2alpha.UserEventServiceSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_usereventservicesettings_writeuserevent_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java new file mode 100644 index 00000000..84ac3536 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_addcatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogAttribute; +import com.google.cloud.retail.v2beta.CatalogServiceClient; + +public class AsyncAddCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncAddCatalogAttribute(); + } + + public static void asyncAddCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.addCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_addcatalogattribute_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java new file mode 100644 index 00000000..95b7db63 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_addcatalogattribute_sync] +import com.google.cloud.retail.v2beta.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogAttribute; +import com.google.cloud.retail.v2beta.CatalogServiceClient; + +public class SyncAddCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncAddCatalogAttribute(); + } + + public static void syncAddCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.addCatalogAttribute(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_addcatalogattribute_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..e11bb764 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CatalogServiceSettings; +import com.google.cloud.retail.v2beta.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. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2beta_generated_catalogserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..5302d33d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CatalogServiceSettings; + +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. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2beta_generated_catalogserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..f7077726 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CatalogServiceSettings; +import com.google.cloud.retail.v2beta.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. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2beta_generated_catalogserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java new file mode 100644 index 00000000..3fe2b04f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getattributesconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetAttributesConfigRequest; + +public class AsyncGetAttributesConfig { + + public static void main(String[] args) throws Exception { + asyncGetAttributesConfig(); + } + + public static void asyncGetAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetAttributesConfigRequest request = + GetAttributesConfigRequest.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + ApiFuture future = + catalogServiceClient.getAttributesConfigCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getattributesconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java new file mode 100644 index 00000000..f9fbcc7b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getattributesconfig_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetAttributesConfigRequest; + +public class SyncGetAttributesConfig { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfig(); + } + + public static void syncGetAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetAttributesConfigRequest request = + GetAttributesConfigRequest.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + AttributesConfig response = catalogServiceClient.getAttributesConfig(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getattributesconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java new file mode 100644 index 00000000..4ae60e57 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getattributesconfig_attributesconfigname_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; + +public class SyncGetAttributesConfigAttributesconfigname { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfigAttributesconfigname(); + } + + public static void syncGetAttributesConfigAttributesconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + AttributesConfig response = catalogServiceClient.getAttributesConfig(name); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getattributesconfig_attributesconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java new file mode 100644 index 00000000..186e4186 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getattributesconfig_string_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; + +public class SyncGetAttributesConfigString { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfigString(); + } + + public static void syncGetAttributesConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + AttributesConfig response = catalogServiceClient.getAttributesConfig(name); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getattributesconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java new file mode 100644 index 00000000..1b76379f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getcompletionconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.CompletionConfigName; +import com.google.cloud.retail.v2beta.GetCompletionConfigRequest; + +public class AsyncGetCompletionConfig { + + public static void main(String[] args) throws Exception { + asyncGetCompletionConfig(); + } + + public static void asyncGetCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetCompletionConfigRequest request = + GetCompletionConfigRequest.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + ApiFuture future = + catalogServiceClient.getCompletionConfigCallable().futureCall(request); + // Do something. + CompletionConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getcompletionconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java new file mode 100644 index 00000000..82639a1e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getcompletionconfig_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.CompletionConfigName; +import com.google.cloud.retail.v2beta.GetCompletionConfigRequest; + +public class SyncGetCompletionConfig { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfig(); + } + + public static void syncGetCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetCompletionConfigRequest request = + GetCompletionConfigRequest.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + CompletionConfig response = catalogServiceClient.getCompletionConfig(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getcompletionconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java new file mode 100644 index 00000000..8ee48946 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getcompletionconfig_completionconfigname_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.CompletionConfigName; + +public class SyncGetCompletionConfigCompletionconfigname { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfigCompletionconfigname(); + } + + public static void syncGetCompletionConfigCompletionconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + CompletionConfig response = catalogServiceClient.getCompletionConfig(name); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getcompletionconfig_completionconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java new file mode 100644 index 00000000..a09242da --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getcompletionconfig_string_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.CompletionConfigName; + +public class SyncGetCompletionConfigString { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfigString(); + } + + public static void syncGetCompletionConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + CompletionConfig response = catalogServiceClient.getCompletionConfig(name); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getcompletionconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java new file mode 100644 index 00000000..ca136476 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetDefaultBranchRequest; +import com.google.cloud.retail.v2beta.GetDefaultBranchResponse; + +public class AsyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncGetDefaultBranch(); + } + + public static void asyncGetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetDefaultBranchRequest request = + GetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + ApiFuture future = + catalogServiceClient.getDefaultBranchCallable().futureCall(request); + // Do something. + GetDefaultBranchResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getdefaultbranch_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java new file mode 100644 index 00000000..33edc3ab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getdefaultbranch_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetDefaultBranchRequest; +import com.google.cloud.retail.v2beta.GetDefaultBranchResponse; + +public class SyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranch(); + } + + public static void syncGetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetDefaultBranchRequest request = + GetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getdefaultbranch_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java new file mode 100644 index 00000000..335ea14b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchCatalogname(); + } + + public static void syncGetDefaultBranchCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(catalog); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java new file mode 100644 index 00000000..81bef11f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getdefaultbranch_string_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchString(); + } + + public static void syncGetDefaultBranchString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(catalog); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getdefaultbranch_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogs.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogs.java new file mode 100644 index 00000000..ababcfd9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogs.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_listcatalogs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.ListCatalogsRequest; +import com.google.cloud.retail.v2beta.LocationName; + +public class AsyncListCatalogs { + + public static void main(String[] args) throws Exception { + asyncListCatalogs(); + } + + public static void asyncListCatalogs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ListCatalogsRequest request = + ListCatalogsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + catalogServiceClient.listCatalogsPagedCallable().futureCall(request); + // Do something. + for (Catalog element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_listcatalogs_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java new file mode 100644 index 00000000..7679cd51 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_listcatalogs_paged_async] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.ListCatalogsRequest; +import com.google.cloud.retail.v2beta.ListCatalogsResponse; +import com.google.cloud.retail.v2beta.LocationName; +import com.google.common.base.Strings; + +public class AsyncListCatalogsPaged { + + public static void main(String[] args) throws Exception { + asyncListCatalogsPaged(); + } + + public static void asyncListCatalogsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ListCatalogsRequest request = + ListCatalogsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListCatalogsResponse response = catalogServiceClient.listCatalogsCallable().call(request); + for (Catalog element : response.getCatalogsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_listcatalogs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogs.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogs.java new file mode 100644 index 00000000..7c30dedf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogs.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_listcatalogs_sync] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.ListCatalogsRequest; +import com.google.cloud.retail.v2beta.LocationName; + +public class SyncListCatalogs { + + public static void main(String[] args) throws Exception { + syncListCatalogs(); + } + + public static void syncListCatalogs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ListCatalogsRequest request = + ListCatalogsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Catalog element : catalogServiceClient.listCatalogs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_listcatalogs_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java new file mode 100644 index 00000000..8ea17f20 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_listcatalogs_locationname_sync] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.LocationName; + +public class SyncListCatalogsLocationname { + + public static void main(String[] args) throws Exception { + syncListCatalogsLocationname(); + } + + public static void syncListCatalogsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Catalog element : catalogServiceClient.listCatalogs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_listcatalogs_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsString.java new file mode 100644 index 00000000..89c0e5fc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_listcatalogs_string_sync] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.LocationName; + +public class SyncListCatalogsString { + + public static void main(String[] args) throws Exception { + syncListCatalogsString(); + } + + public static void syncListCatalogsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Catalog element : catalogServiceClient.listCatalogs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_listcatalogs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java new file mode 100644 index 00000000..03d463cf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_removecatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest; + +public class AsyncRemoveCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncRemoveCatalogAttribute(); + } + + public static void asyncRemoveCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + ApiFuture future = + catalogServiceClient.removeCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_removecatalogattribute_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java new file mode 100644 index 00000000..894ab601 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_removecatalogattribute_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest; + +public class SyncRemoveCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncRemoveCatalogAttribute(); + } + + public static void syncRemoveCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + AttributesConfig response = catalogServiceClient.removeCatalogAttribute(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_removecatalogattribute_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java new file mode 100644 index 00000000..02f62a5f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_replacecatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogAttribute; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest; +import com.google.protobuf.FieldMask; + +public class AsyncReplaceCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncReplaceCatalogAttribute(); + } + + public static void asyncReplaceCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.replaceCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_replacecatalogattribute_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java new file mode 100644 index 00000000..ffe7f215 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_replacecatalogattribute_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogAttribute; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest; +import com.google.protobuf.FieldMask; + +public class SyncReplaceCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncReplaceCatalogAttribute(); + } + + public static void syncReplaceCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.replaceCatalogAttribute(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_replacecatalogattribute_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java new file mode 100644 index 00000000..88af8fe6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_setdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class AsyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncSetDefaultBranch(); + } + + public static void asyncSetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + SetDefaultBranchRequest request = + SetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setBranchId( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setNote("note3387378") + .setForce(true) + .build(); + ApiFuture future = catalogServiceClient.setDefaultBranchCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_setdefaultbranch_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java new file mode 100644 index 00000000..f8605468 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_setdefaultbranch_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranch(); + } + + public static void syncSetDefaultBranch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + SetDefaultBranchRequest request = + SetDefaultBranchRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setBranchId( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setNote("note3387378") + .setForce(true) + .build(); + catalogServiceClient.setDefaultBranch(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_setdefaultbranch_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java new file mode 100644 index 00000000..f7707632 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchCatalogname(); + } + + public static void syncSetDefaultBranchCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + catalogServiceClient.setDefaultBranch(catalog); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java new file mode 100644 index 00000000..88f9d27f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_setdefaultbranch_string_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchString(); + } + + public static void syncSetDefaultBranchString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + String catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + catalogServiceClient.setDefaultBranch(catalog); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_setdefaultbranch_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java new file mode 100644 index 00000000..43456026 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updateattributesconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.UpdateAttributesConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateAttributesConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateAttributesConfig(); + } + + public static void asyncUpdateAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateAttributesConfigRequest request = + UpdateAttributesConfigRequest.newBuilder() + .setAttributesConfig(AttributesConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.updateAttributesConfigCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updateattributesconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java new file mode 100644 index 00000000..abbf7b88 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updateattributesconfig_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.UpdateAttributesConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAttributesConfig { + + public static void main(String[] args) throws Exception { + syncUpdateAttributesConfig(); + } + + public static void syncUpdateAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateAttributesConfigRequest request = + UpdateAttributesConfigRequest.newBuilder() + .setAttributesConfig(AttributesConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.updateAttributesConfig(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updateattributesconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java new file mode 100644 index 00000000..cab614a3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updateattributesconfig_attributesconfigfieldmask_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAttributesConfigAttributesconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateAttributesConfigAttributesconfigFieldmask(); + } + + public static void syncUpdateAttributesConfigAttributesconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AttributesConfig attributesConfig = AttributesConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + AttributesConfig response = + catalogServiceClient.updateAttributesConfig(attributesConfig, updateMask); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updateattributesconfig_attributesconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java new file mode 100644 index 00000000..260cf62c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecatalog_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + asyncUpdateCatalog(); + } + + public static void asyncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCatalogRequest request = + UpdateCatalogRequest.newBuilder() + .setCatalog(Catalog.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = catalogServiceClient.updateCatalogCallable().futureCall(request); + // Do something. + Catalog response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecatalog_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 00000000..c2a33974 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalog.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecatalog_sync] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCatalogRequest request = + UpdateCatalogRequest.newBuilder() + .setCatalog(Catalog.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Catalog response = catalogServiceClient.updateCatalog(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecatalog_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java new file mode 100644 index 00000000..ff243649 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalogCatalogFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateCatalogCatalogFieldmask(); + } + + public static void syncUpdateCatalogCatalogFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + Catalog catalog = Catalog.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Catalog response = catalogServiceClient.updateCatalog(catalog, updateMask); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java new file mode 100644 index 00000000..f2d4a974 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.UpdateCompletionConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateCompletionConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateCompletionConfig(); + } + + public static void asyncUpdateCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCompletionConfigRequest request = + UpdateCompletionConfigRequest.newBuilder() + .setCompletionConfig(CompletionConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.updateCompletionConfigCallable().futureCall(request); + // Do something. + CompletionConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java new file mode 100644 index 00000000..7b0ff57f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.UpdateCompletionConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCompletionConfig { + + public static void main(String[] args) throws Exception { + syncUpdateCompletionConfig(); + } + + public static void syncUpdateCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCompletionConfigRequest request = + UpdateCompletionConfigRequest.newBuilder() + .setCompletionConfig(CompletionConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + CompletionConfig response = catalogServiceClient.updateCompletionConfig(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java new file mode 100644 index 00000000..2b7ca867 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_completionconfigfieldmask_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCompletionConfigCompletionconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateCompletionConfigCompletionconfigFieldmask(); + } + + public static void syncUpdateCompletionConfigCompletionconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CompletionConfig completionConfig = CompletionConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + CompletionConfig response = + catalogServiceClient.updateCompletionConfig(completionConfig, updateMask); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_completionconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 00000000..2cbfa3b9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogservicesettings/updatecatalog/SyncUpdateCatalog.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogservicesettings_updatecatalog_sync] +import com.google.cloud.retail.v2beta.CatalogServiceSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_catalogservicesettings_updatecatalog_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/AsyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/AsyncCompleteQuery.java new file mode 100644 index 00000000..80ddc3d2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/AsyncCompleteQuery.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_completequery_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CompleteQueryRequest; +import com.google.cloud.retail.v2beta.CompleteQueryResponse; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import java.util.ArrayList; + +public class AsyncCompleteQuery { + + public static void main(String[] args) throws Exception { + asyncCompleteQuery(); + } + + public static void asyncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + ApiFuture future = + completionServiceClient.completeQueryCallable().futureCall(request); + // Do something. + CompleteQueryResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_completionserviceclient_completequery_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/SyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/SyncCompleteQuery.java new file mode 100644 index 00000000..d6f90b8d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/SyncCompleteQuery.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_completequery_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CompleteQueryRequest; +import com.google.cloud.retail.v2beta.CompleteQueryResponse; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import java.util.ArrayList; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + CompleteQueryResponse response = completionServiceClient.completeQuery(request); + } + } +} +// [END retail_v2beta_generated_completionserviceclient_completequery_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..3f0b032c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.CompletionServiceSettings; +import com.google.cloud.retail.v2beta.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. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2beta_generated_completionserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..2d8d6699 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider1.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.CompletionServiceSettings; + +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. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2beta_generated_completionserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..9d8d7eb1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetEndpoint.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.CompletionServiceSettings; +import com.google.cloud.retail.v2beta.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. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2beta_generated_completionserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java new file mode 100644 index 00000000..963c1452 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionData.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_importcompletiondata_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CompletionDataInputConfig; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.ImportCompletionDataRequest; +import com.google.longrunning.Operation; + +public class AsyncImportCompletionData { + + public static void main(String[] args) throws Exception { + asyncImportCompletionData(); + } + + public static void asyncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + completionServiceClient.importCompletionDataCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_completionserviceclient_importcompletiondata_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java new file mode 100644 index 00000000..ffac086c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_importcompletiondata_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CompletionDataInputConfig; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.ImportCompletionDataRequest; +import com.google.cloud.retail.v2beta.ImportCompletionDataResponse; +import com.google.cloud.retail.v2beta.ImportMetadata; + +public class AsyncImportCompletionDataLRO { + + public static void main(String[] args) throws Exception { + asyncImportCompletionDataLRO(); + } + + public static void asyncImportCompletionDataLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + completionServiceClient.importCompletionDataOperationCallable().futureCall(request); + // Do something. + ImportCompletionDataResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_completionserviceclient_importcompletiondata_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/SyncImportCompletionData.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/SyncImportCompletionData.java new file mode 100644 index 00000000..86e4ab28 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/SyncImportCompletionData.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_importcompletiondata_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CompletionDataInputConfig; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.ImportCompletionDataRequest; +import com.google.cloud.retail.v2beta.ImportCompletionDataResponse; + +public class SyncImportCompletionData { + + public static void main(String[] args) throws Exception { + syncImportCompletionData(); + } + + public static void syncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportCompletionDataResponse response = + completionServiceClient.importCompletionDataAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_completionserviceclient_importcompletiondata_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/completionservicesettings/completequery/SyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionservicesettings/completequery/SyncCompleteQuery.java new file mode 100644 index 00000000..de62c829 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/completionservicesettings/completequery/SyncCompleteQuery.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionservicesettings_completequery_sync] +import com.google.cloud.retail.v2beta.CompletionServiceSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings.Builder completionServiceSettingsBuilder = + CompletionServiceSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceSettings completionServiceSettings = completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_completionservicesettings_completequery_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..320d3850 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ControlServiceSettings; +import com.google.cloud.retail.v2beta.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. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2beta_generated_controlserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..3898eca2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ControlServiceSettings; + +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. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder() + .setTransportChannelProvider( + ControlServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2beta_generated_controlserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..6faec97b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ControlServiceSettings; +import com.google.cloud.retail.v2beta.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. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2beta_generated_controlserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/AsyncCreateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/AsyncCreateControl.java new file mode 100644 index 00000000..00f81a93 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/AsyncCreateControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_createcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.CreateControlRequest; + +public class AsyncCreateControl { + + public static void main(String[] args) throws Exception { + asyncCreateControl(); + } + + public static void asyncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CreateControlRequest request = + CreateControlRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setControl(Control.newBuilder().build()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = controlServiceClient.createControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_createcontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControl.java new file mode 100644 index 00000000..8a7b3559 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_createcontrol_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.CreateControlRequest; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CreateControlRequest request = + CreateControlRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setControl(Control.newBuilder().build()) + .setControlId("controlId-395080872") + .build(); + Control response = controlServiceClient.createControl(request); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_createcontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java new file mode 100644 index 00000000..6a1be976 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_createcontrol_catalognamecontrolstring_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncCreateControlCatalognameControlString { + + public static void main(String[] args) throws Exception { + syncCreateControlCatalognameControlString(); + } + + public static void syncCreateControlCatalognameControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + Control response = controlServiceClient.createControl(parent, control, controlId); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_createcontrol_catalognamecontrolstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java new file mode 100644 index 00000000..a0d032c4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlStringControlString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_createcontrol_stringcontrolstring_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncCreateControlStringControlString { + + public static void main(String[] args) throws Exception { + syncCreateControlStringControlString(); + } + + public static void syncCreateControlStringControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + Control response = controlServiceClient.createControl(parent, control, controlId); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_createcontrol_stringcontrolstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/AsyncDeleteControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/AsyncDeleteControl.java new file mode 100644 index 00000000..f8d7faa8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/AsyncDeleteControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_deletecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.DeleteControlRequest; +import com.google.protobuf.Empty; + +public class AsyncDeleteControl { + + public static void main(String[] args) throws Exception { + asyncDeleteControl(); + } + + public static void asyncDeleteControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + DeleteControlRequest request = + DeleteControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + ApiFuture future = controlServiceClient.deleteControlCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_deletecontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControl.java new file mode 100644 index 00000000..c9ad4ff4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_deletecontrol_sync] +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.DeleteControlRequest; +import com.google.protobuf.Empty; + +public class SyncDeleteControl { + + public static void main(String[] args) throws Exception { + syncDeleteControl(); + } + + public static void syncDeleteControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + DeleteControlRequest request = + DeleteControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + controlServiceClient.deleteControl(request); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_deletecontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java new file mode 100644 index 00000000..551e17ae --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlControlname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_deletecontrol_controlname_sync] +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteControlControlname { + + public static void main(String[] args) throws Exception { + syncDeleteControlControlname(); + } + + public static void syncDeleteControlControlname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + controlServiceClient.deleteControl(name); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_deletecontrol_controlname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlString.java new file mode 100644 index 00000000..9492b937 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_deletecontrol_string_sync] +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteControlString { + + public static void main(String[] args) throws Exception { + syncDeleteControlString(); + } + + public static void syncDeleteControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString(); + controlServiceClient.deleteControl(name); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_deletecontrol_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/AsyncGetControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/AsyncGetControl.java new file mode 100644 index 00000000..a6c2c60a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/AsyncGetControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_getcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.GetControlRequest; + +public class AsyncGetControl { + + public static void main(String[] args) throws Exception { + asyncGetControl(); + } + + public static void asyncGetControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + GetControlRequest request = + GetControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + ApiFuture future = controlServiceClient.getControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_getcontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControl.java new file mode 100644 index 00000000..e19fd69d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_getcontrol_sync] +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.GetControlRequest; + +public class SyncGetControl { + + public static void main(String[] args) throws Exception { + syncGetControl(); + } + + public static void syncGetControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + GetControlRequest request = + GetControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + Control response = controlServiceClient.getControl(request); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_getcontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlControlname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlControlname.java new file mode 100644 index 00000000..bd7b90c7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlControlname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_getcontrol_controlname_sync] +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncGetControlControlname { + + public static void main(String[] args) throws Exception { + syncGetControlControlname(); + } + + public static void syncGetControlControlname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + Control response = controlServiceClient.getControl(name); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_getcontrol_controlname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlString.java new file mode 100644 index 00000000..dab545a1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_getcontrol_string_sync] +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncGetControlString { + + public static void main(String[] args) throws Exception { + syncGetControlString(); + } + + public static void syncGetControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString(); + Control response = controlServiceClient.getControl(name); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_getcontrol_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControls.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControls.java new file mode 100644 index 00000000..505b6fc8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControls.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_listcontrols_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ListControlsRequest; + +public class AsyncListControls { + + public static void main(String[] args) throws Exception { + asyncListControls(); + } + + public static void asyncListControls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + controlServiceClient.listControlsPagedCallable().futureCall(request); + // Do something. + for (Control element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_controlserviceclient_listcontrols_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControlsPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControlsPaged.java new file mode 100644 index 00000000..71f67e10 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControlsPaged.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_listcontrols_paged_async] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ListControlsRequest; +import com.google.cloud.retail.v2beta.ListControlsResponse; +import com.google.common.base.Strings; + +public class AsyncListControlsPaged { + + public static void main(String[] args) throws Exception { + asyncListControlsPaged(); + } + + public static void asyncListControlsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListControlsResponse response = controlServiceClient.listControlsCallable().call(request); + for (Control element : response.getControlsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2beta_generated_controlserviceclient_listcontrols_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControls.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControls.java new file mode 100644 index 00000000..01dbd88c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControls.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_listcontrols_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ListControlsRequest; + +public class SyncListControls { + + public static void main(String[] args) throws Exception { + syncListControls(); + } + + public static void syncListControls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Control element : controlServiceClient.listControls(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_controlserviceclient_listcontrols_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsCatalogname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsCatalogname.java new file mode 100644 index 00000000..8289913f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsCatalogname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_listcontrols_catalogname_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncListControlsCatalogname { + + public static void main(String[] args) throws Exception { + syncListControlsCatalogname(); + } + + public static void syncListControlsCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + for (Control element : controlServiceClient.listControls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_controlserviceclient_listcontrols_catalogname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsString.java new file mode 100644 index 00000000..c60cb18b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_listcontrols_string_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncListControlsString { + + public static void main(String[] args) throws Exception { + syncListControlsString(); + } + + public static void syncListControlsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + for (Control element : controlServiceClient.listControls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_controlserviceclient_listcontrols_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/AsyncUpdateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/AsyncUpdateControl.java new file mode 100644 index 00000000..928312da --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/AsyncUpdateControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_updatecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.UpdateControlRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateControl { + + public static void main(String[] args) throws Exception { + asyncUpdateControl(); + } + + public static void asyncUpdateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + UpdateControlRequest request = + UpdateControlRequest.newBuilder() + .setControl(Control.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = controlServiceClient.updateControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_updatecontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControl.java new file mode 100644 index 00000000..4b3913cf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_updatecontrol_sync] +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.UpdateControlRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateControl { + + public static void main(String[] args) throws Exception { + syncUpdateControl(); + } + + public static void syncUpdateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + UpdateControlRequest request = + UpdateControlRequest.newBuilder() + .setControl(Control.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Control response = controlServiceClient.updateControl(request); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_updatecontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java new file mode 100644 index 00000000..dc3f7869 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_updatecontrol_controlfieldmask_sync] +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateControlControlFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateControlControlFieldmask(); + } + + public static void syncUpdateControlControlFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + Control control = Control.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Control response = controlServiceClient.updateControl(control, updateMask); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_updatecontrol_controlfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/controlservicesettings/createcontrol/SyncCreateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlservicesettings/createcontrol/SyncCreateControl.java new file mode 100644 index 00000000..86d8b9b2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/controlservicesettings/createcontrol/SyncCreateControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlservicesettings_createcontrol_sync] +import com.google.cloud.retail.v2beta.ControlServiceSettings; +import java.time.Duration; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceSettings.Builder controlServiceSettingsBuilder = + ControlServiceSettings.newBuilder(); + controlServiceSettingsBuilder + .createControlSettings() + .setRetrySettings( + controlServiceSettingsBuilder + .createControlSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ControlServiceSettings controlServiceSettings = controlServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_controlservicesettings_createcontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..3dd974c1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.PredictionServiceClient; +import com.google.cloud.retail.v2beta.PredictionServiceSettings; +import com.google.cloud.retail.v2beta.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. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2beta_generated_predictionserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..35739124 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.PredictionServiceClient; +import com.google.cloud.retail.v2beta.PredictionServiceSettings; + +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. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2beta_generated_predictionserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..551d1f23 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetEndpoint.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.PredictionServiceClient; +import com.google.cloud.retail.v2beta.PredictionServiceSettings; +import com.google.cloud.retail.v2beta.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. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2beta_generated_predictionserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/AsyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/AsyncPredict.java new file mode 100644 index 00000000..a9c14f7d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/AsyncPredict.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionserviceclient_predict_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.PredictRequest; +import com.google.cloud.retail.v2beta.PredictResponse; +import com.google.cloud.retail.v2beta.PredictionServiceClient; +import com.google.cloud.retail.v2beta.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class AsyncPredict { + + public static void main(String[] args) throws Exception { + asyncPredict(); + } + + public static void asyncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + predictionServiceClient.predictCallable().futureCall(request); + // Do something. + PredictResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_predictionserviceclient_predict_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/SyncPredict.java new file mode 100644 index 00000000..d30a345b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/SyncPredict.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionserviceclient_predict_sync] +import com.google.cloud.retail.v2beta.PredictRequest; +import com.google.cloud.retail.v2beta.PredictResponse; +import com.google.cloud.retail.v2beta.PredictionServiceClient; +import com.google.cloud.retail.v2beta.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + PredictResponse response = predictionServiceClient.predict(request); + } + } +} +// [END retail_v2beta_generated_predictionserviceclient_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionservicesettings/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionservicesettings/predict/SyncPredict.java new file mode 100644 index 00000000..4bcc2150 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionservicesettings/predict/SyncPredict.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionservicesettings_predict_sync] +import com.google.cloud.retail.v2beta.PredictionServiceSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceSettings predictionServiceSettings = predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_predictionservicesettings_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java new file mode 100644 index 00000000..341a6231 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addfulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlaces(); + } + + public static void asyncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addfulfillmentplaces_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java new file mode 100644 index 00000000..29ebf11a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addfulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlacesLRO(); + } + + public static void asyncAddFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + AddFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addfulfillmentplaces_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java new file mode 100644 index 00000000..7d87a8e5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addfulfillmentplaces_sync] +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlaces(); + } + + public static void syncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addfulfillmentplaces_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java new file mode 100644 index 00000000..6d2cfb0b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addfulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncAddFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesProductname(); + } + + public static void syncAddFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addfulfillmentplaces_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java new file mode 100644 index 00000000..fcf77016 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addfulfillmentplaces_string_sync] +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncAddFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesString(); + } + + public static void syncAddFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addfulfillmentplaces_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java new file mode 100644 index 00000000..6ad09148 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addlocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.LocalInventory; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventories(); + } + + public static void asyncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addlocalinventories_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java new file mode 100644 index 00000000..bd587cb6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addlocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2beta.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.LocalInventory; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventoriesLRO(); + } + + public static void asyncAddLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addLocalInventoriesOperationCallable().futureCall(request); + // Do something. + AddLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addlocalinventories_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventories.java new file mode 100644 index 00000000..e6df6c49 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addlocalinventories_sync] +import com.google.cloud.retail.v2beta.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.LocalInventory; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + syncAddLocalInventories(); + } + + public static void syncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addlocalinventories_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java new file mode 100644 index 00000000..77edad20 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addlocalinventories_productname_sync] +import com.google.cloud.retail.v2beta.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncAddLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesProductname(); + } + + public static void syncAddLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addlocalinventories_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java new file mode 100644 index 00000000..4cf735a5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addlocalinventories_string_sync] +import com.google.cloud.retail.v2beta.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncAddLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesString(); + } + + public static void syncAddLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addlocalinventories_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..9986ddc2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.ProductServiceSettings; +import com.google.cloud.retail.v2beta.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. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2beta_generated_productserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..47cc8acd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.ProductServiceSettings; + +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. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2beta_generated_productserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..a091791f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.ProductServiceSettings; +import com.google.cloud.retail.v2beta.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. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2beta_generated_productserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/AsyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/AsyncCreateProduct.java new file mode 100644 index 00000000..6316aba5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/AsyncCreateProduct.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_createproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.CreateProductRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + ApiFuture future = productServiceClient.createProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_createproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProduct.java new file mode 100644 index 00000000..0d6b1b40 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProduct.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_createproduct_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.CreateProductRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + Product response = productServiceClient.createProduct(request); + } + } +} +// [END retail_v2beta_generated_productserviceclient_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java new file mode 100644 index 00000000..53908457 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_createproduct_branchnameproductstring_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncCreateProductBranchnameProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductBranchnameProductString(); + } + + public static void syncCreateProductBranchnameProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2beta_generated_productserviceclient_createproduct_branchnameproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductStringProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductStringProductString.java new file mode 100644 index 00000000..abc7c587 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_createproduct_stringproductstring_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2beta_generated_productserviceclient_createproduct_stringproductstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/AsyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/AsyncDeleteProduct.java new file mode 100644 index 00000000..5a079e79 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/AsyncDeleteProduct.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_deleteproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.DeleteProductRequest; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.deleteProductCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_deleteproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProduct.java new file mode 100644 index 00000000..d4c19bd5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProduct.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_deleteproduct_sync] +import com.google.cloud.retail.v2beta.DeleteProductRequest; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.Empty; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + productServiceClient.deleteProduct(request); + } + } +} +// [END retail_v2beta_generated_productserviceclient_deleteproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductProductname.java new file mode 100644 index 00000000..18e28c28 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductProductname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_deleteproduct_productname_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.Empty; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2beta_generated_productserviceclient_deleteproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductString.java new file mode 100644 index 00000000..6fcef450 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_deleteproduct_string_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.Empty; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2beta_generated_productserviceclient_deleteproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/AsyncGetProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/AsyncGetProduct.java new file mode 100644 index 00000000..ced473d9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/AsyncGetProduct.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_getproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.GetProductRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.getProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_getproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProduct.java new file mode 100644 index 00000000..c777816f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProduct.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_getproduct_sync] +import com.google.cloud.retail.v2beta.GetProductRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + Product response = productServiceClient.getProduct(request); + } + } +} +// [END retail_v2beta_generated_productserviceclient_getproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductProductname.java new file mode 100644 index 00000000..f6e6d7af --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductProductname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_getproduct_productname_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2beta_generated_productserviceclient_getproduct_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductString.java new file mode 100644 index 00000000..8bc84b63 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_getproduct_string_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2beta_generated_productserviceclient_getproduct_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProducts.java new file mode 100644 index 00000000..c1705d52 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProducts.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_importproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportProductsRequest; +import com.google.cloud.retail.v2beta.ProductInputConfig; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncImportProducts { + + public static void main(String[] args) throws Exception { + asyncImportProducts(); + } + + public static void asyncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + productServiceClient.importProductsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_importproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProductsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProductsLRO.java new file mode 100644 index 00000000..a9181657 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProductsLRO.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_importproducts_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportMetadata; +import com.google.cloud.retail.v2beta.ImportProductsRequest; +import com.google.cloud.retail.v2beta.ImportProductsResponse; +import com.google.cloud.retail.v2beta.ProductInputConfig; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class AsyncImportProductsLRO { + + public static void main(String[] args) throws Exception { + asyncImportProductsLRO(); + } + + public static void asyncImportProductsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + productServiceClient.importProductsOperationCallable().futureCall(request); + // Do something. + ImportProductsResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_importproducts_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/SyncImportProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/SyncImportProducts.java new file mode 100644 index 00000000..2303e880 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/SyncImportProducts.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_importproducts_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportProductsRequest; +import com.google.cloud.retail.v2beta.ImportProductsResponse; +import com.google.cloud.retail.v2beta.ProductInputConfig; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncImportProducts { + + public static void main(String[] args) throws Exception { + syncImportProducts(); + } + + public static void syncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportProductsResponse response = productServiceClient.importProductsAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_importproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProducts.java new file mode 100644 index 00000000..584111ee --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProducts.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_listproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ListProductsRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + productServiceClient.listProductsPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_productserviceclient_listproducts_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProductsPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProductsPaged.java new file mode 100644 index 00000000..a41c9ed9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProductsPaged.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_listproducts_paged_async] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ListProductsRequest; +import com.google.cloud.retail.v2beta.ListProductsResponse; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.common.base.Strings; +import com.google.protobuf.FieldMask; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + while (true) { + ListProductsResponse response = productServiceClient.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 retail_v2beta_generated_productserviceclient_listproducts_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProducts.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProducts.java new file mode 100644 index 00000000..0eb6d991 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProducts.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_listproducts_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ListProductsRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + for (Product element : productServiceClient.listProducts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_productserviceclient_listproducts_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsBranchname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsBranchname.java new file mode 100644 index 00000000..4acc1028 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsBranchname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_listproducts_branchname_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncListProductsBranchname { + + public static void main(String[] args) throws Exception { + syncListProductsBranchname(); + } + + public static void syncListProductsBranchname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_productserviceclient_listproducts_branchname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsString.java new file mode 100644 index 00000000..64e4770b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_listproducts_string_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_productserviceclient_listproducts_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java new file mode 100644 index 00000000..acdcc3f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removefulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlaces(); + } + + public static void asyncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removefulfillmentplaces_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java new file mode 100644 index 00000000..b602d1a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removefulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlacesLRO(); + } + + public static void asyncRemoveFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + RemoveFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removefulfillmentplaces_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java new file mode 100644 index 00000000..c397f9e3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removefulfillmentplaces_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlaces(); + } + + public static void syncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removefulfillmentplaces_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java new file mode 100644 index 00000000..7fe6359d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removefulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesProductname(); + } + + public static void syncRemoveFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removefulfillmentplaces_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java new file mode 100644 index 00000000..9e986171 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removefulfillmentplaces_string_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesString(); + } + + public static void syncRemoveFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removefulfillmentplaces_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java new file mode 100644 index 00000000..85326af9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removelocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventories(); + } + + public static void asyncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removelocalinventories_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java new file mode 100644 index 00000000..96959e7b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removelocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventoriesLRO(); + } + + public static void asyncRemoveLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeLocalInventoriesOperationCallable().futureCall(request); + // Do something. + RemoveLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removelocalinventories_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java new file mode 100644 index 00000000..600bfe2c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removelocalinventories_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventories(); + } + + public static void syncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removelocalinventories_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java new file mode 100644 index 00000000..0de3e632 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removelocalinventories_productname_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesProductname(); + } + + public static void syncRemoveLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removelocalinventories_productname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java new file mode 100644 index 00000000..991c42f6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removelocalinventories_string_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesString(); + } + + public static void syncRemoveLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removelocalinventories_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventory.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventory.java new file mode 100644 index 00000000..ee08a61b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventory.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_setinventory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.SetInventoryRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventory { + + public static void main(String[] args) throws Exception { + asyncSetInventory(); + } + + public static void asyncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.setInventoryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_setinventory_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventoryLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventoryLRO.java new file mode 100644 index 00000000..a4a7210c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventoryLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_setinventory_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.SetInventoryMetadata; +import com.google.cloud.retail.v2beta.SetInventoryRequest; +import com.google.cloud.retail.v2beta.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventoryLRO { + + public static void main(String[] args) throws Exception { + asyncSetInventoryLRO(); + } + + public static void asyncSetInventoryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.setInventoryOperationCallable().futureCall(request); + // Do something. + SetInventoryResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_setinventory_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventory.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventory.java new file mode 100644 index 00000000..930717b5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventory.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_setinventory_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.SetInventoryRequest; +import com.google.cloud.retail.v2beta.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncSetInventory { + + public static void main(String[] args) throws Exception { + syncSetInventory(); + } + + public static void syncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + SetInventoryResponse response = productServiceClient.setInventoryAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_setinventory_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java new file mode 100644 index 00000000..2d6a3493 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_setinventory_productfieldmask_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.SetInventoryResponse; +import com.google.protobuf.FieldMask; + +public class SyncSetInventoryProductFieldmask { + + public static void main(String[] args) throws Exception { + syncSetInventoryProductFieldmask(); + } + + public static void syncSetInventoryProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product inventory = Product.newBuilder().build(); + FieldMask setMask = FieldMask.newBuilder().build(); + SetInventoryResponse response = + productServiceClient.setInventoryAsync(inventory, setMask).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_setinventory_productfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/AsyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/AsyncUpdateProduct.java new file mode 100644 index 00000000..4ca112ed --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/AsyncUpdateProduct.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_updateproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.updateProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_updateproduct_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProduct.java new file mode 100644 index 00000000..d4ee6292 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProduct.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_updateproduct_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + Product response = productServiceClient.updateProduct(request); + } + } +} +// [END retail_v2beta_generated_productserviceclient_updateproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java new file mode 100644 index 00000000..ea64bfa3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_updateproduct_productfieldmask_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +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 (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product product = Product.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Product response = productServiceClient.updateProduct(product, updateMask); + } + } +} +// [END retail_v2beta_generated_productserviceclient_updateproduct_productfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/productservicesettings/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/productservicesettings/createproduct/SyncCreateProduct.java new file mode 100644 index 00000000..76eb39a0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/productservicesettings/createproduct/SyncCreateProduct.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_productservicesettings_createproduct_sync] +import com.google.cloud.retail.v2beta.ProductServiceSettings; +import java.time.Duration; + +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. + ProductServiceSettings.Builder productServiceSettingsBuilder = + ProductServiceSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_productservicesettings_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..d2d0cd06 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.SearchServiceSettings; +import com.google.cloud.retail.v2beta.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. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2beta_generated_searchserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..3dceef44 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.SearchServiceSettings; + +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. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2beta_generated_searchserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..ec26b519 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/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.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.SearchServiceSettings; +import com.google.cloud.retail.v2beta.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. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2beta_generated_searchserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearch.java new file mode 100644 index 00000000..8e9c16ec --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearch.java @@ -0,0 +1,69 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_search_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.SearchRequest; +import com.google.cloud.retail.v2beta.SearchResponse; +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.UserInfo; +import java.util.ArrayList; + +public class AsyncSearch { + + public static void main(String[] args) throws Exception { + asyncSearch(); + } + + public static void asyncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + ApiFuture future = + searchServiceClient.searchPagedCallable().futureCall(request); + // Do something. + for (SearchResponse.SearchResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_searchserviceclient_search_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearchPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearchPaged.java new file mode 100644 index 00000000..48cdb363 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearchPaged.java @@ -0,0 +1,75 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_search_paged_async] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.SearchRequest; +import com.google.cloud.retail.v2beta.SearchResponse; +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.UserInfo; +import com.google.common.base.Strings; +import java.util.ArrayList; + +public class AsyncSearchPaged { + + public static void main(String[] args) throws Exception { + asyncSearchPaged(); + } + + public static void asyncSearchPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + while (true) { + SearchResponse response = searchServiceClient.searchCallable().call(request); + for (SearchResponse.SearchResult element : response.getResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2beta_generated_searchserviceclient_search_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/SyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/SyncSearch.java new file mode 100644 index 00000000..f2fc2b9d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/SyncSearch.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_search_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.SearchRequest; +import com.google.cloud.retail.v2beta.SearchResponse; +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.UserInfo; +import java.util.ArrayList; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + for (SearchResponse.SearchResult element : searchServiceClient.search(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_searchserviceclient_search_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/searchservicesettings/search/SyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchservicesettings/search/SyncSearch.java new file mode 100644 index 00000000..53b373a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/searchservicesettings/search/SyncSearch.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchservicesettings_search_sync] +import com.google.cloud.retail.v2beta.SearchServiceSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings.Builder searchServiceSettingsBuilder = SearchServiceSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_searchservicesettings_search_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/AsyncAddControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/AsyncAddControl.java new file mode 100644 index 00000000..65c97669 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/AsyncAddControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_addcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AddControlRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class AsyncAddControl { + + public static void main(String[] args) throws Exception { + asyncAddControl(); + } + + public static void asyncAddControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + AddControlRequest request = + AddControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = + servingConfigServiceClient.addControlCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_addcontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControl.java new file mode 100644 index 00000000..fa39829f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_addcontrol_sync] +import com.google.cloud.retail.v2beta.AddControlRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncAddControl { + + public static void main(String[] args) throws Exception { + syncAddControl(); + } + + public static void syncAddControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + AddControlRequest request = + AddControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ServingConfig response = servingConfigServiceClient.addControl(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_addcontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java new file mode 100644 index 00000000..05e947e1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_addcontrol_servingconfigname_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncAddControlServingconfigname { + + public static void main(String[] args) throws Exception { + syncAddControlServingconfigname(); + } + + public static void syncAddControlServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.addControl(servingConfig); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_addcontrol_servingconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlString.java new file mode 100644 index 00000000..9b3f6373 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_addcontrol_string_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncAddControlString { + + public static void main(String[] args) throws Exception { + syncAddControlString(); + } + + public static void syncAddControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.addControl(servingConfig); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_addcontrol_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..a725d416 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.cloud.retail.v2beta.ServingConfigServiceSettings; +import com.google.cloud.retail.v2beta.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. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..6bb86f6d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.cloud.retail.v2beta.ServingConfigServiceSettings; + +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. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder() + .setTransportChannelProvider( + ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..1935777a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetEndpoint.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.cloud.retail.v2beta.ServingConfigServiceSettings; +import com.google.cloud.retail.v2beta.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. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java new file mode 100644 index 00000000..9d26ccaf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_createservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CreateServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class AsyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + asyncCreateServingConfig(); + } + + public static void asyncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CreateServingConfigRequest request = + CreateServingConfigRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setServingConfig(ServingConfig.newBuilder().build()) + .setServingConfigId("servingConfigId-831052759") + .build(); + ApiFuture future = + servingConfigServiceClient.createServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_createservingconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 00000000..409103d8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_createservingconfig_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CreateServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CreateServingConfigRequest request = + CreateServingConfigRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setServingConfig(ServingConfig.newBuilder().build()) + .setServingConfigId("servingConfigId-831052759") + .build(); + ServingConfig response = servingConfigServiceClient.createServingConfig(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_createservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java new file mode 100644 index 00000000..7f4e7a1c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_createservingconfig_catalognameservingconfigstring_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncCreateServingConfigCatalognameServingconfigString { + + public static void main(String[] args) throws Exception { + syncCreateServingConfigCatalognameServingconfigString(); + } + + public static void syncCreateServingConfigCatalognameServingconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + ServingConfig response = + servingConfigServiceClient.createServingConfig(parent, servingConfig, servingConfigId); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_createservingconfig_catalognameservingconfigstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java new file mode 100644 index 00000000..17432dab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_createservingconfig_stringservingconfigstring_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncCreateServingConfigStringServingconfigString { + + public static void main(String[] args) throws Exception { + syncCreateServingConfigStringServingconfigString(); + } + + public static void syncCreateServingConfigStringServingconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + ServingConfig response = + servingConfigServiceClient.createServingConfig(parent, servingConfig, servingConfigId); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_createservingconfig_stringservingconfigstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java new file mode 100644 index 00000000..b1a8431d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.DeleteServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteServingConfig { + + public static void main(String[] args) throws Exception { + asyncDeleteServingConfig(); + } + + public static void asyncDeleteServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + DeleteServingConfigRequest request = + DeleteServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ApiFuture future = + servingConfigServiceClient.deleteServingConfigCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java new file mode 100644 index 00000000..0151b52c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_sync] +import com.google.cloud.retail.v2beta.DeleteServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfig { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfig(); + } + + public static void syncDeleteServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + DeleteServingConfigRequest request = + DeleteServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + servingConfigServiceClient.deleteServingConfig(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java new file mode 100644 index 00000000..4a869a90 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_servingconfigname_sync] +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfigServingconfigname { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfigServingconfigname(); + } + + public static void syncDeleteServingConfigServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + servingConfigServiceClient.deleteServingConfig(name); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_servingconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java new file mode 100644 index 00000000..9436e146 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_string_sync] +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfigString { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfigString(); + } + + public static void syncDeleteServingConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + servingConfigServiceClient.deleteServingConfig(name); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java new file mode 100644 index 00000000..d7f4718b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_getservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.GetServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class AsyncGetServingConfig { + + public static void main(String[] args) throws Exception { + asyncGetServingConfig(); + } + + public static void asyncGetServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + GetServingConfigRequest request = + GetServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ApiFuture future = + servingConfigServiceClient.getServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_getservingconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java new file mode 100644 index 00000000..1c7dee2c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_getservingconfig_sync] +import com.google.cloud.retail.v2beta.GetServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncGetServingConfig { + + public static void main(String[] args) throws Exception { + syncGetServingConfig(); + } + + public static void syncGetServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + GetServingConfigRequest request = + GetServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ServingConfig response = servingConfigServiceClient.getServingConfig(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_getservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java new file mode 100644 index 00000000..063db107 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_getservingconfig_servingconfigname_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncGetServingConfigServingconfigname { + + public static void main(String[] args) throws Exception { + syncGetServingConfigServingconfigname(); + } + + public static void syncGetServingConfigServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.getServingConfig(name); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_getservingconfig_servingconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java new file mode 100644 index 00000000..68393336 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_getservingconfig_string_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncGetServingConfigString { + + public static void main(String[] args) throws Exception { + syncGetServingConfigString(); + } + + public static void syncGetServingConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.getServingConfig(name); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_getservingconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java new file mode 100644 index 00000000..9eda4ea4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ListServingConfigsRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class AsyncListServingConfigs { + + public static void main(String[] args) throws Exception { + asyncListServingConfigs(); + } + + public static void asyncListServingConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + servingConfigServiceClient.listServingConfigsPagedCallable().futureCall(request); + // Do something. + for (ServingConfig element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java new file mode 100644 index 00000000..6d71bde6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_paged_async] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ListServingConfigsRequest; +import com.google.cloud.retail.v2beta.ListServingConfigsResponse; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.common.base.Strings; + +public class AsyncListServingConfigsPaged { + + public static void main(String[] args) throws Exception { + asyncListServingConfigsPaged(); + } + + public static void asyncListServingConfigsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListServingConfigsResponse response = + servingConfigServiceClient.listServingConfigsCallable().call(request); + for (ServingConfig element : response.getServingConfigsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java new file mode 100644 index 00000000..6ceca20a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ListServingConfigsRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncListServingConfigs { + + public static void main(String[] args) throws Exception { + syncListServingConfigs(); + } + + public static void syncListServingConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java new file mode 100644 index 00000000..7f3ffaac --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_catalogname_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncListServingConfigsCatalogname { + + public static void main(String[] args) throws Exception { + syncListServingConfigsCatalogname(); + } + + public static void syncListServingConfigsCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_catalogname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java new file mode 100644 index 00000000..761d0164 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_string_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncListServingConfigsString { + + public static void main(String[] args) throws Exception { + syncListServingConfigsString(); + } + + public static void syncListServingConfigsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java new file mode 100644 index 00000000..c919c671 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/AsyncRemoveControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_removecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.RemoveControlRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class AsyncRemoveControl { + + public static void main(String[] args) throws Exception { + asyncRemoveControl(); + } + + public static void asyncRemoveControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + RemoveControlRequest request = + RemoveControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = + servingConfigServiceClient.removeControlCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_removecontrol_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControl.java new file mode 100644 index 00000000..590eb215 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControl.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_removecontrol_sync] +import com.google.cloud.retail.v2beta.RemoveControlRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncRemoveControl { + + public static void main(String[] args) throws Exception { + syncRemoveControl(); + } + + public static void syncRemoveControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + RemoveControlRequest request = + RemoveControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ServingConfig response = servingConfigServiceClient.removeControl(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_removecontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java new file mode 100644 index 00000000..03424a2f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_removecontrol_servingconfigname_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncRemoveControlServingconfigname { + + public static void main(String[] args) throws Exception { + syncRemoveControlServingconfigname(); + } + + public static void syncRemoveControlServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.removeControl(servingConfig); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_removecontrol_servingconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java new file mode 100644 index 00000000..44367cc2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlString.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_removecontrol_string_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncRemoveControlString { + + public static void main(String[] args) throws Exception { + syncRemoveControlString(); + } + + public static void syncRemoveControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.removeControl(servingConfig); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_removecontrol_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java new file mode 100644 index 00000000..216df01b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.cloud.retail.v2beta.UpdateServingConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateServingConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateServingConfig(); + } + + public static void asyncUpdateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + UpdateServingConfigRequest request = + UpdateServingConfigRequest.newBuilder() + .setServingConfig(ServingConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + servingConfigServiceClient.updateServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java new file mode 100644 index 00000000..b7f65306 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.cloud.retail.v2beta.UpdateServingConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateServingConfig { + + public static void main(String[] args) throws Exception { + syncUpdateServingConfig(); + } + + public static void syncUpdateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + UpdateServingConfigRequest request = + UpdateServingConfigRequest.newBuilder() + .setServingConfig(ServingConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ServingConfig response = servingConfigServiceClient.updateServingConfig(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java new file mode 100644 index 00000000..f0f24d82 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_servingconfigfieldmask_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateServingConfigServingconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateServingConfigServingconfigFieldmask(); + } + + public static void syncUpdateServingConfigServingconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ServingConfig response = + servingConfigServiceClient.updateServingConfig(servingConfig, updateMask); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_servingconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 00000000..05930f6a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigservicesettings_createservingconfig_sync] +import com.google.cloud.retail.v2beta.ServingConfigServiceSettings; +import java.time.Duration; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceSettings.Builder servingConfigServiceSettingsBuilder = + ServingConfigServiceSettings.newBuilder(); + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .setRetrySettings( + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ServingConfigServiceSettings servingConfigServiceSettings = + servingConfigServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_servingconfigservicesettings_createservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 00000000..461df87b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.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.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_catalogservicestubsettings_updatecatalog_sync] +import com.google.cloud.retail.v2beta.stub.CatalogServiceStubSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceStubSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceStubSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceStubSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_catalogservicestubsettings_updatecatalog_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java new file mode 100644 index 00000000..6916d8a2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/completionservicestubsettings/completequery/SyncCompleteQuery.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.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_completionservicestubsettings_completequery_sync] +import com.google.cloud.retail.v2beta.stub.CompletionServiceStubSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceStubSettings.Builder completionServiceSettingsBuilder = + CompletionServiceStubSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceStubSettings completionServiceSettings = + completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_completionservicestubsettings_completequery_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java new file mode 100644 index 00000000..d43bb3e1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/controlservicestubsettings/createcontrol/SyncCreateControl.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.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_controlservicestubsettings_createcontrol_sync] +import com.google.cloud.retail.v2beta.stub.ControlServiceStubSettings; +import java.time.Duration; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceStubSettings.Builder controlServiceSettingsBuilder = + ControlServiceStubSettings.newBuilder(); + controlServiceSettingsBuilder + .createControlSettings() + .setRetrySettings( + controlServiceSettingsBuilder + .createControlSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ControlServiceStubSettings controlServiceSettings = controlServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_controlservicestubsettings_createcontrol_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/predictionservicestubsettings/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/predictionservicestubsettings/predict/SyncPredict.java new file mode 100644 index 00000000..b60cbc9a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/predictionservicestubsettings/predict/SyncPredict.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.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_predictionservicestubsettings_predict_sync] +import com.google.cloud.retail.v2beta.stub.PredictionServiceStubSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceStubSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceStubSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceStubSettings predictionServiceSettings = + predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_predictionservicestubsettings_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/productservicestubsettings/createproduct/SyncCreateProduct.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/productservicestubsettings/createproduct/SyncCreateProduct.java new file mode 100644 index 00000000..0db7c0f8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/productservicestubsettings/createproduct/SyncCreateProduct.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.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_productservicestubsettings_createproduct_sync] +import com.google.cloud.retail.v2beta.stub.ProductServiceStubSettings; +import java.time.Duration; + +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. + ProductServiceStubSettings.Builder productServiceSettingsBuilder = + ProductServiceStubSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceStubSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_productservicestubsettings_createproduct_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/searchservicestubsettings/search/SyncSearch.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/searchservicestubsettings/search/SyncSearch.java new file mode 100644 index 00000000..4ed39109 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/searchservicestubsettings/search/SyncSearch.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.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_searchservicestubsettings_search_sync] +import com.google.cloud.retail.v2beta.stub.SearchServiceStubSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceStubSettings.Builder searchServiceSettingsBuilder = + SearchServiceStubSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceStubSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_searchservicestubsettings_search_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 00000000..3caaf3b0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.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.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_servingconfigservicestubsettings_createservingconfig_sync] +import com.google.cloud.retail.v2beta.stub.ServingConfigServiceStubSettings; +import java.time.Duration; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceStubSettings.Builder servingConfigServiceSettingsBuilder = + ServingConfigServiceStubSettings.newBuilder(); + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .setRetrySettings( + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ServingConfigServiceStubSettings servingConfigServiceSettings = + servingConfigServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_servingconfigservicestubsettings_createservingconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 00000000..92180686 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.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.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_usereventservicestubsettings_writeuserevent_sync] +import com.google.cloud.retail.v2beta.stub.UserEventServiceStubSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceStubSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceStubSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceStubSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_usereventservicestubsettings_writeuserevent_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java new file mode 100644 index 00000000..0992bf52 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_collectuserevent_async] +import com.google.api.HttpBody; +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CollectUserEventRequest; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class AsyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + asyncCollectUserEvent(); + } + + public static void asyncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + ApiFuture future = + userEventServiceClient.collectUserEventCallable().futureCall(request); + // Do something. + HttpBody response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_collectuserevent_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java new file mode 100644 index 00000000..893ec1ee --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/SyncCollectUserEvent.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_collectuserevent_sync] +import com.google.api.HttpBody; +import com.google.cloud.retail.v2beta.CollectUserEventRequest; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class SyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + syncCollectUserEvent(); + } + + public static void syncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + HttpBody response = userEventServiceClient.collectUserEvent(request); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_collectuserevent_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..18bc722d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.cloud.retail.v2beta.UserEventServiceSettings; +import com.google.cloud.retail.v2beta.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. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2beta_generated_usereventserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..98632693 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.cloud.retail.v2beta.UserEventServiceSettings; + +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. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2beta_generated_usereventserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..f362a958 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetEndpoint.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.cloud.retail.v2beta.UserEventServiceSettings; +import com.google.cloud.retail.v2beta.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. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2beta_generated_usereventserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEvents.java new file mode 100644 index 00000000..441e4b8c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEvents.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_importuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportUserEventsRequest; +import com.google.cloud.retail.v2beta.UserEventInputConfig; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncImportUserEvents { + + public static void main(String[] args) throws Exception { + asyncImportUserEvents(); + } + + public static void asyncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.importUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_importuserevents_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java new file mode 100644 index 00000000..8b9a8a8a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_importuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportMetadata; +import com.google.cloud.retail.v2beta.ImportUserEventsRequest; +import com.google.cloud.retail.v2beta.ImportUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventInputConfig; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class AsyncImportUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncImportUserEventsLRO(); + } + + public static void asyncImportUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + OperationFuture future = + userEventServiceClient.importUserEventsOperationCallable().futureCall(request); + // Do something. + ImportUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_importuserevents_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/SyncImportUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/SyncImportUserEvents.java new file mode 100644 index 00000000..694c4f5b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/SyncImportUserEvents.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_importuserevents_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportUserEventsRequest; +import com.google.cloud.retail.v2beta.ImportUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventInputConfig; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class SyncImportUserEvents { + + public static void main(String[] args) throws Exception { + syncImportUserEvents(); + } + + public static void syncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ImportUserEventsResponse response = + userEventServiceClient.importUserEventsAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_importuserevents_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java new file mode 100644 index 00000000..2993e355 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_purgeuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.PurgeUserEventsRequest; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEvents(); + } + + public static void asyncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + ApiFuture future = + userEventServiceClient.purgeUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_purgeuserevents_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java new file mode 100644 index 00000000..0c3327b1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_purgeuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.PurgeMetadata; +import com.google.cloud.retail.v2beta.PurgeUserEventsRequest; +import com.google.cloud.retail.v2beta.PurgeUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class AsyncPurgeUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEventsLRO(); + } + + public static void asyncPurgeUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + OperationFuture future = + userEventServiceClient.purgeUserEventsOperationCallable().futureCall(request); + // Do something. + PurgeUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_purgeuserevents_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java new file mode 100644 index 00000000..a0beff68 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_purgeuserevents_sync] +import com.google.cloud.retail.v2beta.PurgeUserEventsRequest; +import com.google.cloud.retail.v2beta.PurgeUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class SyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + syncPurgeUserEvents(); + } + + public static void syncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + PurgeUserEventsResponse response = userEventServiceClient.purgeUserEventsAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_purgeuserevents_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java new file mode 100644 index 00000000..0402ab4a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_rejoinuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.RejoinUserEventsRequest; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEvents(); + } + + public static void asyncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + ApiFuture future = + userEventServiceClient.rejoinUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_rejoinuserevents_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java new file mode 100644 index 00000000..fc843fc4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_rejoinuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2beta.RejoinUserEventsRequest; +import com.google.cloud.retail.v2beta.RejoinUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class AsyncRejoinUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEventsLRO(); + } + + public static void asyncRejoinUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + OperationFuture future = + userEventServiceClient.rejoinUserEventsOperationCallable().futureCall(request); + // Do something. + RejoinUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_rejoinuserevents_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java new file mode 100644 index 00000000..6787f7bc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_rejoinuserevents_sync] +import com.google.cloud.retail.v2beta.RejoinUserEventsRequest; +import com.google.cloud.retail.v2beta.RejoinUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class SyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + syncRejoinUserEvents(); + } + + public static void syncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + RejoinUserEventsResponse response = + userEventServiceClient.rejoinUserEventsAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_rejoinuserevents_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java new file mode 100644 index 00000000..b4a1587a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_writeuserevent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.UserEvent; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.cloud.retail.v2beta.WriteUserEventRequest; + +public class AsyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + asyncWriteUserEvent(); + } + + public static void asyncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.writeUserEventCallable().futureCall(request); + // Do something. + UserEvent response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_writeuserevent_async] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 00000000..789e7683 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/SyncWriteUserEvent.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_writeuserevent_sync] +import com.google.cloud.retail.v2beta.UserEvent; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.cloud.retail.v2beta.WriteUserEventRequest; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + UserEvent response = userEventServiceClient.writeUserEvent(request); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_writeuserevent_sync] diff --git a/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 00000000..a7c7a624 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventservicesettings/writeuserevent/SyncWriteUserEvent.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.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventservicesettings_writeuserevent_sync] +import com.google.cloud.retail.v2beta.UserEventServiceSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_usereventservicesettings_writeuserevent_sync]