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

com.google.cloud.recommender.v1beta1.stub.GrpcRecommenderStub 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.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.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcStubCallableFactory;
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.longrunning.stub.GrpcOperationsStub;
import io.grpc.MethodDescriptor;
import io.grpc.protobuf.ProtoUtils;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;

// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
 * gRPC 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 GrpcRecommenderStub extends RecommenderStub { private static final MethodDescriptor listInsightsMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/ListInsights") .setRequestMarshaller(ProtoUtils.marshaller(ListInsightsRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListInsightsResponse.getDefaultInstance())) .build(); private static final MethodDescriptor getInsightMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/GetInsight") .setRequestMarshaller(ProtoUtils.marshaller(GetInsightRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Insight.getDefaultInstance())) .build(); private static final MethodDescriptor markInsightAcceptedMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/MarkInsightAccepted") .setRequestMarshaller( ProtoUtils.marshaller(MarkInsightAcceptedRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Insight.getDefaultInstance())) .build(); private static final MethodDescriptor listRecommendationsMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/ListRecommendations") .setRequestMarshaller( ProtoUtils.marshaller(ListRecommendationsRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListRecommendationsResponse.getDefaultInstance())) .build(); private static final MethodDescriptor getRecommendationMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/GetRecommendation") .setRequestMarshaller( ProtoUtils.marshaller(GetRecommendationRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Recommendation.getDefaultInstance())) .build(); private static final MethodDescriptor markRecommendationClaimedMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.recommender.v1beta1.Recommender/MarkRecommendationClaimed") .setRequestMarshaller( ProtoUtils.marshaller(MarkRecommendationClaimedRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Recommendation.getDefaultInstance())) .build(); private static final MethodDescriptor markRecommendationSucceededMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.recommender.v1beta1.Recommender/MarkRecommendationSucceeded") .setRequestMarshaller( ProtoUtils.marshaller(MarkRecommendationSucceededRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Recommendation.getDefaultInstance())) .build(); private static final MethodDescriptor markRecommendationFailedMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.recommender.v1beta1.Recommender/MarkRecommendationFailed") .setRequestMarshaller( ProtoUtils.marshaller(MarkRecommendationFailedRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Recommendation.getDefaultInstance())) .build(); private static final MethodDescriptor getRecommenderConfigMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.recommender.v1beta1.Recommender/GetRecommenderConfig") .setRequestMarshaller( ProtoUtils.marshaller(GetRecommenderConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(RecommenderConfig.getDefaultInstance())) .build(); private static final MethodDescriptor updateRecommenderConfigMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.recommender.v1beta1.Recommender/UpdateRecommenderConfig") .setRequestMarshaller( ProtoUtils.marshaller(UpdateRecommenderConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(RecommenderConfig.getDefaultInstance())) .build(); private static final MethodDescriptor getInsightTypeConfigMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.recommender.v1beta1.Recommender/GetInsightTypeConfig") .setRequestMarshaller( ProtoUtils.marshaller(GetInsightTypeConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(InsightTypeConfig.getDefaultInstance())) .build(); private static final MethodDescriptor updateInsightTypeConfigMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.recommender.v1beta1.Recommender/UpdateInsightTypeConfig") .setRequestMarshaller( ProtoUtils.marshaller(UpdateInsightTypeConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(InsightTypeConfig.getDefaultInstance())) .build(); private static final MethodDescriptor listRecommendersMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/ListRecommenders") .setRequestMarshaller( ProtoUtils.marshaller(ListRecommendersRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListRecommendersResponse.getDefaultInstance())) .build(); private static final MethodDescriptor listInsightTypesMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.recommender.v1beta1.Recommender/ListInsightTypes") .setRequestMarshaller( ProtoUtils.marshaller(ListInsightTypesRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListInsightTypesResponse.getDefaultInstance())) .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 GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcRecommenderStub create(RecommenderStubSettings settings) throws IOException { return new GrpcRecommenderStub(settings, ClientContext.create(settings)); } public static final GrpcRecommenderStub create(ClientContext clientContext) throws IOException { return new GrpcRecommenderStub(RecommenderStubSettings.newBuilder().build(), clientContext); } public static final GrpcRecommenderStub create( ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { return new GrpcRecommenderStub( RecommenderStubSettings.newBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of GrpcRecommenderStub, 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 GrpcRecommenderStub(RecommenderStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new GrpcRecommenderCallableFactory()); } /** * Constructs an instance of GrpcRecommenderStub, 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 GrpcRecommenderStub( RecommenderStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings listInsightsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listInsightsMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings getInsightTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getInsightMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings markInsightAcceptedTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(markInsightAcceptedMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings listRecommendationsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listRecommendationsMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings getRecommendationTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getRecommendationMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings markRecommendationClaimedTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(markRecommendationClaimedMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings markRecommendationSucceededTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(markRecommendationSucceededMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings markRecommendationFailedTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(markRecommendationFailedMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings getRecommenderConfigTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getRecommenderConfigMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings updateRecommenderConfigTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateRecommenderConfigMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "recommender_config.name", String.valueOf(request.getRecommenderConfig().getName())); return builder.build(); }) .build(); GrpcCallSettings getInsightTypeConfigTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getInsightTypeConfigMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings updateInsightTypeConfigTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateInsightTypeConfigMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "insight_type_config.name", String.valueOf(request.getInsightTypeConfig().getName())); return builder.build(); }) .build(); GrpcCallSettings listRecommendersTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listRecommendersMethodDescriptor) .build(); GrpcCallSettings listInsightTypesTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listInsightTypesMethodDescriptor) .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()); } public GrpcOperationsStub getOperationsStub() { return operationsStub; } @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); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy