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

com.google.cloud.retail.v2alpha.stub.HttpJsonGenerativeQuestionServiceStub Maven / Gradle / Ivy

The 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.retail.v2alpha.stub;

import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.httpjson.ApiMethodDescriptor;
import com.google.api.gax.httpjson.HttpJsonCallSettings;
import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
import com.google.api.gax.httpjson.ProtoMessageRequestFormatter;
import com.google.api.gax.httpjson.ProtoMessageResponseParser;
import com.google.api.gax.httpjson.ProtoRestSerializer;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.retail.v2alpha.BatchUpdateGenerativeQuestionConfigsRequest;
import com.google.cloud.retail.v2alpha.BatchUpdateGenerativeQuestionConfigsResponse;
import com.google.cloud.retail.v2alpha.GenerativeQuestionConfig;
import com.google.cloud.retail.v2alpha.GenerativeQuestionsFeatureConfig;
import com.google.cloud.retail.v2alpha.GetGenerativeQuestionsFeatureConfigRequest;
import com.google.cloud.retail.v2alpha.ListGenerativeQuestionConfigsRequest;
import com.google.cloud.retail.v2alpha.ListGenerativeQuestionConfigsResponse;
import com.google.cloud.retail.v2alpha.UpdateGenerativeQuestionConfigRequest;
import com.google.cloud.retail.v2alpha.UpdateGenerativeQuestionsFeatureConfigRequest;
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 GenerativeQuestionService service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @BetaApi @Generated("by gapic-generator-java") public class HttpJsonGenerativeQuestionServiceStub extends GenerativeQuestionServiceStub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); private static final ApiMethodDescriptor< UpdateGenerativeQuestionsFeatureConfigRequest, GenerativeQuestionsFeatureConfig> updateGenerativeQuestionsFeatureConfigMethodDescriptor = ApiMethodDescriptor . newBuilder() .setFullMethodName( "google.cloud.retail.v2alpha.GenerativeQuestionService/UpdateGenerativeQuestionsFeatureConfig") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter .newBuilder() .setPath( "/v2alpha/{generativeQuestionsFeatureConfig.catalog=projects/*/locations/*/catalogs/*}/generativeQuestionFeature", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "generativeQuestionsFeatureConfig.catalog", request.getGenerativeQuestionsFeatureConfig().getCatalog()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody( "generativeQuestionsFeatureConfig", request.getGenerativeQuestionsFeatureConfig(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(GenerativeQuestionsFeatureConfig.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor< GetGenerativeQuestionsFeatureConfigRequest, GenerativeQuestionsFeatureConfig> getGenerativeQuestionsFeatureConfigMethodDescriptor = ApiMethodDescriptor . newBuilder() .setFullMethodName( "google.cloud.retail.v2alpha.GenerativeQuestionService/GetGenerativeQuestionsFeatureConfig") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter .newBuilder() .setPath( "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}/generativeQuestionFeature", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "catalog", request.getCatalog()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(GenerativeQuestionsFeatureConfig.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor< ListGenerativeQuestionConfigsRequest, ListGenerativeQuestionConfigsResponse> listGenerativeQuestionConfigsMethodDescriptor = ApiMethodDescriptor . newBuilder() .setFullMethodName( "google.cloud.retail.v2alpha.GenerativeQuestionService/ListGenerativeQuestionConfigs") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/generativeQuestions", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance( ListGenerativeQuestionConfigsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor< UpdateGenerativeQuestionConfigRequest, GenerativeQuestionConfig> updateGenerativeQuestionConfigMethodDescriptor = ApiMethodDescriptor .newBuilder() .setFullMethodName( "google.cloud.retail.v2alpha.GenerativeQuestionService/UpdateGenerativeQuestionConfig") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2alpha/{generativeQuestionConfig.catalog=projects/*/locations/*/catalogs/*}/generativeQuestion", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "generativeQuestionConfig.catalog", request.getGenerativeQuestionConfig().getCatalog()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody( "generativeQuestionConfig", request.getGenerativeQuestionConfig(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(GenerativeQuestionConfig.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor< BatchUpdateGenerativeQuestionConfigsRequest, BatchUpdateGenerativeQuestionConfigsResponse> batchUpdateGenerativeQuestionConfigsMethodDescriptor = ApiMethodDescriptor . newBuilder() .setFullMethodName( "google.cloud.retail.v2alpha.GenerativeQuestionService/BatchUpdateGenerativeQuestionConfigs") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter .newBuilder() .setPath( "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/generativeQuestion:batchUpdate", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearParent().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser .newBuilder() .setDefaultInstance( BatchUpdateGenerativeQuestionConfigsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private final UnaryCallable< UpdateGenerativeQuestionsFeatureConfigRequest, GenerativeQuestionsFeatureConfig> updateGenerativeQuestionsFeatureConfigCallable; private final UnaryCallable< GetGenerativeQuestionsFeatureConfigRequest, GenerativeQuestionsFeatureConfig> getGenerativeQuestionsFeatureConfigCallable; private final UnaryCallable< ListGenerativeQuestionConfigsRequest, ListGenerativeQuestionConfigsResponse> listGenerativeQuestionConfigsCallable; private final UnaryCallable updateGenerativeQuestionConfigCallable; private final UnaryCallable< BatchUpdateGenerativeQuestionConfigsRequest, BatchUpdateGenerativeQuestionConfigsResponse> batchUpdateGenerativeQuestionConfigsCallable; private final BackgroundResource backgroundResources; private final HttpJsonStubCallableFactory callableFactory; public static final HttpJsonGenerativeQuestionServiceStub create( GenerativeQuestionServiceStubSettings settings) throws IOException { return new HttpJsonGenerativeQuestionServiceStub(settings, ClientContext.create(settings)); } public static final HttpJsonGenerativeQuestionServiceStub create(ClientContext clientContext) throws IOException { return new HttpJsonGenerativeQuestionServiceStub( GenerativeQuestionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); } public static final HttpJsonGenerativeQuestionServiceStub create( ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { return new HttpJsonGenerativeQuestionServiceStub( GenerativeQuestionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of HttpJsonGenerativeQuestionServiceStub, 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 HttpJsonGenerativeQuestionServiceStub( GenerativeQuestionServiceStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new HttpJsonGenerativeQuestionServiceCallableFactory()); } /** * Constructs an instance of HttpJsonGenerativeQuestionServiceStub, 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 HttpJsonGenerativeQuestionServiceStub( GenerativeQuestionServiceStubSettings settings, ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; HttpJsonCallSettings< UpdateGenerativeQuestionsFeatureConfigRequest, GenerativeQuestionsFeatureConfig> updateGenerativeQuestionsFeatureConfigTransportSettings = HttpJsonCallSettings . newBuilder() .setMethodDescriptor(updateGenerativeQuestionsFeatureConfigMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "generative_questions_feature_config.catalog", String.valueOf( request.getGenerativeQuestionsFeatureConfig().getCatalog())); return builder.build(); }) .build(); HttpJsonCallSettings< GetGenerativeQuestionsFeatureConfigRequest, GenerativeQuestionsFeatureConfig> getGenerativeQuestionsFeatureConfigTransportSettings = HttpJsonCallSettings . newBuilder() .setMethodDescriptor(getGenerativeQuestionsFeatureConfigMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("catalog", String.valueOf(request.getCatalog())); return builder.build(); }) .build(); HttpJsonCallSettings< ListGenerativeQuestionConfigsRequest, ListGenerativeQuestionConfigsResponse> listGenerativeQuestionConfigsTransportSettings = HttpJsonCallSettings . newBuilder() .setMethodDescriptor(listGenerativeQuestionConfigsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings updateGenerativeQuestionConfigTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(updateGenerativeQuestionConfigMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "generative_question_config.catalog", String.valueOf(request.getGenerativeQuestionConfig().getCatalog())); return builder.build(); }) .build(); HttpJsonCallSettings< BatchUpdateGenerativeQuestionConfigsRequest, BatchUpdateGenerativeQuestionConfigsResponse> batchUpdateGenerativeQuestionConfigsTransportSettings = HttpJsonCallSettings . newBuilder() .setMethodDescriptor(batchUpdateGenerativeQuestionConfigsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); this.updateGenerativeQuestionsFeatureConfigCallable = callableFactory.createUnaryCallable( updateGenerativeQuestionsFeatureConfigTransportSettings, settings.updateGenerativeQuestionsFeatureConfigSettings(), clientContext); this.getGenerativeQuestionsFeatureConfigCallable = callableFactory.createUnaryCallable( getGenerativeQuestionsFeatureConfigTransportSettings, settings.getGenerativeQuestionsFeatureConfigSettings(), clientContext); this.listGenerativeQuestionConfigsCallable = callableFactory.createUnaryCallable( listGenerativeQuestionConfigsTransportSettings, settings.listGenerativeQuestionConfigsSettings(), clientContext); this.updateGenerativeQuestionConfigCallable = callableFactory.createUnaryCallable( updateGenerativeQuestionConfigTransportSettings, settings.updateGenerativeQuestionConfigSettings(), clientContext); this.batchUpdateGenerativeQuestionConfigsCallable = callableFactory.createUnaryCallable( batchUpdateGenerativeQuestionConfigsTransportSettings, settings.batchUpdateGenerativeQuestionConfigsSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } @InternalApi public static List getMethodDescriptors() { List methodDescriptors = new ArrayList<>(); methodDescriptors.add(updateGenerativeQuestionsFeatureConfigMethodDescriptor); methodDescriptors.add(getGenerativeQuestionsFeatureConfigMethodDescriptor); methodDescriptors.add(listGenerativeQuestionConfigsMethodDescriptor); methodDescriptors.add(updateGenerativeQuestionConfigMethodDescriptor); methodDescriptors.add(batchUpdateGenerativeQuestionConfigsMethodDescriptor); return methodDescriptors; } @Override public UnaryCallable< UpdateGenerativeQuestionsFeatureConfigRequest, GenerativeQuestionsFeatureConfig> updateGenerativeQuestionsFeatureConfigCallable() { return updateGenerativeQuestionsFeatureConfigCallable; } @Override public UnaryCallable getGenerativeQuestionsFeatureConfigCallable() { return getGenerativeQuestionsFeatureConfigCallable; } @Override public UnaryCallable listGenerativeQuestionConfigsCallable() { return listGenerativeQuestionConfigsCallable; } @Override public UnaryCallable updateGenerativeQuestionConfigCallable() { return updateGenerativeQuestionConfigCallable; } @Override public UnaryCallable< BatchUpdateGenerativeQuestionConfigsRequest, BatchUpdateGenerativeQuestionConfigsResponse> batchUpdateGenerativeQuestionConfigsCallable() { return batchUpdateGenerativeQuestionConfigsCallable; } @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