com.google.cloud.dialogflow.v2.stub.GrpcConversationModelsStub Maven / Gradle / Ivy
Show all versions of google-cloud-dialogflow Show documentation
/*
* 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.v2.stub;
import static com.google.cloud.dialogflow.v2.ConversationModelsClient.ListConversationModelEvaluationsPagedResponse;
import static com.google.cloud.dialogflow.v2.ConversationModelsClient.ListConversationModelsPagedResponse;
import static com.google.cloud.dialogflow.v2.ConversationModelsClient.ListLocationsPagedResponse;
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.v2.ConversationModel;
import com.google.cloud.dialogflow.v2.ConversationModelEvaluation;
import com.google.cloud.dialogflow.v2.CreateConversationModelEvaluationOperationMetadata;
import com.google.cloud.dialogflow.v2.CreateConversationModelEvaluationRequest;
import com.google.cloud.dialogflow.v2.CreateConversationModelOperationMetadata;
import com.google.cloud.dialogflow.v2.CreateConversationModelRequest;
import com.google.cloud.dialogflow.v2.DeleteConversationModelOperationMetadata;
import com.google.cloud.dialogflow.v2.DeleteConversationModelRequest;
import com.google.cloud.dialogflow.v2.DeployConversationModelOperationMetadata;
import com.google.cloud.dialogflow.v2.DeployConversationModelRequest;
import com.google.cloud.dialogflow.v2.GetConversationModelEvaluationRequest;
import com.google.cloud.dialogflow.v2.GetConversationModelRequest;
import com.google.cloud.dialogflow.v2.ListConversationModelEvaluationsRequest;
import com.google.cloud.dialogflow.v2.ListConversationModelEvaluationsResponse;
import com.google.cloud.dialogflow.v2.ListConversationModelsRequest;
import com.google.cloud.dialogflow.v2.ListConversationModelsResponse;
import com.google.cloud.dialogflow.v2.UndeployConversationModelOperationMetadata;
import com.google.cloud.dialogflow.v2.UndeployConversationModelRequest;
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 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 ConversationModels service API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@Generated("by gapic-generator-java")
public class GrpcConversationModelsStub extends ConversationModelsStub {
private static final MethodDescriptor
createConversationModelMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.dialogflow.v2.ConversationModels/CreateConversationModel")
.setRequestMarshaller(
ProtoUtils.marshaller(CreateConversationModelRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
getConversationModelMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.dialogflow.v2.ConversationModels/GetConversationModel")
.setRequestMarshaller(
ProtoUtils.marshaller(GetConversationModelRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(ConversationModel.getDefaultInstance()))
.build();
private static final MethodDescriptor<
ListConversationModelsRequest, ListConversationModelsResponse>
listConversationModelsMethodDescriptor =
MethodDescriptor
.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.dialogflow.v2.ConversationModels/ListConversationModels")
.setRequestMarshaller(
ProtoUtils.marshaller(ListConversationModelsRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListConversationModelsResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor
deleteConversationModelMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.dialogflow.v2.ConversationModels/DeleteConversationModel")
.setRequestMarshaller(
ProtoUtils.marshaller(DeleteConversationModelRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
deployConversationModelMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.dialogflow.v2.ConversationModels/DeployConversationModel")
.setRequestMarshaller(
ProtoUtils.marshaller(DeployConversationModelRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
undeployConversationModelMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.dialogflow.v2.ConversationModels/UndeployConversationModel")
.setRequestMarshaller(
ProtoUtils.marshaller(UndeployConversationModelRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor<
GetConversationModelEvaluationRequest, ConversationModelEvaluation>
getConversationModelEvaluationMethodDescriptor =
MethodDescriptor
.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.dialogflow.v2.ConversationModels/GetConversationModelEvaluation")
.setRequestMarshaller(
ProtoUtils.marshaller(GetConversationModelEvaluationRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ConversationModelEvaluation.getDefaultInstance()))
.build();
private static final MethodDescriptor<
ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsResponse>
listConversationModelEvaluationsMethodDescriptor =
MethodDescriptor
.
newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.dialogflow.v2.ConversationModels/ListConversationModelEvaluations")
.setRequestMarshaller(
ProtoUtils.marshaller(
ListConversationModelEvaluationsRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(
ListConversationModelEvaluationsResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor
createConversationModelEvaluationMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.dialogflow.v2.ConversationModels/CreateConversationModelEvaluation")
.setRequestMarshaller(
ProtoUtils.marshaller(
CreateConversationModelEvaluationRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.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
createConversationModelCallable;
private final OperationCallable<
CreateConversationModelRequest,
ConversationModel,
CreateConversationModelOperationMetadata>
createConversationModelOperationCallable;
private final UnaryCallable
getConversationModelCallable;
private final UnaryCallable
listConversationModelsCallable;
private final UnaryCallable
listConversationModelsPagedCallable;
private final UnaryCallable
deleteConversationModelCallable;
private final OperationCallable<
DeleteConversationModelRequest, Empty, DeleteConversationModelOperationMetadata>
deleteConversationModelOperationCallable;
private final UnaryCallable
deployConversationModelCallable;
private final OperationCallable<
DeployConversationModelRequest, Empty, DeployConversationModelOperationMetadata>
deployConversationModelOperationCallable;
private final UnaryCallable
undeployConversationModelCallable;
private final OperationCallable<
UndeployConversationModelRequest, Empty, UndeployConversationModelOperationMetadata>
undeployConversationModelOperationCallable;
private final UnaryCallable
getConversationModelEvaluationCallable;
private final UnaryCallable<
ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsResponse>
listConversationModelEvaluationsCallable;
private final UnaryCallable<
ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsPagedResponse>
listConversationModelEvaluationsPagedCallable;
private final UnaryCallable
createConversationModelEvaluationCallable;
private final OperationCallable<
CreateConversationModelEvaluationRequest,
ConversationModelEvaluation,
CreateConversationModelEvaluationOperationMetadata>
createConversationModelEvaluationOperationCallable;
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 GrpcConversationModelsStub create(ConversationModelsStubSettings settings)
throws IOException {
return new GrpcConversationModelsStub(settings, ClientContext.create(settings));
}
public static final GrpcConversationModelsStub create(ClientContext clientContext)
throws IOException {
return new GrpcConversationModelsStub(
ConversationModelsStubSettings.newBuilder().build(), clientContext);
}
public static final GrpcConversationModelsStub create(
ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
return new GrpcConversationModelsStub(
ConversationModelsStubSettings.newBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of GrpcConversationModelsStub, 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 GrpcConversationModelsStub(
ConversationModelsStubSettings settings, ClientContext clientContext) throws IOException {
this(settings, clientContext, new GrpcConversationModelsCallableFactory());
}
/**
* Constructs an instance of GrpcConversationModelsStub, 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 GrpcConversationModelsStub(
ConversationModelsStubSettings settings,
ClientContext clientContext,
GrpcStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
GrpcCallSettings
createConversationModelTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createConversationModelMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
GrpcCallSettings
getConversationModelTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getConversationModelMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings
listConversationModelsTransportSettings =
GrpcCallSettings
.newBuilder()
.setMethodDescriptor(listConversationModelsMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
GrpcCallSettings
deleteConversationModelTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deleteConversationModelMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings
deployConversationModelTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deployConversationModelMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings
undeployConversationModelTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(undeployConversationModelMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings
getConversationModelEvaluationTransportSettings =
GrpcCallSettings
.newBuilder()
.setMethodDescriptor(getConversationModelEvaluationMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings<
ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsResponse>
listConversationModelEvaluationsTransportSettings =
GrpcCallSettings
.
newBuilder()
.setMethodDescriptor(listConversationModelEvaluationsMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
GrpcCallSettings
createConversationModelEvaluationTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createConversationModelEvaluationMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
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.createConversationModelCallable =
callableFactory.createUnaryCallable(
createConversationModelTransportSettings,
settings.createConversationModelSettings(),
clientContext);
this.createConversationModelOperationCallable =
callableFactory.createOperationCallable(
createConversationModelTransportSettings,
settings.createConversationModelOperationSettings(),
clientContext,
operationsStub);
this.getConversationModelCallable =
callableFactory.createUnaryCallable(
getConversationModelTransportSettings,
settings.getConversationModelSettings(),
clientContext);
this.listConversationModelsCallable =
callableFactory.createUnaryCallable(
listConversationModelsTransportSettings,
settings.listConversationModelsSettings(),
clientContext);
this.listConversationModelsPagedCallable =
callableFactory.createPagedCallable(
listConversationModelsTransportSettings,
settings.listConversationModelsSettings(),
clientContext);
this.deleteConversationModelCallable =
callableFactory.createUnaryCallable(
deleteConversationModelTransportSettings,
settings.deleteConversationModelSettings(),
clientContext);
this.deleteConversationModelOperationCallable =
callableFactory.createOperationCallable(
deleteConversationModelTransportSettings,
settings.deleteConversationModelOperationSettings(),
clientContext,
operationsStub);
this.deployConversationModelCallable =
callableFactory.createUnaryCallable(
deployConversationModelTransportSettings,
settings.deployConversationModelSettings(),
clientContext);
this.deployConversationModelOperationCallable =
callableFactory.createOperationCallable(
deployConversationModelTransportSettings,
settings.deployConversationModelOperationSettings(),
clientContext,
operationsStub);
this.undeployConversationModelCallable =
callableFactory.createUnaryCallable(
undeployConversationModelTransportSettings,
settings.undeployConversationModelSettings(),
clientContext);
this.undeployConversationModelOperationCallable =
callableFactory.createOperationCallable(
undeployConversationModelTransportSettings,
settings.undeployConversationModelOperationSettings(),
clientContext,
operationsStub);
this.getConversationModelEvaluationCallable =
callableFactory.createUnaryCallable(
getConversationModelEvaluationTransportSettings,
settings.getConversationModelEvaluationSettings(),
clientContext);
this.listConversationModelEvaluationsCallable =
callableFactory.createUnaryCallable(
listConversationModelEvaluationsTransportSettings,
settings.listConversationModelEvaluationsSettings(),
clientContext);
this.listConversationModelEvaluationsPagedCallable =
callableFactory.createPagedCallable(
listConversationModelEvaluationsTransportSettings,
settings.listConversationModelEvaluationsSettings(),
clientContext);
this.createConversationModelEvaluationCallable =
callableFactory.createUnaryCallable(
createConversationModelEvaluationTransportSettings,
settings.createConversationModelEvaluationSettings(),
clientContext);
this.createConversationModelEvaluationOperationCallable =
callableFactory.createOperationCallable(
createConversationModelEvaluationTransportSettings,
settings.createConversationModelEvaluationOperationSettings(),
clientContext,
operationsStub);
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
createConversationModelCallable() {
return createConversationModelCallable;
}
@Override
public OperationCallable<
CreateConversationModelRequest,
ConversationModel,
CreateConversationModelOperationMetadata>
createConversationModelOperationCallable() {
return createConversationModelOperationCallable;
}
@Override
public UnaryCallable
getConversationModelCallable() {
return getConversationModelCallable;
}
@Override
public UnaryCallable
listConversationModelsCallable() {
return listConversationModelsCallable;
}
@Override
public UnaryCallable
listConversationModelsPagedCallable() {
return listConversationModelsPagedCallable;
}
@Override
public UnaryCallable
deleteConversationModelCallable() {
return deleteConversationModelCallable;
}
@Override
public OperationCallable<
DeleteConversationModelRequest, Empty, DeleteConversationModelOperationMetadata>
deleteConversationModelOperationCallable() {
return deleteConversationModelOperationCallable;
}
@Override
public UnaryCallable
deployConversationModelCallable() {
return deployConversationModelCallable;
}
@Override
public OperationCallable<
DeployConversationModelRequest, Empty, DeployConversationModelOperationMetadata>
deployConversationModelOperationCallable() {
return deployConversationModelOperationCallable;
}
@Override
public UnaryCallable
undeployConversationModelCallable() {
return undeployConversationModelCallable;
}
@Override
public OperationCallable<
UndeployConversationModelRequest, Empty, UndeployConversationModelOperationMetadata>
undeployConversationModelOperationCallable() {
return undeployConversationModelOperationCallable;
}
@Override
public UnaryCallable
getConversationModelEvaluationCallable() {
return getConversationModelEvaluationCallable;
}
@Override
public UnaryCallable<
ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsResponse>
listConversationModelEvaluationsCallable() {
return listConversationModelEvaluationsCallable;
}
@Override
public UnaryCallable<
ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsPagedResponse>
listConversationModelEvaluationsPagedCallable() {
return listConversationModelEvaluationsPagedCallable;
}
@Override
public UnaryCallable
createConversationModelEvaluationCallable() {
return createConversationModelEvaluationCallable;
}
@Override
public OperationCallable<
CreateConversationModelEvaluationRequest,
ConversationModelEvaluation,
CreateConversationModelEvaluationOperationMetadata>
createConversationModelEvaluationOperationCallable() {
return createConversationModelEvaluationOperationCallable;
}
@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);
}
}