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

com.google.cloud.dialogflow.cx.v3beta1.stub.GrpcAgentsStub Maven / Gradle / Ivy

Go to download

provides a new way of designing agents, taking a state machine approach to agent design. This gives you clear and explicit control over a conversation, a better end-user experience, and a better development workflow.

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.dialogflow.cx.v3beta1.stub;

import static com.google.cloud.dialogflow.cx.v3beta1.AgentsClient.ListAgentsPagedResponse;
import static com.google.cloud.dialogflow.cx.v3beta1.AgentsClient.ListLocationsPagedResponse;

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.OperationCallable;
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.dialogflow.cx.v3beta1.Agent;
import com.google.cloud.dialogflow.cx.v3beta1.AgentValidationResult;
import com.google.cloud.dialogflow.cx.v3beta1.CreateAgentRequest;
import com.google.cloud.dialogflow.cx.v3beta1.DeleteAgentRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ExportAgentRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ExportAgentResponse;
import com.google.cloud.dialogflow.cx.v3beta1.GenerativeSettings;
import com.google.cloud.dialogflow.cx.v3beta1.GetAgentRequest;
import com.google.cloud.dialogflow.cx.v3beta1.GetAgentValidationResultRequest;
import com.google.cloud.dialogflow.cx.v3beta1.GetGenerativeSettingsRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ListAgentsRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ListAgentsResponse;
import com.google.cloud.dialogflow.cx.v3beta1.RestoreAgentRequest;
import com.google.cloud.dialogflow.cx.v3beta1.UpdateAgentRequest;
import com.google.cloud.dialogflow.cx.v3beta1.UpdateGenerativeSettingsRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ValidateAgentRequest;
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.longrunning.Operation;
import com.google.longrunning.stub.GrpcOperationsStub;
import com.google.protobuf.Empty;
import com.google.protobuf.Struct;
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 Agents service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @BetaApi @Generated("by gapic-generator-java") public class GrpcAgentsStub extends AgentsStub { private static final MethodDescriptor listAgentsMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Agents/ListAgents") .setRequestMarshaller(ProtoUtils.marshaller(ListAgentsRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(ListAgentsResponse.getDefaultInstance())) .build(); private static final MethodDescriptor getAgentMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Agents/GetAgent") .setRequestMarshaller(ProtoUtils.marshaller(GetAgentRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Agent.getDefaultInstance())) .build(); private static final MethodDescriptor createAgentMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Agents/CreateAgent") .setRequestMarshaller(ProtoUtils.marshaller(CreateAgentRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Agent.getDefaultInstance())) .build(); private static final MethodDescriptor updateAgentMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Agents/UpdateAgent") .setRequestMarshaller(ProtoUtils.marshaller(UpdateAgentRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Agent.getDefaultInstance())) .build(); private static final MethodDescriptor deleteAgentMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Agents/DeleteAgent") .setRequestMarshaller(ProtoUtils.marshaller(DeleteAgentRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); private static final MethodDescriptor exportAgentMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Agents/ExportAgent") .setRequestMarshaller(ProtoUtils.marshaller(ExportAgentRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor restoreAgentMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Agents/RestoreAgent") .setRequestMarshaller(ProtoUtils.marshaller(RestoreAgentRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor validateAgentMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Agents/ValidateAgent") .setRequestMarshaller( ProtoUtils.marshaller(ValidateAgentRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(AgentValidationResult.getDefaultInstance())) .build(); private static final MethodDescriptor getAgentValidationResultMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.dialogflow.cx.v3beta1.Agents/GetAgentValidationResult") .setRequestMarshaller( ProtoUtils.marshaller(GetAgentValidationResultRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(AgentValidationResult.getDefaultInstance())) .build(); private static final MethodDescriptor getGenerativeSettingsMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Agents/GetGenerativeSettings") .setRequestMarshaller( ProtoUtils.marshaller(GetGenerativeSettingsRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(GenerativeSettings.getDefaultInstance())) .build(); private static final MethodDescriptor updateGenerativeSettingsMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.dialogflow.cx.v3beta1.Agents/UpdateGenerativeSettings") .setRequestMarshaller( ProtoUtils.marshaller(UpdateGenerativeSettingsRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(GenerativeSettings.getDefaultInstance())) .build(); private static final MethodDescriptor listLocationsMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.location.Locations/ListLocations") .setRequestMarshaller( ProtoUtils.marshaller(ListLocationsRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListLocationsResponse.getDefaultInstance())) .build(); private static final MethodDescriptor getLocationMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.location.Locations/GetLocation") .setRequestMarshaller(ProtoUtils.marshaller(GetLocationRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Location.getDefaultInstance())) .build(); private final UnaryCallable listAgentsCallable; private final UnaryCallable listAgentsPagedCallable; private final UnaryCallable getAgentCallable; private final UnaryCallable createAgentCallable; private final UnaryCallable updateAgentCallable; private final UnaryCallable deleteAgentCallable; private final UnaryCallable exportAgentCallable; private final OperationCallable exportAgentOperationCallable; private final UnaryCallable restoreAgentCallable; private final OperationCallable restoreAgentOperationCallable; private final UnaryCallable validateAgentCallable; private final UnaryCallable getAgentValidationResultCallable; private final UnaryCallable getGenerativeSettingsCallable; private final UnaryCallable updateGenerativeSettingsCallable; private final UnaryCallable listLocationsCallable; private final UnaryCallable listLocationsPagedCallable; private final UnaryCallable getLocationCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcAgentsStub create(AgentsStubSettings settings) throws IOException { return new GrpcAgentsStub(settings, ClientContext.create(settings)); } public static final GrpcAgentsStub create(ClientContext clientContext) throws IOException { return new GrpcAgentsStub(AgentsStubSettings.newBuilder().build(), clientContext); } public static final GrpcAgentsStub create( ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { return new GrpcAgentsStub( AgentsStubSettings.newBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of GrpcAgentsStub, 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 GrpcAgentsStub(AgentsStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new GrpcAgentsCallableFactory()); } /** * Constructs an instance of GrpcAgentsStub, 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 GrpcAgentsStub( AgentsStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings listAgentsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listAgentsMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings getAgentTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getAgentMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings createAgentTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createAgentMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings updateAgentTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateAgentMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("agent.name", String.valueOf(request.getAgent().getName())); return builder.build(); }) .build(); GrpcCallSettings deleteAgentTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteAgentMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings exportAgentTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(exportAgentMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings restoreAgentTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(restoreAgentMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings validateAgentTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(validateAgentMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings getAgentValidationResultTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getAgentValidationResultMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings getGenerativeSettingsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getGenerativeSettingsMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings updateGenerativeSettingsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateGenerativeSettingsMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "generative_settings.name", String.valueOf(request.getGenerativeSettings().getName())); return builder.build(); }) .build(); GrpcCallSettings listLocationsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listLocationsMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings getLocationTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getLocationMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); this.listAgentsCallable = callableFactory.createUnaryCallable( listAgentsTransportSettings, settings.listAgentsSettings(), clientContext); this.listAgentsPagedCallable = callableFactory.createPagedCallable( listAgentsTransportSettings, settings.listAgentsSettings(), clientContext); this.getAgentCallable = callableFactory.createUnaryCallable( getAgentTransportSettings, settings.getAgentSettings(), clientContext); this.createAgentCallable = callableFactory.createUnaryCallable( createAgentTransportSettings, settings.createAgentSettings(), clientContext); this.updateAgentCallable = callableFactory.createUnaryCallable( updateAgentTransportSettings, settings.updateAgentSettings(), clientContext); this.deleteAgentCallable = callableFactory.createUnaryCallable( deleteAgentTransportSettings, settings.deleteAgentSettings(), clientContext); this.exportAgentCallable = callableFactory.createUnaryCallable( exportAgentTransportSettings, settings.exportAgentSettings(), clientContext); this.exportAgentOperationCallable = callableFactory.createOperationCallable( exportAgentTransportSettings, settings.exportAgentOperationSettings(), clientContext, operationsStub); this.restoreAgentCallable = callableFactory.createUnaryCallable( restoreAgentTransportSettings, settings.restoreAgentSettings(), clientContext); this.restoreAgentOperationCallable = callableFactory.createOperationCallable( restoreAgentTransportSettings, settings.restoreAgentOperationSettings(), clientContext, operationsStub); this.validateAgentCallable = callableFactory.createUnaryCallable( validateAgentTransportSettings, settings.validateAgentSettings(), clientContext); this.getAgentValidationResultCallable = callableFactory.createUnaryCallable( getAgentValidationResultTransportSettings, settings.getAgentValidationResultSettings(), clientContext); this.getGenerativeSettingsCallable = callableFactory.createUnaryCallable( getGenerativeSettingsTransportSettings, settings.getGenerativeSettingsSettings(), clientContext); this.updateGenerativeSettingsCallable = callableFactory.createUnaryCallable( updateGenerativeSettingsTransportSettings, settings.updateGenerativeSettingsSettings(), 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()); } public GrpcOperationsStub getOperationsStub() { return operationsStub; } @Override public UnaryCallable listAgentsCallable() { return listAgentsCallable; } @Override public UnaryCallable listAgentsPagedCallable() { return listAgentsPagedCallable; } @Override public UnaryCallable getAgentCallable() { return getAgentCallable; } @Override public UnaryCallable createAgentCallable() { return createAgentCallable; } @Override public UnaryCallable updateAgentCallable() { return updateAgentCallable; } @Override public UnaryCallable deleteAgentCallable() { return deleteAgentCallable; } @Override public UnaryCallable exportAgentCallable() { return exportAgentCallable; } @Override public OperationCallable exportAgentOperationCallable() { return exportAgentOperationCallable; } @Override public UnaryCallable restoreAgentCallable() { return restoreAgentCallable; } @Override public OperationCallable restoreAgentOperationCallable() { return restoreAgentOperationCallable; } @Override public UnaryCallable validateAgentCallable() { return validateAgentCallable; } @Override public UnaryCallable getAgentValidationResultCallable() { return getAgentValidationResultCallable; } @Override public UnaryCallable getGenerativeSettingsCallable() { return getGenerativeSettingsCallable; } @Override public UnaryCallable updateGenerativeSettingsCallable() { return updateGenerativeSettingsCallable; } @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 - 2025 Weber Informatics LLC | Privacy Policy