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

com.google.cloud.dialogflow.v2beta1.stub.HttpJsonConversationsStub Maven / Gradle / Ivy

There is a newer version: 4.59.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.dialogflow.v2beta1.stub;

import static com.google.cloud.dialogflow.v2beta1.ConversationsClient.ListConversationsPagedResponse;
import static com.google.cloud.dialogflow.v2beta1.ConversationsClient.ListLocationsPagedResponse;
import static com.google.cloud.dialogflow.v2beta1.ConversationsClient.ListMessagesPagedResponse;

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.dialogflow.v2beta1.BatchCreateMessagesRequest;
import com.google.cloud.dialogflow.v2beta1.BatchCreateMessagesResponse;
import com.google.cloud.dialogflow.v2beta1.CompleteConversationRequest;
import com.google.cloud.dialogflow.v2beta1.Conversation;
import com.google.cloud.dialogflow.v2beta1.CreateConversationRequest;
import com.google.cloud.dialogflow.v2beta1.GenerateStatelessSummaryRequest;
import com.google.cloud.dialogflow.v2beta1.GenerateStatelessSummaryResponse;
import com.google.cloud.dialogflow.v2beta1.GetConversationRequest;
import com.google.cloud.dialogflow.v2beta1.ListConversationsRequest;
import com.google.cloud.dialogflow.v2beta1.ListConversationsResponse;
import com.google.cloud.dialogflow.v2beta1.ListMessagesRequest;
import com.google.cloud.dialogflow.v2beta1.ListMessagesResponse;
import com.google.cloud.dialogflow.v2beta1.SearchKnowledgeRequest;
import com.google.cloud.dialogflow.v2beta1.SearchKnowledgeResponse;
import com.google.cloud.dialogflow.v2beta1.SuggestConversationSummaryRequest;
import com.google.cloud.dialogflow.v2beta1.SuggestConversationSummaryResponse;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
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 Conversations service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @BetaApi @Generated("by gapic-generator-java") public class HttpJsonConversationsStub extends ConversationsStub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); private static final ApiMethodDescriptor createConversationMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.v2beta1.Conversations/CreateConversation") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2beta1/{parent=projects/*}/conversations", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/conversations") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam( fields, "conversationId", request.getConversationId()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("conversation", request.getConversation(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Conversation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listConversationsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.v2beta1.Conversations/ListConversations") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2beta1/{parent=projects/*}/conversations", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/conversations") .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(ListConversationsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getConversationMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.v2beta1.Conversations/GetConversation") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2beta1/{name=projects/*/conversations/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths("/v2beta1/{name=projects/*/locations/*/conversations/*}") .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(Conversation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor completeConversationMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.dialogflow.v2beta1.Conversations/CompleteConversation") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2beta1/{name=projects/*/conversations/*}:complete", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v2beta1/{name=projects/*/locations/*/conversations/*}:complete") .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(Conversation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor batchCreateMessagesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.dialogflow.v2beta1.Conversations/BatchCreateMessages") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2beta1/{parent=projects/*/conversations/*}/messages:batchCreate", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths( "/v2beta1/{parent=projects/*/locations/*/conversations/*}/messages:batchCreate") .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(BatchCreateMessagesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listMessagesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.v2beta1.Conversations/ListMessages") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2beta1/{parent=projects/*/conversations/*}/messages", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths( "/v2beta1/{parent=projects/*/locations/*/conversations/*}/messages") .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(ListMessagesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor< SuggestConversationSummaryRequest, SuggestConversationSummaryResponse> suggestConversationSummaryMethodDescriptor = ApiMethodDescriptor .newBuilder() .setFullMethodName( "google.cloud.dialogflow.v2beta1.Conversations/SuggestConversationSummary") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2beta1/{conversation=projects/*/conversations/*}/suggestions:suggestConversationSummary", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "conversation", request.getConversation()); return fields; }) .setAdditionalPaths( "/v2beta1/{conversation=projects/*/locations/*/conversations/*}/suggestions:suggestConversationSummary") .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().clearConversation().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(SuggestConversationSummaryResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor< GenerateStatelessSummaryRequest, GenerateStatelessSummaryResponse> generateStatelessSummaryMethodDescriptor = ApiMethodDescriptor .newBuilder() .setFullMethodName( "google.cloud.dialogflow.v2beta1.Conversations/GenerateStatelessSummary") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2beta1/{statelessConversation.parent=projects/*}/suggestions:generateStatelessSummary", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "statelessConversation.parent", request.getStatelessConversation().getParent()); return fields; }) .setAdditionalPaths( "/v2beta1/{statelessConversation.parent=projects/*/locations/*}/suggestions:generateStatelessSummary") .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().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(GenerateStatelessSummaryResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor searchKnowledgeMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.v2beta1.Conversations/SearchKnowledge") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2beta1/{parent=projects/*}/suggestions:searchKnowledge", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "conversation", request.getConversation()); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths( "/v2beta1/{parent=projects/*/locations/*}/suggestions:searchKnowledge", "/v2beta1/{conversation=projects/*/conversations/*}/suggestions:searchKnowledge", "/v2beta1/{conversation=projects/*/locations/*/conversations/*}/suggestions:searchKnowledge") .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().clearConversation().clearParent().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(SearchKnowledgeResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listLocationsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.location.Locations/ListLocations") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2beta1/{name=projects/*}/locations", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); 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(ListLocationsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getLocationMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.location.Locations/GetLocation") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2beta1/{name=projects/*/locations/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); 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(Location.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private final UnaryCallable createConversationCallable; private final UnaryCallable listConversationsCallable; private final UnaryCallable listConversationsPagedCallable; private final UnaryCallable getConversationCallable; private final UnaryCallable completeConversationCallable; private final UnaryCallable batchCreateMessagesCallable; private final UnaryCallable listMessagesCallable; private final UnaryCallable listMessagesPagedCallable; private final UnaryCallable suggestConversationSummaryCallable; private final UnaryCallable generateStatelessSummaryCallable; private final UnaryCallable searchKnowledgeCallable; private final UnaryCallable listLocationsCallable; private final UnaryCallable listLocationsPagedCallable; private final UnaryCallable getLocationCallable; private final BackgroundResource backgroundResources; private final HttpJsonStubCallableFactory callableFactory; public static final HttpJsonConversationsStub create(ConversationsStubSettings settings) throws IOException { return new HttpJsonConversationsStub(settings, ClientContext.create(settings)); } public static final HttpJsonConversationsStub create(ClientContext clientContext) throws IOException { return new HttpJsonConversationsStub( ConversationsStubSettings.newHttpJsonBuilder().build(), clientContext); } public static final HttpJsonConversationsStub create( ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { return new HttpJsonConversationsStub( ConversationsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of HttpJsonConversationsStub, 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 HttpJsonConversationsStub( ConversationsStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new HttpJsonConversationsCallableFactory()); } /** * Constructs an instance of HttpJsonConversationsStub, 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 HttpJsonConversationsStub( ConversationsStubSettings settings, ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; HttpJsonCallSettings createConversationTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createConversationMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listConversationsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listConversationsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getConversationTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getConversationMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings completeConversationTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(completeConversationMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings batchCreateMessagesTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(batchCreateMessagesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listMessagesTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listMessagesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings suggestConversationSummaryTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(suggestConversationSummaryMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("conversation", String.valueOf(request.getConversation())); return builder.build(); }) .build(); HttpJsonCallSettings generateStatelessSummaryTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(generateStatelessSummaryMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "stateless_conversation.parent", String.valueOf(request.getStatelessConversation().getParent())); return builder.build(); }) .build(); HttpJsonCallSettings searchKnowledgeTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(searchKnowledgeMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("conversation", String.valueOf(request.getConversation())); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listLocationsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listLocationsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings getLocationTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getLocationMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); this.createConversationCallable = callableFactory.createUnaryCallable( createConversationTransportSettings, settings.createConversationSettings(), clientContext); this.listConversationsCallable = callableFactory.createUnaryCallable( listConversationsTransportSettings, settings.listConversationsSettings(), clientContext); this.listConversationsPagedCallable = callableFactory.createPagedCallable( listConversationsTransportSettings, settings.listConversationsSettings(), clientContext); this.getConversationCallable = callableFactory.createUnaryCallable( getConversationTransportSettings, settings.getConversationSettings(), clientContext); this.completeConversationCallable = callableFactory.createUnaryCallable( completeConversationTransportSettings, settings.completeConversationSettings(), clientContext); this.batchCreateMessagesCallable = callableFactory.createUnaryCallable( batchCreateMessagesTransportSettings, settings.batchCreateMessagesSettings(), clientContext); this.listMessagesCallable = callableFactory.createUnaryCallable( listMessagesTransportSettings, settings.listMessagesSettings(), clientContext); this.listMessagesPagedCallable = callableFactory.createPagedCallable( listMessagesTransportSettings, settings.listMessagesSettings(), clientContext); this.suggestConversationSummaryCallable = callableFactory.createUnaryCallable( suggestConversationSummaryTransportSettings, settings.suggestConversationSummarySettings(), clientContext); this.generateStatelessSummaryCallable = callableFactory.createUnaryCallable( generateStatelessSummaryTransportSettings, settings.generateStatelessSummarySettings(), clientContext); this.searchKnowledgeCallable = callableFactory.createUnaryCallable( searchKnowledgeTransportSettings, settings.searchKnowledgeSettings(), clientContext); this.listLocationsCallable = callableFactory.createUnaryCallable( listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); this.listLocationsPagedCallable = callableFactory.createPagedCallable( listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); this.getLocationCallable = callableFactory.createUnaryCallable( getLocationTransportSettings, settings.getLocationSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } @InternalApi public static List getMethodDescriptors() { List methodDescriptors = new ArrayList<>(); methodDescriptors.add(createConversationMethodDescriptor); methodDescriptors.add(listConversationsMethodDescriptor); methodDescriptors.add(getConversationMethodDescriptor); methodDescriptors.add(completeConversationMethodDescriptor); methodDescriptors.add(batchCreateMessagesMethodDescriptor); methodDescriptors.add(listMessagesMethodDescriptor); methodDescriptors.add(suggestConversationSummaryMethodDescriptor); methodDescriptors.add(generateStatelessSummaryMethodDescriptor); methodDescriptors.add(searchKnowledgeMethodDescriptor); methodDescriptors.add(listLocationsMethodDescriptor); methodDescriptors.add(getLocationMethodDescriptor); return methodDescriptors; } @Override public UnaryCallable createConversationCallable() { return createConversationCallable; } @Override public UnaryCallable listConversationsCallable() { return listConversationsCallable; } @Override public UnaryCallable listConversationsPagedCallable() { return listConversationsPagedCallable; } @Override public UnaryCallable getConversationCallable() { return getConversationCallable; } @Override public UnaryCallable completeConversationCallable() { return completeConversationCallable; } @Override public UnaryCallable batchCreateMessagesCallable() { return batchCreateMessagesCallable; } @Override public UnaryCallable listMessagesCallable() { return listMessagesCallable; } @Override public UnaryCallable listMessagesPagedCallable() { return listMessagesPagedCallable; } @Override public UnaryCallable suggestConversationSummaryCallable() { return suggestConversationSummaryCallable; } @Override public UnaryCallable generateStatelessSummaryCallable() { return generateStatelessSummaryCallable; } @Override public UnaryCallable searchKnowledgeCallable() { return searchKnowledgeCallable; } @Override public UnaryCallable listLocationsCallable() { return listLocationsCallable; } @Override public UnaryCallable listLocationsPagedCallable() { return listLocationsPagedCallable; } @Override public UnaryCallable getLocationCallable() { return getLocationCallable; } @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