All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.cloud.recommender.v1.stub.HttpJsonRecommenderStub Maven / Gradle / Ivy

There is a newer version: 2.51.0
Show newest version
/*
 * 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.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.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.v1.GetInsightRequest;
import com.google.cloud.recommender.v1.GetInsightTypeConfigRequest;
import com.google.cloud.recommender.v1.GetRecommendationRequest;
import com.google.cloud.recommender.v1.GetRecommenderConfigRequest;
import com.google.cloud.recommender.v1.Insight;
import com.google.cloud.recommender.v1.InsightTypeConfig;
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.MarkRecommendationDismissedRequest;
import com.google.cloud.recommender.v1.MarkRecommendationFailedRequest;
import com.google.cloud.recommender.v1.MarkRecommendationSucceededRequest;
import com.google.cloud.recommender.v1.Recommendation;
import com.google.cloud.recommender.v1.RecommenderConfig;
import com.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest;
import com.google.cloud.recommender.v1.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. */ @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.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()); 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.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(); 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.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(); 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.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()); 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.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(); 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 markRecommendationDismissedMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.recommender.v1.Recommender/MarkRecommendationDismissed") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markDismissed", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markDismissed", "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markDismissed", "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markDismissed") .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 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(); 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.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(); 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.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(); 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.v1.Recommender/GetRecommenderConfig") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/locations/*/recommenders/*/config}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v1/{name=organizations/*/locations/*/recommenders/*/config}", "/v1/{name=billingAccounts/*/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.v1.Recommender/UpdateRecommenderConfig") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{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( "/v1/{recommenderConfig.name=organizations/*/locations/*/recommenders/*/config}", "/v1/{recommenderConfig.name=billingAccounts/*/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.v1.Recommender/GetInsightTypeConfig") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/locations/*/insightTypes/*/config}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v1/{name=organizations/*/locations/*/insightTypes/*/config}", "/v1/{name=billingAccounts/*/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.v1.Recommender/UpdateInsightTypeConfig") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{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( "/v1/{insightTypeConfig.name=organizations/*/locations/*/insightTypes/*/config}", "/v1/{insightTypeConfig.name=billingAccounts/*/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 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 markRecommendationDismissedCallable; 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) .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 markRecommendationDismissedTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(markRecommendationDismissedMethodDescriptor) .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(); 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.markRecommendationDismissedCallable = callableFactory.createUnaryCallable( markRecommendationDismissedTransportSettings, settings.markRecommendationDismissedSettings(), 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(markRecommendationDismissedMethodDescriptor); 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 markRecommendationDismissedCallable() { return markRecommendationDismissedCallable; } @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); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy