diff --git a/java-recommender/README.md b/java-recommender/README.md index 89230140a225..ac2d07fb1c8c 100644 --- a/java-recommender/README.md +++ b/java-recommender/README.md @@ -56,13 +56,13 @@ implementation 'com.google.cloud:google-cloud-recommender' If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-recommender:2.4.0' +implementation 'com.google.cloud:google-cloud-recommender:2.4.1' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-recommender" % "2.4.0" +libraryDependencies += "com.google.cloud" % "google-cloud-recommender" % "2.4.1" ``` ## Authentication diff --git a/java-recommender/google-cloud-recommender/pom.xml b/java-recommender/google-cloud-recommender/pom.xml index ab75acd107e0..fbceb39a4d23 100644 --- a/java-recommender/google-cloud-recommender/pom.xml +++ b/java-recommender/google-cloud-recommender/pom.xml @@ -69,6 +69,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -96,12 +100,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + com.google.truth truth diff --git a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/RecommenderClient.java b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/RecommenderClient.java index 99e386361e17..6f856a590656 100644 --- a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/RecommenderClient.java +++ b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/RecommenderClient.java @@ -102,6 +102,20 @@ * RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings); * } * + *

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.
+ * RecommenderSettings recommenderSettings =
+ *     RecommenderSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             RecommenderSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/RecommenderSettings.java b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/RecommenderSettings.java index f4b1c129017c..bd6498392b97 100644 --- a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/RecommenderSettings.java +++ b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/RecommenderSettings.java @@ -24,6 +24,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 RecommenderStubSettings.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 RecommenderStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return RecommenderStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return RecommenderStubSettings.defaultTransportChannelProvider(); } @@ -155,11 +163,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return RecommenderStubSettings.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(RecommenderStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(RecommenderStubSettings.newHttpJsonBuilder()); + } + public RecommenderStubSettings.Builder getStubSettingsBuilder() { return ((RecommenderStubSettings.Builder) getStubSettings()); } diff --git a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/stub/HttpJsonRecommenderCallableFactory.java b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/stub/HttpJsonRecommenderCallableFactory.java new file mode 100644 index 000000000000..9864cff5d4db --- /dev/null +++ b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/stub/HttpJsonRecommenderCallableFactory.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.recommender.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Recommender service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonRecommenderCallableFactory + 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/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/stub/HttpJsonRecommenderStub.java b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/stub/HttpJsonRecommenderStub.java new file mode 100644 index 000000000000..af1be0d12651 --- /dev/null +++ b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/stub/HttpJsonRecommenderStub.java @@ -0,0 +1,640 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.recommender.v1.stub; + +import static com.google.cloud.recommender.v1.RecommenderClient.ListInsightsPagedResponse; +import static com.google.cloud.recommender.v1.RecommenderClient.ListRecommendationsPagedResponse; + +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.recommender.v1.GetInsightRequest; +import com.google.cloud.recommender.v1.GetRecommendationRequest; +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.ListInsightsRequest; +import com.google.cloud.recommender.v1.ListInsightsResponse; +import com.google.cloud.recommender.v1.ListRecommendationsRequest; +import com.google.cloud.recommender.v1.ListRecommendationsResponse; +import com.google.cloud.recommender.v1.MarkInsightAcceptedRequest; +import com.google.cloud.recommender.v1.MarkRecommendationClaimedRequest; +import com.google.cloud.recommender.v1.MarkRecommendationFailedRequest; +import com.google.cloud.recommender.v1.MarkRecommendationSucceededRequest; +import com.google.cloud.recommender.v1.Recommendation; +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 Recommender service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonRecommenderStub extends RecommenderStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listInsightsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.recommender.v1.Recommender/ListInsights") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/insightTypes/*}/insights", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=billingAccounts/*/locations/*/insightTypes/*}/insights", + "/v1/{parent=folders/*/locations/*/insightTypes/*}/insights", + "/v1/{parent=organizations/*/locations/*/insightTypes/*}/insights") + .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(ListInsightsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getInsightMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.recommender.v1.Recommender/GetInsight") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/insightTypes/*/insights/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}", + "/v1/{name=folders/*/locations/*/insightTypes/*/insights/*}", + "/v1/{name=organizations/*/locations/*/insightTypes/*/insights/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Insight.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + markInsightAcceptedMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.recommender.v1.Recommender/MarkInsightAccepted") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/insightTypes/*/insights/*}:markAccepted", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}:markAccepted", + "/v1/{name=folders/*/locations/*/insightTypes/*/insights/*}:markAccepted", + "/v1/{name=organizations/*/locations/*/insightTypes/*/insights/*}:markAccepted") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Insight.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listRecommendationsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.recommender.v1.Recommender/ListRecommendations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/recommenders/*}/recommendations", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=billingAccounts/*/locations/*/recommenders/*}/recommendations", + "/v1/{parent=folders/*/locations/*/recommenders/*}/recommendations", + "/v1/{parent=organizations/*/locations/*/recommenders/*}/recommendations") + .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(ListRecommendationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getRecommendationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.recommender.v1.Recommender/GetRecommendation") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}", + "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}", + "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Recommendation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + markRecommendationClaimedMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.recommender.v1.Recommender/MarkRecommendationClaimed") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markClaimed", + "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markClaimed", + "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markClaimed") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Recommendation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + markRecommendationSucceededMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.recommender.v1.Recommender/MarkRecommendationSucceeded") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markSucceeded", + "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markSucceeded", + "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markSucceeded") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Recommendation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + markRecommendationFailedMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.recommender.v1.Recommender/MarkRecommendationFailed") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markFailed", + "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markFailed", + "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markFailed") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Recommendation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listInsightsCallable; + private final UnaryCallable + listInsightsPagedCallable; + private final UnaryCallable getInsightCallable; + private final UnaryCallable markInsightAcceptedCallable; + private final UnaryCallable + listRecommendationsCallable; + private final UnaryCallable + listRecommendationsPagedCallable; + private final UnaryCallable getRecommendationCallable; + private final UnaryCallable + markRecommendationClaimedCallable; + private final UnaryCallable + markRecommendationSucceededCallable; + private final UnaryCallable + markRecommendationFailedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonRecommenderStub create(RecommenderStubSettings settings) + throws IOException { + return new HttpJsonRecommenderStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonRecommenderStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonRecommenderStub( + RecommenderStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonRecommenderStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonRecommenderStub( + RecommenderStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonRecommenderStub, 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 HttpJsonRecommenderStub(RecommenderStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonRecommenderCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonRecommenderStub, 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 HttpJsonRecommenderStub( + RecommenderStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listInsightsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInsightsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInsightTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInsightMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings markInsightAcceptedTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(markInsightAcceptedMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listRecommendationsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listRecommendationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getRecommendationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getRecommendationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + markRecommendationClaimedTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(markRecommendationClaimedMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + markRecommendationSucceededTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(markRecommendationSucceededMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + markRecommendationFailedTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(markRecommendationFailedMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listInsightsCallable = + callableFactory.createUnaryCallable( + listInsightsTransportSettings, settings.listInsightsSettings(), clientContext); + this.listInsightsPagedCallable = + callableFactory.createPagedCallable( + listInsightsTransportSettings, settings.listInsightsSettings(), clientContext); + this.getInsightCallable = + callableFactory.createUnaryCallable( + getInsightTransportSettings, settings.getInsightSettings(), clientContext); + this.markInsightAcceptedCallable = + callableFactory.createUnaryCallable( + markInsightAcceptedTransportSettings, + settings.markInsightAcceptedSettings(), + clientContext); + this.listRecommendationsCallable = + callableFactory.createUnaryCallable( + listRecommendationsTransportSettings, + settings.listRecommendationsSettings(), + clientContext); + this.listRecommendationsPagedCallable = + callableFactory.createPagedCallable( + listRecommendationsTransportSettings, + settings.listRecommendationsSettings(), + clientContext); + this.getRecommendationCallable = + callableFactory.createUnaryCallable( + getRecommendationTransportSettings, + settings.getRecommendationSettings(), + clientContext); + this.markRecommendationClaimedCallable = + callableFactory.createUnaryCallable( + markRecommendationClaimedTransportSettings, + settings.markRecommendationClaimedSettings(), + clientContext); + this.markRecommendationSucceededCallable = + callableFactory.createUnaryCallable( + markRecommendationSucceededTransportSettings, + settings.markRecommendationSucceededSettings(), + clientContext); + this.markRecommendationFailedCallable = + callableFactory.createUnaryCallable( + markRecommendationFailedTransportSettings, + settings.markRecommendationFailedSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listInsightsMethodDescriptor); + methodDescriptors.add(getInsightMethodDescriptor); + methodDescriptors.add(markInsightAcceptedMethodDescriptor); + methodDescriptors.add(listRecommendationsMethodDescriptor); + methodDescriptors.add(getRecommendationMethodDescriptor); + methodDescriptors.add(markRecommendationClaimedMethodDescriptor); + methodDescriptors.add(markRecommendationSucceededMethodDescriptor); + methodDescriptors.add(markRecommendationFailedMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listInsightsCallable() { + return listInsightsCallable; + } + + @Override + public UnaryCallable listInsightsPagedCallable() { + return listInsightsPagedCallable; + } + + @Override + public UnaryCallable getInsightCallable() { + return getInsightCallable; + } + + @Override + public UnaryCallable markInsightAcceptedCallable() { + return markInsightAcceptedCallable; + } + + @Override + public UnaryCallable + listRecommendationsCallable() { + return listRecommendationsCallable; + } + + @Override + public UnaryCallable + listRecommendationsPagedCallable() { + return listRecommendationsPagedCallable; + } + + @Override + public UnaryCallable getRecommendationCallable() { + return getRecommendationCallable; + } + + @Override + public UnaryCallable + markRecommendationClaimedCallable() { + return markRecommendationClaimedCallable; + } + + @Override + public UnaryCallable + markRecommendationSucceededCallable() { + return markRecommendationSucceededCallable; + } + + @Override + public UnaryCallable + markRecommendationFailedCallable() { + return markRecommendationFailedCallable; + } + + @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/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/stub/RecommenderStubSettings.java b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/stub/RecommenderStubSettings.java index b0e5cbcf9ae3..18f0aebc86fa 100644 --- a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/stub/RecommenderStubSettings.java +++ b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/stub/RecommenderStubSettings.java @@ -28,6 +28,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; @@ -285,6 +288,11 @@ public RecommenderStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcRecommenderStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonRecommenderStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -317,18 +325,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(RecommenderStubSettings.class)) @@ -336,11 +351,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(RecommenderStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return RecommenderStubSettings.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); @@ -498,6 +532,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 .listInsightsSettings() diff --git a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/RecommenderClient.java b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/RecommenderClient.java index 6df85bcf73b7..a751d6f7e0c1 100644 --- a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/RecommenderClient.java +++ b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/RecommenderClient.java @@ -104,6 +104,20 @@ * RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings); * } * + *

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.
+ * RecommenderSettings recommenderSettings =
+ *     RecommenderSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             RecommenderSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/RecommenderSettings.java b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/RecommenderSettings.java index 9c40b4c82ba2..e36c5e346231 100644 --- a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/RecommenderSettings.java +++ b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/RecommenderSettings.java @@ -24,6 +24,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; @@ -166,11 +167,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return RecommenderStubSettings.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 RecommenderStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return RecommenderStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return RecommenderStubSettings.defaultTransportChannelProvider(); } @@ -180,11 +188,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return RecommenderStubSettings.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); @@ -222,6 +236,11 @@ private static Builder createDefault() { return new Builder(RecommenderStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(RecommenderStubSettings.newHttpJsonBuilder()); + } + public RecommenderStubSettings.Builder getStubSettingsBuilder() { return ((RecommenderStubSettings.Builder) getStubSettings()); } diff --git a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/stub/HttpJsonRecommenderCallableFactory.java b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/stub/HttpJsonRecommenderCallableFactory.java new file mode 100644 index 000000000000..74d77decb317 --- /dev/null +++ b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/stub/HttpJsonRecommenderCallableFactory.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.recommender.v1beta1.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 Recommender service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonRecommenderCallableFactory + 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/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/stub/HttpJsonRecommenderStub.java b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/stub/HttpJsonRecommenderStub.java new file mode 100644 index 000000000000..c85cc4f72d8e --- /dev/null +++ b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/stub/HttpJsonRecommenderStub.java @@ -0,0 +1,889 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.recommender.v1beta1.stub; + +import static com.google.cloud.recommender.v1beta1.RecommenderClient.ListInsightsPagedResponse; +import static com.google.cloud.recommender.v1beta1.RecommenderClient.ListRecommendationsPagedResponse; + +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.recommender.v1beta1.GetInsightRequest; +import com.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest; +import com.google.cloud.recommender.v1beta1.GetRecommendationRequest; +import com.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest; +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightTypeConfig; +import com.google.cloud.recommender.v1beta1.ListInsightsRequest; +import com.google.cloud.recommender.v1beta1.ListInsightsResponse; +import com.google.cloud.recommender.v1beta1.ListRecommendationsRequest; +import com.google.cloud.recommender.v1beta1.ListRecommendationsResponse; +import com.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest; +import com.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest; +import com.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest; +import com.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommenderConfig; +import com.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest; +import com.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest; +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 Recommender service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonRecommenderStub extends RecommenderStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listInsightsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/ListInsights") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/insightTypes/*}/insights", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{parent=billingAccounts/*/locations/*/insightTypes/*}/insights", + "/v1beta1/{parent=folders/*/locations/*/insightTypes/*}/insights", + "/v1beta1/{parent=organizations/*/locations/*/insightTypes/*}/insights") + .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(ListInsightsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getInsightMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/GetInsight") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/insightTypes/*/insights/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}", + "/v1beta1/{name=folders/*/locations/*/insightTypes/*/insights/*}", + "/v1beta1/{name=organizations/*/locations/*/insightTypes/*/insights/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Insight.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + markInsightAcceptedMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/MarkInsightAccepted") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/insightTypes/*/insights/*}:markAccepted", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}:markAccepted", + "/v1beta1/{name=folders/*/locations/*/insightTypes/*/insights/*}:markAccepted", + "/v1beta1/{name=organizations/*/locations/*/insightTypes/*/insights/*}:markAccepted") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Insight.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listRecommendationsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/ListRecommendations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/recommenders/*}/recommendations", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{parent=billingAccounts/*/locations/*/recommenders/*}/recommendations", + "/v1beta1/{parent=folders/*/locations/*/recommenders/*}/recommendations", + "/v1beta1/{parent=organizations/*/locations/*/recommenders/*}/recommendations") + .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(ListRecommendationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getRecommendationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/GetRecommendation") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}", + "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}", + "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Recommendation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + markRecommendationClaimedMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.recommender.v1beta1.Recommender/MarkRecommendationClaimed") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markClaimed", + "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markClaimed", + "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markClaimed") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Recommendation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + markRecommendationSucceededMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.recommender.v1beta1.Recommender/MarkRecommendationSucceeded") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markSucceeded", + "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markSucceeded", + "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markSucceeded") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Recommendation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + markRecommendationFailedMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.recommender.v1beta1.Recommender/MarkRecommendationFailed") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markFailed", + "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markFailed", + "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markFailed") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Recommendation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getRecommenderConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.recommender.v1beta1.Recommender/GetRecommenderConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/recommenders/*/config}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{name=organizations/*/locations/*/recommenders/*/config}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(RecommenderConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateRecommenderConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.recommender.v1beta1.Recommender/UpdateRecommenderConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{recommenderConfig.name=projects/*/locations/*/recommenders/*/config}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "recommenderConfig.name", + request.getRecommenderConfig().getName()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{recommenderConfig.name=organizations/*/locations/*/recommenders/*/config}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("recommenderConfig", request.getRecommenderConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(RecommenderConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInsightTypeConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.recommender.v1beta1.Recommender/GetInsightTypeConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/insightTypes/*/config}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{name=organizations/*/locations/*/insightTypes/*/config}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(InsightTypeConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateInsightTypeConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.recommender.v1beta1.Recommender/UpdateInsightTypeConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{insightTypeConfig.name=projects/*/locations/*/insightTypes/*/config}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "insightTypeConfig.name", + request.getInsightTypeConfig().getName()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{insightTypeConfig.name=organizations/*/locations/*/insightTypes/*/config}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("insightTypeConfig", request.getInsightTypeConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(InsightTypeConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listInsightsCallable; + private final UnaryCallable + listInsightsPagedCallable; + private final UnaryCallable getInsightCallable; + private final UnaryCallable markInsightAcceptedCallable; + private final UnaryCallable + listRecommendationsCallable; + private final UnaryCallable + listRecommendationsPagedCallable; + private final UnaryCallable getRecommendationCallable; + private final UnaryCallable + markRecommendationClaimedCallable; + private final UnaryCallable + markRecommendationSucceededCallable; + private final UnaryCallable + markRecommendationFailedCallable; + private final UnaryCallable + getRecommenderConfigCallable; + private final UnaryCallable + updateRecommenderConfigCallable; + private final UnaryCallable + getInsightTypeConfigCallable; + private final UnaryCallable + updateInsightTypeConfigCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonRecommenderStub create(RecommenderStubSettings settings) + throws IOException { + return new HttpJsonRecommenderStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonRecommenderStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonRecommenderStub( + RecommenderStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonRecommenderStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonRecommenderStub( + RecommenderStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonRecommenderStub, 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 HttpJsonRecommenderStub(RecommenderStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonRecommenderCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonRecommenderStub, 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 HttpJsonRecommenderStub( + RecommenderStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listInsightsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInsightsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInsightTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInsightMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings markInsightAcceptedTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(markInsightAcceptedMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listRecommendationsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listRecommendationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getRecommendationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getRecommendationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + markRecommendationClaimedTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(markRecommendationClaimedMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + markRecommendationSucceededTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(markRecommendationSucceededMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + markRecommendationFailedTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(markRecommendationFailedMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getRecommenderConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getRecommenderConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateRecommenderConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateRecommenderConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getInsightTypeConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInsightTypeConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateInsightTypeConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateInsightTypeConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listInsightsCallable = + callableFactory.createUnaryCallable( + listInsightsTransportSettings, settings.listInsightsSettings(), clientContext); + this.listInsightsPagedCallable = + callableFactory.createPagedCallable( + listInsightsTransportSettings, settings.listInsightsSettings(), clientContext); + this.getInsightCallable = + callableFactory.createUnaryCallable( + getInsightTransportSettings, settings.getInsightSettings(), clientContext); + this.markInsightAcceptedCallable = + callableFactory.createUnaryCallable( + markInsightAcceptedTransportSettings, + settings.markInsightAcceptedSettings(), + clientContext); + this.listRecommendationsCallable = + callableFactory.createUnaryCallable( + listRecommendationsTransportSettings, + settings.listRecommendationsSettings(), + clientContext); + this.listRecommendationsPagedCallable = + callableFactory.createPagedCallable( + listRecommendationsTransportSettings, + settings.listRecommendationsSettings(), + clientContext); + this.getRecommendationCallable = + callableFactory.createUnaryCallable( + getRecommendationTransportSettings, + settings.getRecommendationSettings(), + clientContext); + this.markRecommendationClaimedCallable = + callableFactory.createUnaryCallable( + markRecommendationClaimedTransportSettings, + settings.markRecommendationClaimedSettings(), + clientContext); + this.markRecommendationSucceededCallable = + callableFactory.createUnaryCallable( + markRecommendationSucceededTransportSettings, + settings.markRecommendationSucceededSettings(), + clientContext); + this.markRecommendationFailedCallable = + callableFactory.createUnaryCallable( + markRecommendationFailedTransportSettings, + settings.markRecommendationFailedSettings(), + clientContext); + this.getRecommenderConfigCallable = + callableFactory.createUnaryCallable( + getRecommenderConfigTransportSettings, + settings.getRecommenderConfigSettings(), + clientContext); + this.updateRecommenderConfigCallable = + callableFactory.createUnaryCallable( + updateRecommenderConfigTransportSettings, + settings.updateRecommenderConfigSettings(), + clientContext); + this.getInsightTypeConfigCallable = + callableFactory.createUnaryCallable( + getInsightTypeConfigTransportSettings, + settings.getInsightTypeConfigSettings(), + clientContext); + this.updateInsightTypeConfigCallable = + callableFactory.createUnaryCallable( + updateInsightTypeConfigTransportSettings, + settings.updateInsightTypeConfigSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listInsightsMethodDescriptor); + methodDescriptors.add(getInsightMethodDescriptor); + methodDescriptors.add(markInsightAcceptedMethodDescriptor); + methodDescriptors.add(listRecommendationsMethodDescriptor); + methodDescriptors.add(getRecommendationMethodDescriptor); + methodDescriptors.add(markRecommendationClaimedMethodDescriptor); + methodDescriptors.add(markRecommendationSucceededMethodDescriptor); + methodDescriptors.add(markRecommendationFailedMethodDescriptor); + methodDescriptors.add(getRecommenderConfigMethodDescriptor); + methodDescriptors.add(updateRecommenderConfigMethodDescriptor); + methodDescriptors.add(getInsightTypeConfigMethodDescriptor); + methodDescriptors.add(updateInsightTypeConfigMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listInsightsCallable() { + return listInsightsCallable; + } + + @Override + public UnaryCallable listInsightsPagedCallable() { + return listInsightsPagedCallable; + } + + @Override + public UnaryCallable getInsightCallable() { + return getInsightCallable; + } + + @Override + public UnaryCallable markInsightAcceptedCallable() { + return markInsightAcceptedCallable; + } + + @Override + public UnaryCallable + listRecommendationsCallable() { + return listRecommendationsCallable; + } + + @Override + public UnaryCallable + listRecommendationsPagedCallable() { + return listRecommendationsPagedCallable; + } + + @Override + public UnaryCallable getRecommendationCallable() { + return getRecommendationCallable; + } + + @Override + public UnaryCallable + markRecommendationClaimedCallable() { + return markRecommendationClaimedCallable; + } + + @Override + public UnaryCallable + markRecommendationSucceededCallable() { + return markRecommendationSucceededCallable; + } + + @Override + public UnaryCallable + markRecommendationFailedCallable() { + return markRecommendationFailedCallable; + } + + @Override + public UnaryCallable + getRecommenderConfigCallable() { + return getRecommenderConfigCallable; + } + + @Override + public UnaryCallable + updateRecommenderConfigCallable() { + return updateRecommenderConfigCallable; + } + + @Override + public UnaryCallable + getInsightTypeConfigCallable() { + return getInsightTypeConfigCallable; + } + + @Override + public UnaryCallable + updateInsightTypeConfigCallable() { + return updateInsightTypeConfigCallable; + } + + @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/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/stub/RecommenderStubSettings.java b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/stub/RecommenderStubSettings.java index d43785412dd9..2199023dc74a 100644 --- a/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/stub/RecommenderStubSettings.java +++ b/java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1beta1/stub/RecommenderStubSettings.java @@ -28,6 +28,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; @@ -324,6 +327,11 @@ public RecommenderStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcRecommenderStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonRecommenderStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -356,18 +364,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(RecommenderStubSettings.class)) @@ -375,11 +390,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(RecommenderStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return RecommenderStubSettings.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); @@ -568,6 +602,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 .listInsightsSettings() diff --git a/java-recommender/google-cloud-recommender/src/test/java/com/google/cloud/recommender/v1/RecommenderClientHttpJsonTest.java b/java-recommender/google-cloud-recommender/src/test/java/com/google/cloud/recommender/v1/RecommenderClientHttpJsonTest.java new file mode 100644 index 000000000000..f9fb0199be9d --- /dev/null +++ b/java-recommender/google-cloud-recommender/src/test/java/com/google/cloud/recommender/v1/RecommenderClientHttpJsonTest.java @@ -0,0 +1,1148 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.recommender.v1; + +import static com.google.cloud.recommender.v1.RecommenderClient.ListInsightsPagedResponse; +import static com.google.cloud.recommender.v1.RecommenderClient.ListRecommendationsPagedResponse; + +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.recommender.v1.stub.HttpJsonRecommenderStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Duration; +import com.google.protobuf.Struct; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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 RecommenderClientHttpJsonTest { + private static MockHttpService mockService; + private static RecommenderClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonRecommenderStub.getMethodDescriptors(), + RecommenderSettings.getDefaultEndpoint()); + RecommenderSettings settings = + RecommenderSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + RecommenderSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = RecommenderClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listInsightsTest() throws Exception { + Insight responsesElement = Insight.newBuilder().build(); + ListInsightsResponse expectedResponse = + ListInsightsResponse.newBuilder() + .setNextPageToken("") + .addAllInsights(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InsightTypeName parent = + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]"); + + ListInsightsPagedResponse pagedListResponse = client.listInsights(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInsightsList().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 listInsightsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InsightTypeName parent = + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]"); + client.listInsights(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInsightsTest2() throws Exception { + Insight responsesElement = Insight.newBuilder().build(); + ListInsightsResponse expectedResponse = + ListInsightsResponse.newBuilder() + .setNextPageToken("") + .addAllInsights(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-8290/locations/location-8290/insightTypes/insightType-8290"; + + ListInsightsPagedResponse pagedListResponse = client.listInsights(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInsightsList().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 listInsightsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-8290/locations/location-8290/insightTypes/insightType-8290"; + client.listInsights(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInsightTest() throws Exception { + Insight expectedResponse = + Insight.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .setDescription("description-1724546052") + .addAllTargetResources(new ArrayList()) + .setInsightSubtype("insightSubtype841535170") + .setContent(Struct.newBuilder().build()) + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setObservationPeriod(Duration.newBuilder().build()) + .setStateInfo(InsightStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedRecommendations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + + Insight actualResponse = client.getInsight(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 getInsightExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + client.getInsight(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInsightTest2() throws Exception { + Insight expectedResponse = + Insight.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .setDescription("description-1724546052") + .addAllTargetResources(new ArrayList()) + .setInsightSubtype("insightSubtype841535170") + .setContent(Struct.newBuilder().build()) + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setObservationPeriod(Duration.newBuilder().build()) + .setStateInfo(InsightStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedRecommendations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-3636/locations/location-3636/insightTypes/insightType-3636/insights/insight-3636"; + + Insight actualResponse = client.getInsight(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 getInsightExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-3636/locations/location-3636/insightTypes/insightType-3636/insights/insight-3636"; + client.getInsight(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markInsightAcceptedTest() throws Exception { + Insight expectedResponse = + Insight.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .setDescription("description-1724546052") + .addAllTargetResources(new ArrayList()) + .setInsightSubtype("insightSubtype841535170") + .setContent(Struct.newBuilder().build()) + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setObservationPeriod(Duration.newBuilder().build()) + .setStateInfo(InsightStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedRecommendations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Insight actualResponse = client.markInsightAccepted(name, stateMetadata, etag); + 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 markInsightAcceptedExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markInsightAccepted(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markInsightAcceptedTest2() throws Exception { + Insight expectedResponse = + Insight.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .setDescription("description-1724546052") + .addAllTargetResources(new ArrayList()) + .setInsightSubtype("insightSubtype841535170") + .setContent(Struct.newBuilder().build()) + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setObservationPeriod(Duration.newBuilder().build()) + .setStateInfo(InsightStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedRecommendations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-3636/locations/location-3636/insightTypes/insightType-3636/insights/insight-3636"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Insight actualResponse = client.markInsightAccepted(name, stateMetadata, etag); + 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 markInsightAcceptedExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-3636/locations/location-3636/insightTypes/insightType-3636/insights/insight-3636"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markInsightAccepted(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRecommendationsTest() throws Exception { + Recommendation responsesElement = Recommendation.newBuilder().build(); + ListRecommendationsResponse expectedResponse = + ListRecommendationsResponse.newBuilder() + .setNextPageToken("") + .addAllRecommendations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + RecommenderName parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + + ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRecommendationsList().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 listRecommendationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommenderName parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + client.listRecommendations(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRecommendationsTest2() throws Exception { + Recommendation responsesElement = Recommendation.newBuilder().build(); + ListRecommendationsResponse expectedResponse = + ListRecommendationsResponse.newBuilder() + .setNextPageToken("") + .addAllRecommendations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6437/locations/location-6437/recommenders/recommender-6437"; + + ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRecommendationsList().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 listRecommendationsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6437/locations/location-6437/recommenders/recommender-6437"; + client.listRecommendations(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRecommendationsTest3() throws Exception { + Recommendation responsesElement = Recommendation.newBuilder().build(); + ListRecommendationsResponse expectedResponse = + ListRecommendationsResponse.newBuilder() + .setNextPageToken("") + .addAllRecommendations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + RecommenderName parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + String filter = "filter-1274492040"; + + ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRecommendationsList().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 listRecommendationsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommenderName parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + String filter = "filter-1274492040"; + client.listRecommendations(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRecommendationsTest4() throws Exception { + Recommendation responsesElement = Recommendation.newBuilder().build(); + ListRecommendationsResponse expectedResponse = + ListRecommendationsResponse.newBuilder() + .setNextPageToken("") + .addAllRecommendations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6437/locations/location-6437/recommenders/recommender-6437"; + String filter = "filter-1274492040"; + + ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRecommendationsList().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 listRecommendationsExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6437/locations/location-6437/recommenders/recommender-6437"; + String filter = "filter-1274492040"; + client.listRecommendations(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRecommendationTest() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + + Recommendation actualResponse = client.getRecommendation(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 getRecommendationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + client.getRecommendation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRecommendationTest2() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + + Recommendation actualResponse = client.getRecommendation(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 getRecommendationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + client.getRecommendation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationClaimedTest() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationClaimed(name, stateMetadata, etag); + 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 markRecommendationClaimedExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationClaimed(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationClaimedTest2() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationClaimed(name, stateMetadata, etag); + 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 markRecommendationClaimedExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationClaimed(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationSucceededTest() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationSucceeded(name, stateMetadata, etag); + 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 markRecommendationSucceededExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationSucceeded(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationSucceededTest2() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationSucceeded(name, stateMetadata, etag); + 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 markRecommendationSucceededExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationSucceeded(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationFailedTest() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationFailed(name, stateMetadata, etag); + 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 markRecommendationFailedExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationFailed(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationFailedTest2() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationFailed(name, stateMetadata, etag); + 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 markRecommendationFailedExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationFailed(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-recommender/google-cloud-recommender/src/test/java/com/google/cloud/recommender/v1beta1/RecommenderClientHttpJsonTest.java b/java-recommender/google-cloud-recommender/src/test/java/com/google/cloud/recommender/v1beta1/RecommenderClientHttpJsonTest.java new file mode 100644 index 000000000000..0b0dd83b934b --- /dev/null +++ b/java-recommender/google-cloud-recommender/src/test/java/com/google/cloud/recommender/v1beta1/RecommenderClientHttpJsonTest.java @@ -0,0 +1,1429 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.recommender.v1beta1; + +import static com.google.cloud.recommender.v1beta1.RecommenderClient.ListInsightsPagedResponse; +import static com.google.cloud.recommender.v1beta1.RecommenderClient.ListRecommendationsPagedResponse; + +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.recommender.v1beta1.stub.HttpJsonRecommenderStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Struct; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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 RecommenderClientHttpJsonTest { + private static MockHttpService mockService; + private static RecommenderClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonRecommenderStub.getMethodDescriptors(), + RecommenderSettings.getDefaultEndpoint()); + RecommenderSettings settings = + RecommenderSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + RecommenderSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = RecommenderClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listInsightsTest() throws Exception { + Insight responsesElement = Insight.newBuilder().build(); + ListInsightsResponse expectedResponse = + ListInsightsResponse.newBuilder() + .setNextPageToken("") + .addAllInsights(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InsightTypeName parent = + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]"); + + ListInsightsPagedResponse pagedListResponse = client.listInsights(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInsightsList().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 listInsightsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InsightTypeName parent = + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]"); + client.listInsights(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInsightsTest2() throws Exception { + Insight responsesElement = Insight.newBuilder().build(); + ListInsightsResponse expectedResponse = + ListInsightsResponse.newBuilder() + .setNextPageToken("") + .addAllInsights(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-8290/locations/location-8290/insightTypes/insightType-8290"; + + ListInsightsPagedResponse pagedListResponse = client.listInsights(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInsightsList().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 listInsightsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-8290/locations/location-8290/insightTypes/insightType-8290"; + client.listInsights(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInsightTest() throws Exception { + Insight expectedResponse = + Insight.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .setDescription("description-1724546052") + .addAllTargetResources(new ArrayList()) + .setInsightSubtype("insightSubtype841535170") + .setContent(Struct.newBuilder().build()) + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setObservationPeriod(Duration.newBuilder().build()) + .setStateInfo(InsightStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedRecommendations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + + Insight actualResponse = client.getInsight(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 getInsightExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + client.getInsight(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInsightTest2() throws Exception { + Insight expectedResponse = + Insight.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .setDescription("description-1724546052") + .addAllTargetResources(new ArrayList()) + .setInsightSubtype("insightSubtype841535170") + .setContent(Struct.newBuilder().build()) + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setObservationPeriod(Duration.newBuilder().build()) + .setStateInfo(InsightStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedRecommendations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-3636/locations/location-3636/insightTypes/insightType-3636/insights/insight-3636"; + + Insight actualResponse = client.getInsight(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 getInsightExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-3636/locations/location-3636/insightTypes/insightType-3636/insights/insight-3636"; + client.getInsight(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markInsightAcceptedTest() throws Exception { + Insight expectedResponse = + Insight.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .setDescription("description-1724546052") + .addAllTargetResources(new ArrayList()) + .setInsightSubtype("insightSubtype841535170") + .setContent(Struct.newBuilder().build()) + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setObservationPeriod(Duration.newBuilder().build()) + .setStateInfo(InsightStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedRecommendations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Insight actualResponse = client.markInsightAccepted(name, stateMetadata, etag); + 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 markInsightAcceptedExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markInsightAccepted(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markInsightAcceptedTest2() throws Exception { + Insight expectedResponse = + Insight.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .setDescription("description-1724546052") + .addAllTargetResources(new ArrayList()) + .setInsightSubtype("insightSubtype841535170") + .setContent(Struct.newBuilder().build()) + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setObservationPeriod(Duration.newBuilder().build()) + .setStateInfo(InsightStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedRecommendations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-3636/locations/location-3636/insightTypes/insightType-3636/insights/insight-3636"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Insight actualResponse = client.markInsightAccepted(name, stateMetadata, etag); + 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 markInsightAcceptedExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-3636/locations/location-3636/insightTypes/insightType-3636/insights/insight-3636"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markInsightAccepted(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRecommendationsTest() throws Exception { + Recommendation responsesElement = Recommendation.newBuilder().build(); + ListRecommendationsResponse expectedResponse = + ListRecommendationsResponse.newBuilder() + .setNextPageToken("") + .addAllRecommendations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + RecommenderName parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + String filter = "filter-1274492040"; + + ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRecommendationsList().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 listRecommendationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommenderName parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + String filter = "filter-1274492040"; + client.listRecommendations(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRecommendationsTest2() throws Exception { + Recommendation responsesElement = Recommendation.newBuilder().build(); + ListRecommendationsResponse expectedResponse = + ListRecommendationsResponse.newBuilder() + .setNextPageToken("") + .addAllRecommendations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6437/locations/location-6437/recommenders/recommender-6437"; + String filter = "filter-1274492040"; + + ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRecommendationsList().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 listRecommendationsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6437/locations/location-6437/recommenders/recommender-6437"; + String filter = "filter-1274492040"; + client.listRecommendations(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRecommendationTest() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + + Recommendation actualResponse = client.getRecommendation(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 getRecommendationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + client.getRecommendation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRecommendationTest2() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + + Recommendation actualResponse = client.getRecommendation(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 getRecommendationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + client.getRecommendation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationClaimedTest() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationClaimed(name, stateMetadata, etag); + 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 markRecommendationClaimedExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationClaimed(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationClaimedTest2() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationClaimed(name, stateMetadata, etag); + 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 markRecommendationClaimedExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationClaimed(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationSucceededTest() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationSucceeded(name, stateMetadata, etag); + 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 markRecommendationSucceededExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationSucceeded(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationSucceededTest2() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationSucceeded(name, stateMetadata, etag); + 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 markRecommendationSucceededExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationSucceeded(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationFailedTest() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationFailed(name, stateMetadata, etag); + 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 markRecommendationFailedExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationFailed(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void markRecommendationFailedTest2() throws Exception { + Recommendation expectedResponse = + Recommendation.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .setDescription("description-1724546052") + .setRecommenderSubtype("recommenderSubtype1811451601") + .setLastRefreshTime(Timestamp.newBuilder().build()) + .setPrimaryImpact(Impact.newBuilder().build()) + .addAllAdditionalImpact(new ArrayList()) + .setContent(RecommendationContent.newBuilder().build()) + .setStateInfo(RecommendationStateInfo.newBuilder().build()) + .setEtag("etag3123477") + .addAllAssociatedInsights(new ArrayList()) + .setXorGroupId("xorGroupId-2095769825") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + + Recommendation actualResponse = client.markRecommendationFailed(name, stateMetadata, etag); + 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 markRecommendationFailedExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9152/locations/location-9152/recommenders/recommender-9152/recommendations/recommendation-9152"; + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + client.markRecommendationFailed(name, stateMetadata, etag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRecommenderConfigTest() throws Exception { + RecommenderConfig expectedResponse = + RecommenderConfig.newBuilder() + .setName( + RecommenderConfigName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .setRecommenderGenerationConfig(RecommenderGenerationConfig.newBuilder().build()) + .setEtag("etag3123477") + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .putAllAnnotations(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + mockService.addResponse(expectedResponse); + + RecommenderConfigName name = + RecommenderConfigName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + + RecommenderConfig actualResponse = client.getRecommenderConfig(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 getRecommenderConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommenderConfigName name = + RecommenderConfigName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + client.getRecommenderConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRecommenderConfigTest2() throws Exception { + RecommenderConfig expectedResponse = + RecommenderConfig.newBuilder() + .setName( + RecommenderConfigName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .setRecommenderGenerationConfig(RecommenderGenerationConfig.newBuilder().build()) + .setEtag("etag3123477") + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .putAllAnnotations(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-3367/locations/location-3367/recommenders/recommender-3367/config"; + + RecommenderConfig actualResponse = client.getRecommenderConfig(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 getRecommenderConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-3367/locations/location-3367/recommenders/recommender-3367/config"; + client.getRecommenderConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateRecommenderConfigTest() throws Exception { + RecommenderConfig expectedResponse = + RecommenderConfig.newBuilder() + .setName( + RecommenderConfigName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .setRecommenderGenerationConfig(RecommenderGenerationConfig.newBuilder().build()) + .setEtag("etag3123477") + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .putAllAnnotations(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + mockService.addResponse(expectedResponse); + + RecommenderConfig recommenderConfig = + RecommenderConfig.newBuilder() + .setName( + RecommenderConfigName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .setRecommenderGenerationConfig(RecommenderGenerationConfig.newBuilder().build()) + .setEtag("etag3123477") + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .putAllAnnotations(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + RecommenderConfig actualResponse = + client.updateRecommenderConfig(recommenderConfig, 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 updateRecommenderConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RecommenderConfig recommenderConfig = + RecommenderConfig.newBuilder() + .setName( + RecommenderConfigName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .setRecommenderGenerationConfig(RecommenderGenerationConfig.newBuilder().build()) + .setEtag("etag3123477") + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .putAllAnnotations(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateRecommenderConfig(recommenderConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInsightTypeConfigTest() throws Exception { + InsightTypeConfig expectedResponse = + InsightTypeConfig.newBuilder() + .setName( + InsightTypeConfigName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .setInsightTypeGenerationConfig(InsightTypeGenerationConfig.newBuilder().build()) + .setEtag("etag3123477") + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .putAllAnnotations(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + mockService.addResponse(expectedResponse); + + InsightTypeConfigName name = + InsightTypeConfigName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]"); + + InsightTypeConfig actualResponse = client.getInsightTypeConfig(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 getInsightTypeConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InsightTypeConfigName name = + InsightTypeConfigName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]"); + client.getInsightTypeConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInsightTypeConfigTest2() throws Exception { + InsightTypeConfig expectedResponse = + InsightTypeConfig.newBuilder() + .setName( + InsightTypeConfigName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .setInsightTypeGenerationConfig(InsightTypeGenerationConfig.newBuilder().build()) + .setEtag("etag3123477") + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .putAllAnnotations(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-5840/locations/location-5840/insightTypes/insightType-5840/config"; + + InsightTypeConfig actualResponse = client.getInsightTypeConfig(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 getInsightTypeConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5840/locations/location-5840/insightTypes/insightType-5840/config"; + client.getInsightTypeConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateInsightTypeConfigTest() throws Exception { + InsightTypeConfig expectedResponse = + InsightTypeConfig.newBuilder() + .setName( + InsightTypeConfigName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .setInsightTypeGenerationConfig(InsightTypeGenerationConfig.newBuilder().build()) + .setEtag("etag3123477") + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .putAllAnnotations(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + mockService.addResponse(expectedResponse); + + InsightTypeConfig insightTypeConfig = + InsightTypeConfig.newBuilder() + .setName( + InsightTypeConfigName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .setInsightTypeGenerationConfig(InsightTypeGenerationConfig.newBuilder().build()) + .setEtag("etag3123477") + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .putAllAnnotations(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + InsightTypeConfig actualResponse = + client.updateInsightTypeConfig(insightTypeConfig, 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 updateInsightTypeConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InsightTypeConfig insightTypeConfig = + InsightTypeConfig.newBuilder() + .setName( + InsightTypeConfigName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .setInsightTypeGenerationConfig(InsightTypeGenerationConfig.newBuilder().build()) + .setEtag("etag3123477") + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .putAllAnnotations(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateInsightTypeConfig(insightTypeConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/create/SyncCreateSetCredentialsProvider.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..d080776f898e --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.recommender.v1.RecommenderClient; +import com.google.cloud.recommender.v1.RecommenderSettings; +import com.google.cloud.recommender.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + RecommenderSettings recommenderSettings = + RecommenderSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings); + } +} +// [END recommender_v1_generated_recommenderclient_create_setcredentialsprovider_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/create/SyncCreateSetCredentialsProvider1.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..dedbd6687b1d --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_create_setcredentialsprovider1_sync] +import com.google.cloud.recommender.v1.RecommenderClient; +import com.google.cloud.recommender.v1.RecommenderSettings; + +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. + RecommenderSettings recommenderSettings = + RecommenderSettings.newBuilder() + .setTransportChannelProvider( + RecommenderSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings); + } +} +// [END recommender_v1_generated_recommenderclient_create_setcredentialsprovider1_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/create/SyncCreateSetEndpoint.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..7df4f9209ee3 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_create_setendpoint_sync] +import com.google.cloud.recommender.v1.RecommenderClient; +import com.google.cloud.recommender.v1.RecommenderSettings; +import com.google.cloud.recommender.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + RecommenderSettings recommenderSettings = + RecommenderSettings.newBuilder().setEndpoint(myEndpoint).build(); + RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings); + } +} +// [END recommender_v1_generated_recommenderclient_create_setendpoint_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/AsyncGetInsight.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/AsyncGetInsight.java new file mode 100644 index 000000000000..c3886080bc8d --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/AsyncGetInsight.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_getinsight_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1.GetInsightRequest; +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightName; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class AsyncGetInsight { + + public static void main(String[] args) throws Exception { + asyncGetInsight(); + } + + public static void asyncGetInsight() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetInsightRequest request = + GetInsightRequest.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .build(); + ApiFuture future = recommenderClient.getInsightCallable().futureCall(request); + // Do something. + Insight response = future.get(); + } + } +} +// [END recommender_v1_generated_recommenderclient_getinsight_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/SyncGetInsight.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/SyncGetInsight.java new file mode 100644 index 000000000000..706768615a34 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/SyncGetInsight.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_getinsight_sync] +import com.google.cloud.recommender.v1.GetInsightRequest; +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightName; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class SyncGetInsight { + + public static void main(String[] args) throws Exception { + syncGetInsight(); + } + + public static void syncGetInsight() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetInsightRequest request = + GetInsightRequest.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .build(); + Insight response = recommenderClient.getInsight(request); + } + } +} +// [END recommender_v1_generated_recommenderclient_getinsight_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/SyncGetInsightInsightname.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/SyncGetInsightInsightname.java new file mode 100644 index 000000000000..69c4921e4437 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/SyncGetInsightInsightname.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_getinsight_insightname_sync] +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightName; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class SyncGetInsightInsightname { + + public static void main(String[] args) throws Exception { + syncGetInsightInsightname(); + } + + public static void syncGetInsightInsightname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + Insight response = recommenderClient.getInsight(name); + } + } +} +// [END recommender_v1_generated_recommenderclient_getinsight_insightname_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/SyncGetInsightString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/SyncGetInsightString.java new file mode 100644 index 000000000000..af559b52058f --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getinsight/SyncGetInsightString.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_getinsight_string_sync] +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightName; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class SyncGetInsightString { + + public static void main(String[] args) throws Exception { + syncGetInsightString(); + } + + public static void syncGetInsightString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString(); + Insight response = recommenderClient.getInsight(name); + } + } +} +// [END recommender_v1_generated_recommenderclient_getinsight_string_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/AsyncGetRecommendation.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/AsyncGetRecommendation.java new file mode 100644 index 000000000000..abed6e1523bf --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/AsyncGetRecommendation.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_getrecommendation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1.GetRecommendationRequest; +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class AsyncGetRecommendation { + + public static void main(String[] args) throws Exception { + asyncGetRecommendation(); + } + + public static void asyncGetRecommendation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetRecommendationRequest request = + GetRecommendationRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .build(); + ApiFuture future = + recommenderClient.getRecommendationCallable().futureCall(request); + // Do something. + Recommendation response = future.get(); + } + } +} +// [END recommender_v1_generated_recommenderclient_getrecommendation_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/SyncGetRecommendation.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/SyncGetRecommendation.java new file mode 100644 index 000000000000..e0f9ae71656b --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/SyncGetRecommendation.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_getrecommendation_sync] +import com.google.cloud.recommender.v1.GetRecommendationRequest; +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class SyncGetRecommendation { + + public static void main(String[] args) throws Exception { + syncGetRecommendation(); + } + + public static void syncGetRecommendation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetRecommendationRequest request = + GetRecommendationRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .build(); + Recommendation response = recommenderClient.getRecommendation(request); + } + } +} +// [END recommender_v1_generated_recommenderclient_getrecommendation_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/SyncGetRecommendationRecommendationname.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/SyncGetRecommendationRecommendationname.java new file mode 100644 index 000000000000..753d58cc105b --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/SyncGetRecommendationRecommendationname.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_getrecommendation_recommendationname_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class SyncGetRecommendationRecommendationname { + + public static void main(String[] args) throws Exception { + syncGetRecommendationRecommendationname(); + } + + public static void syncGetRecommendationRecommendationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Recommendation response = recommenderClient.getRecommendation(name); + } + } +} +// [END recommender_v1_generated_recommenderclient_getrecommendation_recommendationname_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/SyncGetRecommendationString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/SyncGetRecommendationString.java new file mode 100644 index 000000000000..de04ce88d76b --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/getrecommendation/SyncGetRecommendationString.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_getrecommendation_string_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class SyncGetRecommendationString { + + public static void main(String[] args) throws Exception { + syncGetRecommendationString(); + } + + public static void syncGetRecommendationString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString(); + Recommendation response = recommenderClient.getRecommendation(name); + } + } +} +// [END recommender_v1_generated_recommenderclient_getrecommendation_string_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/AsyncListInsights.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/AsyncListInsights.java new file mode 100644 index 000000000000..b039e65b0455 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/AsyncListInsights.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listinsights_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightTypeName; +import com.google.cloud.recommender.v1.ListInsightsRequest; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class AsyncListInsights { + + public static void main(String[] args) throws Exception { + asyncListInsights(); + } + + public static void asyncListInsights() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListInsightsRequest request = + ListInsightsRequest.newBuilder() + .setParent( + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = recommenderClient.listInsightsPagedCallable().futureCall(request); + // Do something. + for (Insight element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listinsights_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/AsyncListInsightsPaged.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/AsyncListInsightsPaged.java new file mode 100644 index 000000000000..c839dd09daf6 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/AsyncListInsightsPaged.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listinsights_paged_async] +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightTypeName; +import com.google.cloud.recommender.v1.ListInsightsRequest; +import com.google.cloud.recommender.v1.ListInsightsResponse; +import com.google.cloud.recommender.v1.RecommenderClient; +import com.google.common.base.Strings; + +public class AsyncListInsightsPaged { + + public static void main(String[] args) throws Exception { + asyncListInsightsPaged(); + } + + public static void asyncListInsightsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListInsightsRequest request = + ListInsightsRequest.newBuilder() + .setParent( + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListInsightsResponse response = recommenderClient.listInsightsCallable().call(request); + for (Insight element : response.getInsightsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listinsights_paged_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/SyncListInsights.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/SyncListInsights.java new file mode 100644 index 000000000000..762761b5b2c5 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/SyncListInsights.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listinsights_sync] +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightTypeName; +import com.google.cloud.recommender.v1.ListInsightsRequest; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class SyncListInsights { + + public static void main(String[] args) throws Exception { + syncListInsights(); + } + + public static void syncListInsights() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListInsightsRequest request = + ListInsightsRequest.newBuilder() + .setParent( + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Insight element : recommenderClient.listInsights(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listinsights_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/SyncListInsightsInsighttypename.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/SyncListInsightsInsighttypename.java new file mode 100644 index 000000000000..782cd22bf147 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/SyncListInsightsInsighttypename.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listinsights_insighttypename_sync] +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightTypeName; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class SyncListInsightsInsighttypename { + + public static void main(String[] args) throws Exception { + syncListInsightsInsighttypename(); + } + + public static void syncListInsightsInsighttypename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + InsightTypeName parent = + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]"); + for (Insight element : recommenderClient.listInsights(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listinsights_insighttypename_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/SyncListInsightsString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/SyncListInsightsString.java new file mode 100644 index 000000000000..863c396f0769 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listinsights/SyncListInsightsString.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listinsights_string_sync] +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightTypeName; +import com.google.cloud.recommender.v1.RecommenderClient; + +public class SyncListInsightsString { + + public static void main(String[] args) throws Exception { + syncListInsightsString(); + } + + public static void syncListInsightsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String parent = + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString(); + for (Insight element : recommenderClient.listInsights(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listinsights_string_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/AsyncListRecommendations.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/AsyncListRecommendations.java new file mode 100644 index 000000000000..ec0142e4a846 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/AsyncListRecommendations.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listrecommendations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1.ListRecommendationsRequest; +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommenderClient; +import com.google.cloud.recommender.v1.RecommenderName; + +public class AsyncListRecommendations { + + public static void main(String[] args) throws Exception { + asyncListRecommendations(); + } + + public static void asyncListRecommendations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListRecommendationsRequest request = + ListRecommendationsRequest.newBuilder() + .setParent( + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + recommenderClient.listRecommendationsPagedCallable().futureCall(request); + // Do something. + for (Recommendation element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listrecommendations_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/AsyncListRecommendationsPaged.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/AsyncListRecommendationsPaged.java new file mode 100644 index 000000000000..68ab03877b0a --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/AsyncListRecommendationsPaged.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listrecommendations_paged_async] +import com.google.cloud.recommender.v1.ListRecommendationsRequest; +import com.google.cloud.recommender.v1.ListRecommendationsResponse; +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommenderClient; +import com.google.cloud.recommender.v1.RecommenderName; +import com.google.common.base.Strings; + +public class AsyncListRecommendationsPaged { + + public static void main(String[] args) throws Exception { + asyncListRecommendationsPaged(); + } + + public static void asyncListRecommendationsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListRecommendationsRequest request = + ListRecommendationsRequest.newBuilder() + .setParent( + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListRecommendationsResponse response = + recommenderClient.listRecommendationsCallable().call(request); + for (Recommendation element : response.getRecommendationsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listrecommendations_paged_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendations.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendations.java new file mode 100644 index 000000000000..434c7580c22b --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendations.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listrecommendations_sync] +import com.google.cloud.recommender.v1.ListRecommendationsRequest; +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommenderClient; +import com.google.cloud.recommender.v1.RecommenderName; + +public class SyncListRecommendations { + + public static void main(String[] args) throws Exception { + syncListRecommendations(); + } + + public static void syncListRecommendations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListRecommendationsRequest request = + ListRecommendationsRequest.newBuilder() + .setParent( + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Recommendation element : recommenderClient.listRecommendations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listrecommendations_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsRecommendername.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsRecommendername.java new file mode 100644 index 000000000000..daa61fe50048 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsRecommendername.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listrecommendations_recommendername_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommenderClient; +import com.google.cloud.recommender.v1.RecommenderName; + +public class SyncListRecommendationsRecommendername { + + public static void main(String[] args) throws Exception { + syncListRecommendationsRecommendername(); + } + + public static void syncListRecommendationsRecommendername() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommenderName parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + for (Recommendation element : recommenderClient.listRecommendations(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listrecommendations_recommendername_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsRecommendernameString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsRecommendernameString.java new file mode 100644 index 000000000000..187dc9b464f8 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsRecommendernameString.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listrecommendations_recommendernamestring_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommenderClient; +import com.google.cloud.recommender.v1.RecommenderName; + +public class SyncListRecommendationsRecommendernameString { + + public static void main(String[] args) throws Exception { + syncListRecommendationsRecommendernameString(); + } + + public static void syncListRecommendationsRecommendernameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommenderName parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + String filter = "filter-1274492040"; + for (Recommendation element : + recommenderClient.listRecommendations(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listrecommendations_recommendernamestring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsString.java new file mode 100644 index 000000000000..1667f8d3d69a --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsString.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listrecommendations_string_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommenderClient; +import com.google.cloud.recommender.v1.RecommenderName; + +public class SyncListRecommendationsString { + + public static void main(String[] args) throws Exception { + syncListRecommendationsString(); + } + + public static void syncListRecommendationsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString(); + for (Recommendation element : recommenderClient.listRecommendations(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listrecommendations_string_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsStringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsStringString.java new file mode 100644 index 000000000000..78f20d1fadab --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/listrecommendations/SyncListRecommendationsStringString.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_listrecommendations_stringstring_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommenderClient; +import com.google.cloud.recommender.v1.RecommenderName; + +public class SyncListRecommendationsStringString { + + public static void main(String[] args) throws Exception { + syncListRecommendationsStringString(); + } + + public static void syncListRecommendationsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString(); + String filter = "filter-1274492040"; + for (Recommendation element : + recommenderClient.listRecommendations(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1_generated_recommenderclient_listrecommendations_stringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/AsyncMarkInsightAccepted.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/AsyncMarkInsightAccepted.java new file mode 100644 index 000000000000..d827362f7c17 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/AsyncMarkInsightAccepted.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_markinsightaccepted_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightName; +import com.google.cloud.recommender.v1.MarkInsightAcceptedRequest; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; + +public class AsyncMarkInsightAccepted { + + public static void main(String[] args) throws Exception { + asyncMarkInsightAccepted(); + } + + public static void asyncMarkInsightAccepted() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkInsightAcceptedRequest request = + MarkInsightAcceptedRequest.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + ApiFuture future = + recommenderClient.markInsightAcceptedCallable().futureCall(request); + // Do something. + Insight response = future.get(); + } + } +} +// [END recommender_v1_generated_recommenderclient_markinsightaccepted_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/SyncMarkInsightAccepted.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/SyncMarkInsightAccepted.java new file mode 100644 index 000000000000..bd3d4486851f --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/SyncMarkInsightAccepted.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_markinsightaccepted_sync] +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightName; +import com.google.cloud.recommender.v1.MarkInsightAcceptedRequest; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; + +public class SyncMarkInsightAccepted { + + public static void main(String[] args) throws Exception { + syncMarkInsightAccepted(); + } + + public static void syncMarkInsightAccepted() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkInsightAcceptedRequest request = + MarkInsightAcceptedRequest.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + Insight response = recommenderClient.markInsightAccepted(request); + } + } +} +// [END recommender_v1_generated_recommenderclient_markinsightaccepted_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedInsightnameMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedInsightnameMapstringstringString.java new file mode 100644 index 000000000000..3123b74afa47 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedInsightnameMapstringstringString.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.recommender.v1.samples; + +// [START +// recommender_v1_generated_recommenderclient_markinsightaccepted_insightnamemapstringstringstring_sync] +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkInsightAcceptedInsightnameMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkInsightAcceptedInsightnameMapstringstringString(); + } + + public static void syncMarkInsightAcceptedInsightnameMapstringstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Insight response = recommenderClient.markInsightAccepted(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1_generated_recommenderclient_markinsightaccepted_insightnamemapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedStringMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedStringMapstringstringString.java new file mode 100644 index 000000000000..86b989efc6c0 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedStringMapstringstringString.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.recommender.v1.samples; + +// [START +// recommender_v1_generated_recommenderclient_markinsightaccepted_stringmapstringstringstring_sync] +import com.google.cloud.recommender.v1.Insight; +import com.google.cloud.recommender.v1.InsightName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkInsightAcceptedStringMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkInsightAcceptedStringMapstringstringString(); + } + + public static void syncMarkInsightAcceptedStringMapstringstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString(); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Insight response = recommenderClient.markInsightAccepted(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1_generated_recommenderclient_markinsightaccepted_stringmapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/AsyncMarkRecommendationClaimed.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/AsyncMarkRecommendationClaimed.java new file mode 100644 index 000000000000..73ed88e3c5fe --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/AsyncMarkRecommendationClaimed.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_markrecommendationclaimed_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1.MarkRecommendationClaimedRequest; +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; + +public class AsyncMarkRecommendationClaimed { + + public static void main(String[] args) throws Exception { + asyncMarkRecommendationClaimed(); + } + + public static void asyncMarkRecommendationClaimed() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationClaimedRequest request = + MarkRecommendationClaimedRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + ApiFuture future = + recommenderClient.markRecommendationClaimedCallable().futureCall(request); + // Do something. + Recommendation response = future.get(); + } + } +} +// [END recommender_v1_generated_recommenderclient_markrecommendationclaimed_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimed.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimed.java new file mode 100644 index 000000000000..a46d34790a61 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimed.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_markrecommendationclaimed_sync] +import com.google.cloud.recommender.v1.MarkRecommendationClaimedRequest; +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; + +public class SyncMarkRecommendationClaimed { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationClaimed(); + } + + public static void syncMarkRecommendationClaimed() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationClaimedRequest request = + MarkRecommendationClaimedRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + Recommendation response = recommenderClient.markRecommendationClaimed(request); + } + } +} +// [END recommender_v1_generated_recommenderclient_markrecommendationclaimed_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedRecommendationnameMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedRecommendationnameMapstringstringString.java new file mode 100644 index 000000000000..2535dd1be9d8 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedRecommendationnameMapstringstringString.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.recommender.v1.samples; + +// [START +// recommender_v1_generated_recommenderclient_markrecommendationclaimed_recommendationnamemapstringstringstring_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationClaimedRecommendationnameMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationClaimedRecommendationnameMapstringstringString(); + } + + public static void syncMarkRecommendationClaimedRecommendationnameMapstringstringString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationClaimed(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1_generated_recommenderclient_markrecommendationclaimed_recommendationnamemapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedStringMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedStringMapstringstringString.java new file mode 100644 index 000000000000..e101284664aa --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedStringMapstringstringString.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.recommender.v1.samples; + +// [START +// recommender_v1_generated_recommenderclient_markrecommendationclaimed_stringmapstringstringstring_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationClaimedStringMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationClaimedStringMapstringstringString(); + } + + public static void syncMarkRecommendationClaimedStringMapstringstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString(); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationClaimed(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1_generated_recommenderclient_markrecommendationclaimed_stringmapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/AsyncMarkRecommendationFailed.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/AsyncMarkRecommendationFailed.java new file mode 100644 index 000000000000..a75a16bdc79f --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/AsyncMarkRecommendationFailed.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_markrecommendationfailed_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1.MarkRecommendationFailedRequest; +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; + +public class AsyncMarkRecommendationFailed { + + public static void main(String[] args) throws Exception { + asyncMarkRecommendationFailed(); + } + + public static void asyncMarkRecommendationFailed() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationFailedRequest request = + MarkRecommendationFailedRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + ApiFuture future = + recommenderClient.markRecommendationFailedCallable().futureCall(request); + // Do something. + Recommendation response = future.get(); + } + } +} +// [END recommender_v1_generated_recommenderclient_markrecommendationfailed_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailed.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailed.java new file mode 100644 index 000000000000..4b8775900822 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailed.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_markrecommendationfailed_sync] +import com.google.cloud.recommender.v1.MarkRecommendationFailedRequest; +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; + +public class SyncMarkRecommendationFailed { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationFailed(); + } + + public static void syncMarkRecommendationFailed() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationFailedRequest request = + MarkRecommendationFailedRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + Recommendation response = recommenderClient.markRecommendationFailed(request); + } + } +} +// [END recommender_v1_generated_recommenderclient_markrecommendationfailed_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedRecommendationnameMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedRecommendationnameMapstringstringString.java new file mode 100644 index 000000000000..5ba32fc0b7fc --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedRecommendationnameMapstringstringString.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.recommender.v1.samples; + +// [START +// recommender_v1_generated_recommenderclient_markrecommendationfailed_recommendationnamemapstringstringstring_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationFailedRecommendationnameMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationFailedRecommendationnameMapstringstringString(); + } + + public static void syncMarkRecommendationFailedRecommendationnameMapstringstringString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationFailed(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1_generated_recommenderclient_markrecommendationfailed_recommendationnamemapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedStringMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedStringMapstringstringString.java new file mode 100644 index 000000000000..dd844f2f8903 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedStringMapstringstringString.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.recommender.v1.samples; + +// [START +// recommender_v1_generated_recommenderclient_markrecommendationfailed_stringmapstringstringstring_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationFailedStringMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationFailedStringMapstringstringString(); + } + + public static void syncMarkRecommendationFailedStringMapstringstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString(); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationFailed(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1_generated_recommenderclient_markrecommendationfailed_stringmapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/AsyncMarkRecommendationSucceeded.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/AsyncMarkRecommendationSucceeded.java new file mode 100644 index 000000000000..1ab49b14a54b --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/AsyncMarkRecommendationSucceeded.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_markrecommendationsucceeded_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1.MarkRecommendationSucceededRequest; +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; + +public class AsyncMarkRecommendationSucceeded { + + public static void main(String[] args) throws Exception { + asyncMarkRecommendationSucceeded(); + } + + public static void asyncMarkRecommendationSucceeded() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationSucceededRequest request = + MarkRecommendationSucceededRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + ApiFuture future = + recommenderClient.markRecommendationSucceededCallable().futureCall(request); + // Do something. + Recommendation response = future.get(); + } + } +} +// [END recommender_v1_generated_recommenderclient_markrecommendationsucceeded_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceeded.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceeded.java new file mode 100644 index 000000000000..5b721f2268df --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceeded.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommenderclient_markrecommendationsucceeded_sync] +import com.google.cloud.recommender.v1.MarkRecommendationSucceededRequest; +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; + +public class SyncMarkRecommendationSucceeded { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationSucceeded(); + } + + public static void syncMarkRecommendationSucceeded() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationSucceededRequest request = + MarkRecommendationSucceededRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + Recommendation response = recommenderClient.markRecommendationSucceeded(request); + } + } +} +// [END recommender_v1_generated_recommenderclient_markrecommendationsucceeded_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededRecommendationnameMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededRecommendationnameMapstringstringString.java new file mode 100644 index 000000000000..f3ec0fb1fff2 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededRecommendationnameMapstringstringString.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.recommender.v1.samples; + +// [START +// recommender_v1_generated_recommenderclient_markrecommendationsucceeded_recommendationnamemapstringstringstring_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationSucceededRecommendationnameMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationSucceededRecommendationnameMapstringstringString(); + } + + public static void syncMarkRecommendationSucceededRecommendationnameMapstringstringString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationSucceeded(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1_generated_recommenderclient_markrecommendationsucceeded_recommendationnamemapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededStringMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededStringMapstringstringString.java new file mode 100644 index 000000000000..8dd3a0251388 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededStringMapstringstringString.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.recommender.v1.samples; + +// [START +// recommender_v1_generated_recommenderclient_markrecommendationsucceeded_stringmapstringstringstring_sync] +import com.google.cloud.recommender.v1.Recommendation; +import com.google.cloud.recommender.v1.RecommendationName; +import com.google.cloud.recommender.v1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationSucceededStringMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationSucceededStringMapstringstringString(); + } + + public static void syncMarkRecommendationSucceededStringMapstringstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString(); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationSucceeded(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1_generated_recommenderclient_markrecommendationsucceeded_stringmapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommendersettings/getinsight/SyncGetInsight.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommendersettings/getinsight/SyncGetInsight.java new file mode 100644 index 000000000000..00bce876bc19 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/recommendersettings/getinsight/SyncGetInsight.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.recommender.v1.samples; + +// [START recommender_v1_generated_recommendersettings_getinsight_sync] +import com.google.cloud.recommender.v1.RecommenderSettings; +import java.time.Duration; + +public class SyncGetInsight { + + public static void main(String[] args) throws Exception { + syncGetInsight(); + } + + public static void syncGetInsight() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + RecommenderSettings.Builder recommenderSettingsBuilder = RecommenderSettings.newBuilder(); + recommenderSettingsBuilder + .getInsightSettings() + .setRetrySettings( + recommenderSettingsBuilder + .getInsightSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + RecommenderSettings recommenderSettings = recommenderSettingsBuilder.build(); + } +} +// [END recommender_v1_generated_recommendersettings_getinsight_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/stub/recommenderstubsettings/getinsight/SyncGetInsight.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/stub/recommenderstubsettings/getinsight/SyncGetInsight.java new file mode 100644 index 000000000000..3156c617efbd --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1/stub/recommenderstubsettings/getinsight/SyncGetInsight.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.recommender.v1.stub.samples; + +// [START recommender_v1_generated_recommenderstubsettings_getinsight_sync] +import com.google.cloud.recommender.v1.stub.RecommenderStubSettings; +import java.time.Duration; + +public class SyncGetInsight { + + public static void main(String[] args) throws Exception { + syncGetInsight(); + } + + public static void syncGetInsight() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + RecommenderStubSettings.Builder recommenderSettingsBuilder = + RecommenderStubSettings.newBuilder(); + recommenderSettingsBuilder + .getInsightSettings() + .setRetrySettings( + recommenderSettingsBuilder + .getInsightSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + RecommenderStubSettings recommenderSettings = recommenderSettingsBuilder.build(); + } +} +// [END recommender_v1_generated_recommenderstubsettings_getinsight_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/create/SyncCreateSetCredentialsProvider.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..ef4471c7f456 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderSettings; +import com.google.cloud.recommender.v1beta1.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. + RecommenderSettings recommenderSettings = + RecommenderSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings); + } +} +// [END recommender_v1beta1_generated_recommenderclient_create_setcredentialsprovider_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/create/SyncCreateSetCredentialsProvider1.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..fabfc1243a80 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_create_setcredentialsprovider1_sync] +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderSettings; + +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. + RecommenderSettings recommenderSettings = + RecommenderSettings.newBuilder() + .setTransportChannelProvider( + RecommenderSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings); + } +} +// [END recommender_v1beta1_generated_recommenderclient_create_setcredentialsprovider1_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/create/SyncCreateSetEndpoint.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..238eb9fffef9 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_create_setendpoint_sync] +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderSettings; +import com.google.cloud.recommender.v1beta1.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. + RecommenderSettings recommenderSettings = + RecommenderSettings.newBuilder().setEndpoint(myEndpoint).build(); + RecommenderClient recommenderClient = RecommenderClient.create(recommenderSettings); + } +} +// [END recommender_v1beta1_generated_recommenderclient_create_setendpoint_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/AsyncGetInsight.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/AsyncGetInsight.java new file mode 100644 index 000000000000..0a9113d246a5 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/AsyncGetInsight.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getinsight_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.GetInsightRequest; +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class AsyncGetInsight { + + public static void main(String[] args) throws Exception { + asyncGetInsight(); + } + + public static void asyncGetInsight() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetInsightRequest request = + GetInsightRequest.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .build(); + ApiFuture future = recommenderClient.getInsightCallable().futureCall(request); + // Do something. + Insight response = future.get(); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getinsight_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/SyncGetInsight.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/SyncGetInsight.java new file mode 100644 index 000000000000..e00236c3209d --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/SyncGetInsight.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getinsight_sync] +import com.google.cloud.recommender.v1beta1.GetInsightRequest; +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncGetInsight { + + public static void main(String[] args) throws Exception { + syncGetInsight(); + } + + public static void syncGetInsight() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetInsightRequest request = + GetInsightRequest.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .build(); + Insight response = recommenderClient.getInsight(request); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getinsight_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/SyncGetInsightInsightname.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/SyncGetInsightInsightname.java new file mode 100644 index 000000000000..0e3d54193b08 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/SyncGetInsightInsightname.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getinsight_insightname_sync] +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncGetInsightInsightname { + + public static void main(String[] args) throws Exception { + syncGetInsightInsightname(); + } + + public static void syncGetInsightInsightname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + Insight response = recommenderClient.getInsight(name); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getinsight_insightname_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/SyncGetInsightString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/SyncGetInsightString.java new file mode 100644 index 000000000000..164bac05301b --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsight/SyncGetInsightString.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getinsight_string_sync] +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncGetInsightString { + + public static void main(String[] args) throws Exception { + syncGetInsightString(); + } + + public static void syncGetInsightString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString(); + Insight response = recommenderClient.getInsight(name); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getinsight_string_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/AsyncGetInsightTypeConfig.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/AsyncGetInsightTypeConfig.java new file mode 100644 index 000000000000..0145fb1643dd --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/AsyncGetInsightTypeConfig.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getinsighttypeconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest; +import com.google.cloud.recommender.v1beta1.InsightTypeConfig; +import com.google.cloud.recommender.v1beta1.InsightTypeConfigName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class AsyncGetInsightTypeConfig { + + public static void main(String[] args) throws Exception { + asyncGetInsightTypeConfig(); + } + + public static void asyncGetInsightTypeConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetInsightTypeConfigRequest request = + GetInsightTypeConfigRequest.newBuilder() + .setName( + InsightTypeConfigName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .build(); + ApiFuture future = + recommenderClient.getInsightTypeConfigCallable().futureCall(request); + // Do something. + InsightTypeConfig response = future.get(); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getinsighttypeconfig_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/SyncGetInsightTypeConfig.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/SyncGetInsightTypeConfig.java new file mode 100644 index 000000000000..9e45a8279601 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/SyncGetInsightTypeConfig.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getinsighttypeconfig_sync] +import com.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest; +import com.google.cloud.recommender.v1beta1.InsightTypeConfig; +import com.google.cloud.recommender.v1beta1.InsightTypeConfigName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncGetInsightTypeConfig { + + public static void main(String[] args) throws Exception { + syncGetInsightTypeConfig(); + } + + public static void syncGetInsightTypeConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetInsightTypeConfigRequest request = + GetInsightTypeConfigRequest.newBuilder() + .setName( + InsightTypeConfigName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .build(); + InsightTypeConfig response = recommenderClient.getInsightTypeConfig(request); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getinsighttypeconfig_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/SyncGetInsightTypeConfigInsighttypeconfigname.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/SyncGetInsightTypeConfigInsighttypeconfigname.java new file mode 100644 index 000000000000..59bd98b7efd5 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/SyncGetInsightTypeConfigInsighttypeconfigname.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_getinsighttypeconfig_insighttypeconfigname_sync] +import com.google.cloud.recommender.v1beta1.InsightTypeConfig; +import com.google.cloud.recommender.v1beta1.InsightTypeConfigName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncGetInsightTypeConfigInsighttypeconfigname { + + public static void main(String[] args) throws Exception { + syncGetInsightTypeConfigInsighttypeconfigname(); + } + + public static void syncGetInsightTypeConfigInsighttypeconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + InsightTypeConfigName name = + InsightTypeConfigName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]"); + InsightTypeConfig response = recommenderClient.getInsightTypeConfig(name); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_getinsighttypeconfig_insighttypeconfigname_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/SyncGetInsightTypeConfigString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/SyncGetInsightTypeConfigString.java new file mode 100644 index 000000000000..d296184c7421 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getinsighttypeconfig/SyncGetInsightTypeConfigString.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getinsighttypeconfig_string_sync] +import com.google.cloud.recommender.v1beta1.InsightTypeConfig; +import com.google.cloud.recommender.v1beta1.InsightTypeConfigName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncGetInsightTypeConfigString { + + public static void main(String[] args) throws Exception { + syncGetInsightTypeConfigString(); + } + + public static void syncGetInsightTypeConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + InsightTypeConfigName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString(); + InsightTypeConfig response = recommenderClient.getInsightTypeConfig(name); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getinsighttypeconfig_string_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/AsyncGetRecommendation.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/AsyncGetRecommendation.java new file mode 100644 index 000000000000..92d96d65d5c7 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/AsyncGetRecommendation.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getrecommendation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.GetRecommendationRequest; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class AsyncGetRecommendation { + + public static void main(String[] args) throws Exception { + asyncGetRecommendation(); + } + + public static void asyncGetRecommendation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetRecommendationRequest request = + GetRecommendationRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .build(); + ApiFuture future = + recommenderClient.getRecommendationCallable().futureCall(request); + // Do something. + Recommendation response = future.get(); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getrecommendation_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/SyncGetRecommendation.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/SyncGetRecommendation.java new file mode 100644 index 000000000000..cd9ccf15220e --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/SyncGetRecommendation.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getrecommendation_sync] +import com.google.cloud.recommender.v1beta1.GetRecommendationRequest; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncGetRecommendation { + + public static void main(String[] args) throws Exception { + syncGetRecommendation(); + } + + public static void syncGetRecommendation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetRecommendationRequest request = + GetRecommendationRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .build(); + Recommendation response = recommenderClient.getRecommendation(request); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getrecommendation_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/SyncGetRecommendationRecommendationname.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/SyncGetRecommendationRecommendationname.java new file mode 100644 index 000000000000..e1ae6aa970bf --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/SyncGetRecommendationRecommendationname.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getrecommendation_recommendationname_sync] +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncGetRecommendationRecommendationname { + + public static void main(String[] args) throws Exception { + syncGetRecommendationRecommendationname(); + } + + public static void syncGetRecommendationRecommendationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Recommendation response = recommenderClient.getRecommendation(name); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getrecommendation_recommendationname_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/SyncGetRecommendationString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/SyncGetRecommendationString.java new file mode 100644 index 000000000000..e93cd4a59330 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommendation/SyncGetRecommendationString.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getrecommendation_string_sync] +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncGetRecommendationString { + + public static void main(String[] args) throws Exception { + syncGetRecommendationString(); + } + + public static void syncGetRecommendationString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString(); + Recommendation response = recommenderClient.getRecommendation(name); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getrecommendation_string_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/AsyncGetRecommenderConfig.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/AsyncGetRecommenderConfig.java new file mode 100644 index 000000000000..3efdc42a88f9 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/AsyncGetRecommenderConfig.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getrecommenderconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderConfig; +import com.google.cloud.recommender.v1beta1.RecommenderConfigName; + +public class AsyncGetRecommenderConfig { + + public static void main(String[] args) throws Exception { + asyncGetRecommenderConfig(); + } + + public static void asyncGetRecommenderConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetRecommenderConfigRequest request = + GetRecommenderConfigRequest.newBuilder() + .setName( + RecommenderConfigName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .build(); + ApiFuture future = + recommenderClient.getRecommenderConfigCallable().futureCall(request); + // Do something. + RecommenderConfig response = future.get(); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getrecommenderconfig_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/SyncGetRecommenderConfig.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/SyncGetRecommenderConfig.java new file mode 100644 index 000000000000..c503dfc5ed2e --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/SyncGetRecommenderConfig.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getrecommenderconfig_sync] +import com.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderConfig; +import com.google.cloud.recommender.v1beta1.RecommenderConfigName; + +public class SyncGetRecommenderConfig { + + public static void main(String[] args) throws Exception { + syncGetRecommenderConfig(); + } + + public static void syncGetRecommenderConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + GetRecommenderConfigRequest request = + GetRecommenderConfigRequest.newBuilder() + .setName( + RecommenderConfigName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .build(); + RecommenderConfig response = recommenderClient.getRecommenderConfig(request); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getrecommenderconfig_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/SyncGetRecommenderConfigRecommenderconfigname.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/SyncGetRecommenderConfigRecommenderconfigname.java new file mode 100644 index 000000000000..eb0268aded55 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/SyncGetRecommenderConfigRecommenderconfigname.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_getrecommenderconfig_recommenderconfigname_sync] +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderConfig; +import com.google.cloud.recommender.v1beta1.RecommenderConfigName; + +public class SyncGetRecommenderConfigRecommenderconfigname { + + public static void main(String[] args) throws Exception { + syncGetRecommenderConfigRecommenderconfigname(); + } + + public static void syncGetRecommenderConfigRecommenderconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommenderConfigName name = + RecommenderConfigName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + RecommenderConfig response = recommenderClient.getRecommenderConfig(name); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_getrecommenderconfig_recommenderconfigname_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/SyncGetRecommenderConfigString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/SyncGetRecommenderConfigString.java new file mode 100644 index 000000000000..73441451c1c5 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/getrecommenderconfig/SyncGetRecommenderConfigString.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_getrecommenderconfig_string_sync] +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderConfig; +import com.google.cloud.recommender.v1beta1.RecommenderConfigName; + +public class SyncGetRecommenderConfigString { + + public static void main(String[] args) throws Exception { + syncGetRecommenderConfigString(); + } + + public static void syncGetRecommenderConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + RecommenderConfigName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString(); + RecommenderConfig response = recommenderClient.getRecommenderConfig(name); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_getrecommenderconfig_string_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/AsyncListInsights.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/AsyncListInsights.java new file mode 100644 index 000000000000..870ddb173d45 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/AsyncListInsights.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_listinsights_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightTypeName; +import com.google.cloud.recommender.v1beta1.ListInsightsRequest; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class AsyncListInsights { + + public static void main(String[] args) throws Exception { + asyncListInsights(); + } + + public static void asyncListInsights() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListInsightsRequest request = + ListInsightsRequest.newBuilder() + .setParent( + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = recommenderClient.listInsightsPagedCallable().futureCall(request); + // Do something. + for (Insight element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_listinsights_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/AsyncListInsightsPaged.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/AsyncListInsightsPaged.java new file mode 100644 index 000000000000..a18a537d30d6 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/AsyncListInsightsPaged.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_listinsights_paged_async] +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightTypeName; +import com.google.cloud.recommender.v1beta1.ListInsightsRequest; +import com.google.cloud.recommender.v1beta1.ListInsightsResponse; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.common.base.Strings; + +public class AsyncListInsightsPaged { + + public static void main(String[] args) throws Exception { + asyncListInsightsPaged(); + } + + public static void asyncListInsightsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListInsightsRequest request = + ListInsightsRequest.newBuilder() + .setParent( + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListInsightsResponse response = recommenderClient.listInsightsCallable().call(request); + for (Insight element : response.getInsightsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_listinsights_paged_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/SyncListInsights.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/SyncListInsights.java new file mode 100644 index 000000000000..5f4ded8661b0 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/SyncListInsights.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_listinsights_sync] +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightTypeName; +import com.google.cloud.recommender.v1beta1.ListInsightsRequest; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncListInsights { + + public static void main(String[] args) throws Exception { + syncListInsights(); + } + + public static void syncListInsights() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListInsightsRequest request = + ListInsightsRequest.newBuilder() + .setParent( + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Insight element : recommenderClient.listInsights(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_listinsights_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/SyncListInsightsInsighttypename.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/SyncListInsightsInsighttypename.java new file mode 100644 index 000000000000..019b48c6715b --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/SyncListInsightsInsighttypename.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_listinsights_insighttypename_sync] +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightTypeName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncListInsightsInsighttypename { + + public static void main(String[] args) throws Exception { + syncListInsightsInsighttypename(); + } + + public static void syncListInsightsInsighttypename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + InsightTypeName parent = + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]"); + for (Insight element : recommenderClient.listInsights(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_listinsights_insighttypename_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/SyncListInsightsString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/SyncListInsightsString.java new file mode 100644 index 000000000000..b090bdcb5dfc --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listinsights/SyncListInsightsString.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_listinsights_string_sync] +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightTypeName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; + +public class SyncListInsightsString { + + public static void main(String[] args) throws Exception { + syncListInsightsString(); + } + + public static void syncListInsightsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String parent = + InsightTypeName.ofProjectLocationInsightTypeName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]") + .toString(); + for (Insight element : recommenderClient.listInsights(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_listinsights_string_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/AsyncListRecommendations.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/AsyncListRecommendations.java new file mode 100644 index 000000000000..c3feb91265d7 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/AsyncListRecommendations.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_listrecommendations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.ListRecommendationsRequest; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderName; + +public class AsyncListRecommendations { + + public static void main(String[] args) throws Exception { + asyncListRecommendations(); + } + + public static void asyncListRecommendations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListRecommendationsRequest request = + ListRecommendationsRequest.newBuilder() + .setParent( + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + recommenderClient.listRecommendationsPagedCallable().futureCall(request); + // Do something. + for (Recommendation element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_listrecommendations_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/AsyncListRecommendationsPaged.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/AsyncListRecommendationsPaged.java new file mode 100644 index 000000000000..2598b5efc70b --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/AsyncListRecommendationsPaged.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_listrecommendations_paged_async] +import com.google.cloud.recommender.v1beta1.ListRecommendationsRequest; +import com.google.cloud.recommender.v1beta1.ListRecommendationsResponse; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderName; +import com.google.common.base.Strings; + +public class AsyncListRecommendationsPaged { + + public static void main(String[] args) throws Exception { + asyncListRecommendationsPaged(); + } + + public static void asyncListRecommendationsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListRecommendationsRequest request = + ListRecommendationsRequest.newBuilder() + .setParent( + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListRecommendationsResponse response = + recommenderClient.listRecommendationsCallable().call(request); + for (Recommendation element : response.getRecommendationsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_listrecommendations_paged_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/SyncListRecommendations.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/SyncListRecommendations.java new file mode 100644 index 000000000000..2ceeadc57d54 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/SyncListRecommendations.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_listrecommendations_sync] +import com.google.cloud.recommender.v1beta1.ListRecommendationsRequest; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderName; + +public class SyncListRecommendations { + + public static void main(String[] args) throws Exception { + syncListRecommendations(); + } + + public static void syncListRecommendations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + ListRecommendationsRequest request = + ListRecommendationsRequest.newBuilder() + .setParent( + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Recommendation element : recommenderClient.listRecommendations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_listrecommendations_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/SyncListRecommendationsRecommendernameString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/SyncListRecommendationsRecommendernameString.java new file mode 100644 index 000000000000..0a3b905c63cf --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/SyncListRecommendationsRecommendernameString.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_listrecommendations_recommendernamestring_sync] +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderName; + +public class SyncListRecommendationsRecommendernameString { + + public static void main(String[] args) throws Exception { + syncListRecommendationsRecommendernameString(); + } + + public static void syncListRecommendationsRecommendernameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommenderName parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]"); + String filter = "filter-1274492040"; + for (Recommendation element : + recommenderClient.listRecommendations(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_listrecommendations_recommendernamestring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/SyncListRecommendationsStringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/SyncListRecommendationsStringString.java new file mode 100644 index 000000000000..2c8779374a88 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/listrecommendations/SyncListRecommendationsStringString.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_listrecommendations_stringstring_sync] +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderName; + +public class SyncListRecommendationsStringString { + + public static void main(String[] args) throws Exception { + syncListRecommendationsStringString(); + } + + public static void syncListRecommendationsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String parent = + RecommenderName.ofProjectLocationRecommenderName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + .toString(); + String filter = "filter-1274492040"; + for (Recommendation element : + recommenderClient.listRecommendations(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_listrecommendations_stringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/AsyncMarkInsightAccepted.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/AsyncMarkInsightAccepted.java new file mode 100644 index 000000000000..212e98952da8 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/AsyncMarkInsightAccepted.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_markinsightaccepted_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightName; +import com.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; + +public class AsyncMarkInsightAccepted { + + public static void main(String[] args) throws Exception { + asyncMarkInsightAccepted(); + } + + public static void asyncMarkInsightAccepted() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkInsightAcceptedRequest request = + MarkInsightAcceptedRequest.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + ApiFuture future = + recommenderClient.markInsightAcceptedCallable().futureCall(request); + // Do something. + Insight response = future.get(); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_markinsightaccepted_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/SyncMarkInsightAccepted.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/SyncMarkInsightAccepted.java new file mode 100644 index 000000000000..41dbabe38099 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/SyncMarkInsightAccepted.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_markinsightaccepted_sync] +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightName; +import com.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; + +public class SyncMarkInsightAccepted { + + public static void main(String[] args) throws Exception { + syncMarkInsightAccepted(); + } + + public static void syncMarkInsightAccepted() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkInsightAcceptedRequest request = + MarkInsightAcceptedRequest.newBuilder() + .setName( + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + Insight response = recommenderClient.markInsightAccepted(request); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_markinsightaccepted_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedInsightnameMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedInsightnameMapstringstringString.java new file mode 100644 index 000000000000..5901c0c32d48 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedInsightnameMapstringstringString.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_markinsightaccepted_insightnamemapstringstringstring_sync] +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkInsightAcceptedInsightnameMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkInsightAcceptedInsightnameMapstringstringString(); + } + + public static void syncMarkInsightAcceptedInsightnameMapstringstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + InsightName name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Insight response = recommenderClient.markInsightAccepted(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_markinsightaccepted_insightnamemapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedStringMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedStringMapstringstringString.java new file mode 100644 index 000000000000..5d50f59351f6 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markinsightaccepted/SyncMarkInsightAcceptedStringMapstringstringString.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_markinsightaccepted_stringmapstringstringstring_sync] +import com.google.cloud.recommender.v1beta1.Insight; +import com.google.cloud.recommender.v1beta1.InsightName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkInsightAcceptedStringMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkInsightAcceptedStringMapstringstringString(); + } + + public static void syncMarkInsightAcceptedStringMapstringstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + InsightName.ofProjectLocationInsightTypeInsightName( + "[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]") + .toString(); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Insight response = recommenderClient.markInsightAccepted(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_markinsightaccepted_stringmapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/AsyncMarkRecommendationClaimed.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/AsyncMarkRecommendationClaimed.java new file mode 100644 index 000000000000..445a3a9c2919 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/AsyncMarkRecommendationClaimed.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_markrecommendationclaimed_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; + +public class AsyncMarkRecommendationClaimed { + + public static void main(String[] args) throws Exception { + asyncMarkRecommendationClaimed(); + } + + public static void asyncMarkRecommendationClaimed() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationClaimedRequest request = + MarkRecommendationClaimedRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + ApiFuture future = + recommenderClient.markRecommendationClaimedCallable().futureCall(request); + // Do something. + Recommendation response = future.get(); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_markrecommendationclaimed_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimed.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimed.java new file mode 100644 index 000000000000..996ba9405cb8 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimed.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_markrecommendationclaimed_sync] +import com.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; + +public class SyncMarkRecommendationClaimed { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationClaimed(); + } + + public static void syncMarkRecommendationClaimed() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationClaimedRequest request = + MarkRecommendationClaimedRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + Recommendation response = recommenderClient.markRecommendationClaimed(request); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_markrecommendationclaimed_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedRecommendationnameMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedRecommendationnameMapstringstringString.java new file mode 100644 index 000000000000..b77b17f1b176 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedRecommendationnameMapstringstringString.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_markrecommendationclaimed_recommendationnamemapstringstringstring_sync] +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationClaimedRecommendationnameMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationClaimedRecommendationnameMapstringstringString(); + } + + public static void syncMarkRecommendationClaimedRecommendationnameMapstringstringString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationClaimed(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_markrecommendationclaimed_recommendationnamemapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedStringMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedStringMapstringstringString.java new file mode 100644 index 000000000000..b685889168f8 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationclaimed/SyncMarkRecommendationClaimedStringMapstringstringString.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_markrecommendationclaimed_stringmapstringstringstring_sync] +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationClaimedStringMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationClaimedStringMapstringstringString(); + } + + public static void syncMarkRecommendationClaimedStringMapstringstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString(); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationClaimed(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_markrecommendationclaimed_stringmapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/AsyncMarkRecommendationFailed.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/AsyncMarkRecommendationFailed.java new file mode 100644 index 000000000000..d1e19880554c --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/AsyncMarkRecommendationFailed.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_markrecommendationfailed_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; + +public class AsyncMarkRecommendationFailed { + + public static void main(String[] args) throws Exception { + asyncMarkRecommendationFailed(); + } + + public static void asyncMarkRecommendationFailed() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationFailedRequest request = + MarkRecommendationFailedRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + ApiFuture future = + recommenderClient.markRecommendationFailedCallable().futureCall(request); + // Do something. + Recommendation response = future.get(); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_markrecommendationfailed_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailed.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailed.java new file mode 100644 index 000000000000..047365382f72 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailed.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_markrecommendationfailed_sync] +import com.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; + +public class SyncMarkRecommendationFailed { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationFailed(); + } + + public static void syncMarkRecommendationFailed() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationFailedRequest request = + MarkRecommendationFailedRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + Recommendation response = recommenderClient.markRecommendationFailed(request); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_markrecommendationfailed_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedRecommendationnameMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedRecommendationnameMapstringstringString.java new file mode 100644 index 000000000000..6893dc0c57b0 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedRecommendationnameMapstringstringString.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_markrecommendationfailed_recommendationnamemapstringstringstring_sync] +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationFailedRecommendationnameMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationFailedRecommendationnameMapstringstringString(); + } + + public static void syncMarkRecommendationFailedRecommendationnameMapstringstringString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationFailed(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_markrecommendationfailed_recommendationnamemapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedStringMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedStringMapstringstringString.java new file mode 100644 index 000000000000..6d2f95337031 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationfailed/SyncMarkRecommendationFailedStringMapstringstringString.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_markrecommendationfailed_stringmapstringstringstring_sync] +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationFailedStringMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationFailedStringMapstringstringString(); + } + + public static void syncMarkRecommendationFailedStringMapstringstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString(); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationFailed(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_markrecommendationfailed_stringmapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/AsyncMarkRecommendationSucceeded.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/AsyncMarkRecommendationSucceeded.java new file mode 100644 index 000000000000..7868664e78a5 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/AsyncMarkRecommendationSucceeded.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_markrecommendationsucceeded_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; + +public class AsyncMarkRecommendationSucceeded { + + public static void main(String[] args) throws Exception { + asyncMarkRecommendationSucceeded(); + } + + public static void asyncMarkRecommendationSucceeded() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationSucceededRequest request = + MarkRecommendationSucceededRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + ApiFuture future = + recommenderClient.markRecommendationSucceededCallable().futureCall(request); + // Do something. + Recommendation response = future.get(); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_markrecommendationsucceeded_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceeded.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceeded.java new file mode 100644 index 000000000000..2d814f005042 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceeded.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_markrecommendationsucceeded_sync] +import com.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest; +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; + +public class SyncMarkRecommendationSucceeded { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationSucceeded(); + } + + public static void syncMarkRecommendationSucceeded() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + MarkRecommendationSucceededRequest request = + MarkRecommendationSucceededRequest.newBuilder() + .setName( + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString()) + .putAllStateMetadata(new HashMap()) + .setEtag("etag3123477") + .build(); + Recommendation response = recommenderClient.markRecommendationSucceeded(request); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_markrecommendationsucceeded_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededRecommendationnameMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededRecommendationnameMapstringstringString.java new file mode 100644 index 000000000000..d20ad46fda2d --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededRecommendationnameMapstringstringString.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_markrecommendationsucceeded_recommendationnamemapstringstringstring_sync] +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationSucceededRecommendationnameMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationSucceededRecommendationnameMapstringstringString(); + } + + public static void syncMarkRecommendationSucceededRecommendationnameMapstringstringString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommendationName name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationSucceeded(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_markrecommendationsucceeded_recommendationnamemapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededStringMapstringstringString.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededStringMapstringstringString.java new file mode 100644 index 000000000000..192ead2c5cfd --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/markrecommendationsucceeded/SyncMarkRecommendationSucceededStringMapstringstringString.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_markrecommendationsucceeded_stringmapstringstringstring_sync] +import com.google.cloud.recommender.v1beta1.Recommendation; +import com.google.cloud.recommender.v1beta1.RecommendationName; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncMarkRecommendationSucceededStringMapstringstringString { + + public static void main(String[] args) throws Exception { + syncMarkRecommendationSucceededStringMapstringstringString(); + } + + public static void syncMarkRecommendationSucceededStringMapstringstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + String name = + RecommendationName.ofProjectLocationRecommenderRecommendationName( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]") + .toString(); + Map stateMetadata = new HashMap<>(); + String etag = "etag3123477"; + Recommendation response = + recommenderClient.markRecommendationSucceeded(name, stateMetadata, etag); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_markrecommendationsucceeded_stringmapstringstringstring_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updateinsighttypeconfig/AsyncUpdateInsightTypeConfig.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updateinsighttypeconfig/AsyncUpdateInsightTypeConfig.java new file mode 100644 index 000000000000..23b543c5eeb1 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updateinsighttypeconfig/AsyncUpdateInsightTypeConfig.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_updateinsighttypeconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.InsightTypeConfig; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateInsightTypeConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateInsightTypeConfig(); + } + + public static void asyncUpdateInsightTypeConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + UpdateInsightTypeConfigRequest request = + UpdateInsightTypeConfigRequest.newBuilder() + .setInsightTypeConfig(InsightTypeConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setValidateOnly(true) + .build(); + ApiFuture future = + recommenderClient.updateInsightTypeConfigCallable().futureCall(request); + // Do something. + InsightTypeConfig response = future.get(); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_updateinsighttypeconfig_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updateinsighttypeconfig/SyncUpdateInsightTypeConfig.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updateinsighttypeconfig/SyncUpdateInsightTypeConfig.java new file mode 100644 index 000000000000..b29166c2152c --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updateinsighttypeconfig/SyncUpdateInsightTypeConfig.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_updateinsighttypeconfig_sync] +import com.google.cloud.recommender.v1beta1.InsightTypeConfig; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInsightTypeConfig { + + public static void main(String[] args) throws Exception { + syncUpdateInsightTypeConfig(); + } + + public static void syncUpdateInsightTypeConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + UpdateInsightTypeConfigRequest request = + UpdateInsightTypeConfigRequest.newBuilder() + .setInsightTypeConfig(InsightTypeConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setValidateOnly(true) + .build(); + InsightTypeConfig response = recommenderClient.updateInsightTypeConfig(request); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_updateinsighttypeconfig_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updateinsighttypeconfig/SyncUpdateInsightTypeConfigInsighttypeconfigFieldmask.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updateinsighttypeconfig/SyncUpdateInsightTypeConfigInsighttypeconfigFieldmask.java new file mode 100644 index 000000000000..ea24f784a86e --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updateinsighttypeconfig/SyncUpdateInsightTypeConfigInsighttypeconfigFieldmask.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_updateinsighttypeconfig_insighttypeconfigfieldmask_sync] +import com.google.cloud.recommender.v1beta1.InsightTypeConfig; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInsightTypeConfigInsighttypeconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateInsightTypeConfigInsighttypeconfigFieldmask(); + } + + public static void syncUpdateInsightTypeConfigInsighttypeconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + InsightTypeConfig insightTypeConfig = InsightTypeConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + InsightTypeConfig response = + recommenderClient.updateInsightTypeConfig(insightTypeConfig, updateMask); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_updateinsighttypeconfig_insighttypeconfigfieldmask_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updaterecommenderconfig/AsyncUpdateRecommenderConfig.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updaterecommenderconfig/AsyncUpdateRecommenderConfig.java new file mode 100644 index 000000000000..d9d17a3efaa8 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updaterecommenderconfig/AsyncUpdateRecommenderConfig.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_updaterecommenderconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderConfig; +import com.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateRecommenderConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateRecommenderConfig(); + } + + public static void asyncUpdateRecommenderConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + UpdateRecommenderConfigRequest request = + UpdateRecommenderConfigRequest.newBuilder() + .setRecommenderConfig(RecommenderConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setValidateOnly(true) + .build(); + ApiFuture future = + recommenderClient.updateRecommenderConfigCallable().futureCall(request); + // Do something. + RecommenderConfig response = future.get(); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_updaterecommenderconfig_async] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updaterecommenderconfig/SyncUpdateRecommenderConfig.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updaterecommenderconfig/SyncUpdateRecommenderConfig.java new file mode 100644 index 000000000000..c51e034f2cb6 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updaterecommenderconfig/SyncUpdateRecommenderConfig.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommenderclient_updaterecommenderconfig_sync] +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderConfig; +import com.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateRecommenderConfig { + + public static void main(String[] args) throws Exception { + syncUpdateRecommenderConfig(); + } + + public static void syncUpdateRecommenderConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + UpdateRecommenderConfigRequest request = + UpdateRecommenderConfigRequest.newBuilder() + .setRecommenderConfig(RecommenderConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setValidateOnly(true) + .build(); + RecommenderConfig response = recommenderClient.updateRecommenderConfig(request); + } + } +} +// [END recommender_v1beta1_generated_recommenderclient_updaterecommenderconfig_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updaterecommenderconfig/SyncUpdateRecommenderConfigRecommenderconfigFieldmask.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updaterecommenderconfig/SyncUpdateRecommenderConfigRecommenderconfigFieldmask.java new file mode 100644 index 000000000000..72c51e104d68 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommenderclient/updaterecommenderconfig/SyncUpdateRecommenderConfigRecommenderconfigFieldmask.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.recommender.v1beta1.samples; + +// [START +// recommender_v1beta1_generated_recommenderclient_updaterecommenderconfig_recommenderconfigfieldmask_sync] +import com.google.cloud.recommender.v1beta1.RecommenderClient; +import com.google.cloud.recommender.v1beta1.RecommenderConfig; +import com.google.protobuf.FieldMask; + +public class SyncUpdateRecommenderConfigRecommenderconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateRecommenderConfigRecommenderconfigFieldmask(); + } + + public static void syncUpdateRecommenderConfigRecommenderconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RecommenderClient recommenderClient = RecommenderClient.create()) { + RecommenderConfig recommenderConfig = RecommenderConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + RecommenderConfig response = + recommenderClient.updateRecommenderConfig(recommenderConfig, updateMask); + } + } +} +// [END +// recommender_v1beta1_generated_recommenderclient_updaterecommenderconfig_recommenderconfigfieldmask_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommendersettings/getinsight/SyncGetInsight.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommendersettings/getinsight/SyncGetInsight.java new file mode 100644 index 000000000000..8d3d13fd39a2 --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/recommendersettings/getinsight/SyncGetInsight.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.recommender.v1beta1.samples; + +// [START recommender_v1beta1_generated_recommendersettings_getinsight_sync] +import com.google.cloud.recommender.v1beta1.RecommenderSettings; +import java.time.Duration; + +public class SyncGetInsight { + + public static void main(String[] args) throws Exception { + syncGetInsight(); + } + + public static void syncGetInsight() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + RecommenderSettings.Builder recommenderSettingsBuilder = RecommenderSettings.newBuilder(); + recommenderSettingsBuilder + .getInsightSettings() + .setRetrySettings( + recommenderSettingsBuilder + .getInsightSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + RecommenderSettings recommenderSettings = recommenderSettingsBuilder.build(); + } +} +// [END recommender_v1beta1_generated_recommendersettings_getinsight_sync] diff --git a/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/stub/recommenderstubsettings/getinsight/SyncGetInsight.java b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/stub/recommenderstubsettings/getinsight/SyncGetInsight.java new file mode 100644 index 000000000000..9194e90466dd --- /dev/null +++ b/java-recommender/samples/snippets/generated/com/google/cloud/recommender/v1beta1/stub/recommenderstubsettings/getinsight/SyncGetInsight.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.recommender.v1beta1.stub.samples; + +// [START recommender_v1beta1_generated_recommenderstubsettings_getinsight_sync] +import com.google.cloud.recommender.v1beta1.stub.RecommenderStubSettings; +import java.time.Duration; + +public class SyncGetInsight { + + public static void main(String[] args) throws Exception { + syncGetInsight(); + } + + public static void syncGetInsight() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + RecommenderStubSettings.Builder recommenderSettingsBuilder = + RecommenderStubSettings.newBuilder(); + recommenderSettingsBuilder + .getInsightSettings() + .setRetrySettings( + recommenderSettingsBuilder + .getInsightSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + RecommenderStubSettings recommenderSettings = recommenderSettingsBuilder.build(); + } +} +// [END recommender_v1beta1_generated_recommenderstubsettings_getinsight_sync]