com.google.cloud.recommender.v1beta1.stub.HttpJsonRecommenderStub Maven / Gradle / Ivy
Show all versions of google-cloud-recommender Show documentation
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF 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.ListInsightTypesPagedResponse;
import static com.google.cloud.recommender.v1beta1.RecommenderClient.ListInsightsPagedResponse;
import static com.google.cloud.recommender.v1beta1.RecommenderClient.ListRecommendationsPagedResponse;
import static com.google.cloud.recommender.v1beta1.RecommenderClient.ListRecommendersPagedResponse;
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.RequestParamsBuilder;
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.ListInsightTypesRequest;
import com.google.cloud.recommender.v1beta1.ListInsightTypesResponse;
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.ListRecommendersRequest;
import com.google.cloud.recommender.v1beta1.ListRecommendersResponse;
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());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
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();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
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();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearName().build(), true))
.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());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
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();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
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();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearName().build(), true))
.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();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearName().build(), true))
.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();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearName().build(), true))
.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();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
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());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody(
"recommenderConfig", request.getRecommenderConfig(), true))
.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();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
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());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody(
"insightTypeConfig", request.getInsightTypeConfig(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(InsightTypeConfig.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
listRecommendersMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.recommender.v1beta1.Recommender/ListRecommenders")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1beta1/recommenders",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(ListRecommendersResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
listInsightTypesMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.recommender.v1beta1.Recommender/ListInsightTypes")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1beta1/insightTypes",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(ListInsightTypesResponse.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 UnaryCallable
listRecommendersCallable;
private final UnaryCallable
listRecommendersPagedCallable;
private final UnaryCallable
listInsightTypesCallable;
private final UnaryCallable
listInsightTypesPagedCallable;
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)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings getInsightTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getInsightMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings markInsightAcceptedTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(markInsightAcceptedMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
listRecommendationsTransportSettings =
HttpJsonCallSettings
.newBuilder()
.setMethodDescriptor(listRecommendationsMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings
getRecommendationTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getRecommendationMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
markRecommendationClaimedTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(markRecommendationClaimedMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
markRecommendationSucceededTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(markRecommendationSucceededMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
markRecommendationFailedTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(markRecommendationFailedMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
getRecommenderConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getRecommenderConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
updateRecommenderConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateRecommenderConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(
"recommender_config.name",
String.valueOf(request.getRecommenderConfig().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
getInsightTypeConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getInsightTypeConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
updateInsightTypeConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateInsightTypeConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(
"insight_type_config.name",
String.valueOf(request.getInsightTypeConfig().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
listRecommendersTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listRecommendersMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings
listInsightTypesTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listInsightTypesMethodDescriptor)
.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.listRecommendersCallable =
callableFactory.createUnaryCallable(
listRecommendersTransportSettings, settings.listRecommendersSettings(), clientContext);
this.listRecommendersPagedCallable =
callableFactory.createPagedCallable(
listRecommendersTransportSettings, settings.listRecommendersSettings(), clientContext);
this.listInsightTypesCallable =
callableFactory.createUnaryCallable(
listInsightTypesTransportSettings, settings.listInsightTypesSettings(), clientContext);
this.listInsightTypesPagedCallable =
callableFactory.createPagedCallable(
listInsightTypesTransportSettings, settings.listInsightTypesSettings(), 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);
methodDescriptors.add(listRecommendersMethodDescriptor);
methodDescriptors.add(listInsightTypesMethodDescriptor);
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 UnaryCallable
listRecommendersCallable() {
return listRecommendersCallable;
}
@Override
public UnaryCallable
listRecommendersPagedCallable() {
return listRecommendersPagedCallable;
}
@Override
public UnaryCallable
listInsightTypesCallable() {
return listInsightTypesCallable;
}
@Override
public UnaryCallable
listInsightTypesPagedCallable() {
return listInsightTypesPagedCallable;
}
@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);
}
}