com.google.cloud.rapidmigrationassessment.v1.stub.GrpcRapidMigrationAssessmentStub Maven / Gradle / Ivy
/*
* 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.rapidmigrationassessment.v1.stub;
import static com.google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient.ListCollectorsPagedResponse;
import static com.google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient.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.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
import com.google.cloud.rapidmigrationassessment.v1.Annotation;
import com.google.cloud.rapidmigrationassessment.v1.Collector;
import com.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest;
import com.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest;
import com.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest;
import com.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest;
import com.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest;
import com.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest;
import com.google.cloud.rapidmigrationassessment.v1.ListCollectorsResponse;
import com.google.cloud.rapidmigrationassessment.v1.OperationMetadata;
import com.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest;
import com.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest;
import com.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest;
import com.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest;
import com.google.longrunning.Operation;
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 RapidMigrationAssessment service API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@Generated("by gapic-generator-java")
public class GrpcRapidMigrationAssessmentStub extends RapidMigrationAssessmentStub {
private static final MethodDescriptor
createCollectorMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/CreateCollector")
.setRequestMarshaller(
ProtoUtils.marshaller(CreateCollectorRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
createAnnotationMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/CreateAnnotation")
.setRequestMarshaller(
ProtoUtils.marshaller(CreateAnnotationRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
getAnnotationMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/GetAnnotation")
.setRequestMarshaller(
ProtoUtils.marshaller(GetAnnotationRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Annotation.getDefaultInstance()))
.build();
private static final MethodDescriptor
listCollectorsMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/ListCollectors")
.setRequestMarshaller(
ProtoUtils.marshaller(ListCollectorsRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListCollectorsResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor
getCollectorMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/GetCollector")
.setRequestMarshaller(ProtoUtils.marshaller(GetCollectorRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Collector.getDefaultInstance()))
.build();
private static final MethodDescriptor
updateCollectorMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/UpdateCollector")
.setRequestMarshaller(
ProtoUtils.marshaller(UpdateCollectorRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
deleteCollectorMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/DeleteCollector")
.setRequestMarshaller(
ProtoUtils.marshaller(DeleteCollectorRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
resumeCollectorMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/ResumeCollector")
.setRequestMarshaller(
ProtoUtils.marshaller(ResumeCollectorRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
registerCollectorMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/RegisterCollector")
.setRequestMarshaller(
ProtoUtils.marshaller(RegisterCollectorRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
pauseCollectorMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/PauseCollector")
.setRequestMarshaller(
ProtoUtils.marshaller(PauseCollectorRequest.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 createCollectorCallable;
private final OperationCallable
createCollectorOperationCallable;
private final UnaryCallable createAnnotationCallable;
private final OperationCallable
createAnnotationOperationCallable;
private final UnaryCallable getAnnotationCallable;
private final UnaryCallable listCollectorsCallable;
private final UnaryCallable
listCollectorsPagedCallable;
private final UnaryCallable getCollectorCallable;
private final UnaryCallable updateCollectorCallable;
private final OperationCallable
updateCollectorOperationCallable;
private final UnaryCallable deleteCollectorCallable;
private final OperationCallable
deleteCollectorOperationCallable;
private final UnaryCallable resumeCollectorCallable;
private final OperationCallable
resumeCollectorOperationCallable;
private final UnaryCallable registerCollectorCallable;
private final OperationCallable
registerCollectorOperationCallable;
private final UnaryCallable pauseCollectorCallable;
private final OperationCallable
pauseCollectorOperationCallable;
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 GrpcRapidMigrationAssessmentStub create(
RapidMigrationAssessmentStubSettings settings) throws IOException {
return new GrpcRapidMigrationAssessmentStub(settings, ClientContext.create(settings));
}
public static final GrpcRapidMigrationAssessmentStub create(ClientContext clientContext)
throws IOException {
return new GrpcRapidMigrationAssessmentStub(
RapidMigrationAssessmentStubSettings.newBuilder().build(), clientContext);
}
public static final GrpcRapidMigrationAssessmentStub create(
ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
return new GrpcRapidMigrationAssessmentStub(
RapidMigrationAssessmentStubSettings.newBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of GrpcRapidMigrationAssessmentStub, 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 GrpcRapidMigrationAssessmentStub(
RapidMigrationAssessmentStubSettings settings, ClientContext clientContext)
throws IOException {
this(settings, clientContext, new GrpcRapidMigrationAssessmentCallableFactory());
}
/**
* Constructs an instance of GrpcRapidMigrationAssessmentStub, 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 GrpcRapidMigrationAssessmentStub(
RapidMigrationAssessmentStubSettings settings,
ClientContext clientContext,
GrpcStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
GrpcCallSettings createCollectorTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createCollectorMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
GrpcCallSettings createAnnotationTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createAnnotationMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
GrpcCallSettings getAnnotationTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getAnnotationMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings
listCollectorsTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(listCollectorsMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
GrpcCallSettings getCollectorTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getCollectorMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings updateCollectorTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(updateCollectorMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("collector.name", String.valueOf(request.getCollector().getName()));
return builder.build();
})
.build();
GrpcCallSettings deleteCollectorTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deleteCollectorMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings resumeCollectorTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(resumeCollectorMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings registerCollectorTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(registerCollectorMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings pauseCollectorTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(pauseCollectorMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.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.createCollectorCallable =
callableFactory.createUnaryCallable(
createCollectorTransportSettings, settings.createCollectorSettings(), clientContext);
this.createCollectorOperationCallable =
callableFactory.createOperationCallable(
createCollectorTransportSettings,
settings.createCollectorOperationSettings(),
clientContext,
operationsStub);
this.createAnnotationCallable =
callableFactory.createUnaryCallable(
createAnnotationTransportSettings, settings.createAnnotationSettings(), clientContext);
this.createAnnotationOperationCallable =
callableFactory.createOperationCallable(
createAnnotationTransportSettings,
settings.createAnnotationOperationSettings(),
clientContext,
operationsStub);
this.getAnnotationCallable =
callableFactory.createUnaryCallable(
getAnnotationTransportSettings, settings.getAnnotationSettings(), clientContext);
this.listCollectorsCallable =
callableFactory.createUnaryCallable(
listCollectorsTransportSettings, settings.listCollectorsSettings(), clientContext);
this.listCollectorsPagedCallable =
callableFactory.createPagedCallable(
listCollectorsTransportSettings, settings.listCollectorsSettings(), clientContext);
this.getCollectorCallable =
callableFactory.createUnaryCallable(
getCollectorTransportSettings, settings.getCollectorSettings(), clientContext);
this.updateCollectorCallable =
callableFactory.createUnaryCallable(
updateCollectorTransportSettings, settings.updateCollectorSettings(), clientContext);
this.updateCollectorOperationCallable =
callableFactory.createOperationCallable(
updateCollectorTransportSettings,
settings.updateCollectorOperationSettings(),
clientContext,
operationsStub);
this.deleteCollectorCallable =
callableFactory.createUnaryCallable(
deleteCollectorTransportSettings, settings.deleteCollectorSettings(), clientContext);
this.deleteCollectorOperationCallable =
callableFactory.createOperationCallable(
deleteCollectorTransportSettings,
settings.deleteCollectorOperationSettings(),
clientContext,
operationsStub);
this.resumeCollectorCallable =
callableFactory.createUnaryCallable(
resumeCollectorTransportSettings, settings.resumeCollectorSettings(), clientContext);
this.resumeCollectorOperationCallable =
callableFactory.createOperationCallable(
resumeCollectorTransportSettings,
settings.resumeCollectorOperationSettings(),
clientContext,
operationsStub);
this.registerCollectorCallable =
callableFactory.createUnaryCallable(
registerCollectorTransportSettings,
settings.registerCollectorSettings(),
clientContext);
this.registerCollectorOperationCallable =
callableFactory.createOperationCallable(
registerCollectorTransportSettings,
settings.registerCollectorOperationSettings(),
clientContext,
operationsStub);
this.pauseCollectorCallable =
callableFactory.createUnaryCallable(
pauseCollectorTransportSettings, settings.pauseCollectorSettings(), clientContext);
this.pauseCollectorOperationCallable =
callableFactory.createOperationCallable(
pauseCollectorTransportSettings,
settings.pauseCollectorOperationSettings(),
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 createCollectorCallable() {
return createCollectorCallable;
}
@Override
public OperationCallable
createCollectorOperationCallable() {
return createCollectorOperationCallable;
}
@Override
public UnaryCallable createAnnotationCallable() {
return createAnnotationCallable;
}
@Override
public OperationCallable
createAnnotationOperationCallable() {
return createAnnotationOperationCallable;
}
@Override
public UnaryCallable getAnnotationCallable() {
return getAnnotationCallable;
}
@Override
public UnaryCallable listCollectorsCallable() {
return listCollectorsCallable;
}
@Override
public UnaryCallable
listCollectorsPagedCallable() {
return listCollectorsPagedCallable;
}
@Override
public UnaryCallable getCollectorCallable() {
return getCollectorCallable;
}
@Override
public UnaryCallable updateCollectorCallable() {
return updateCollectorCallable;
}
@Override
public OperationCallable
updateCollectorOperationCallable() {
return updateCollectorOperationCallable;
}
@Override
public UnaryCallable deleteCollectorCallable() {
return deleteCollectorCallable;
}
@Override
public OperationCallable
deleteCollectorOperationCallable() {
return deleteCollectorOperationCallable;
}
@Override
public UnaryCallable resumeCollectorCallable() {
return resumeCollectorCallable;
}
@Override
public OperationCallable
resumeCollectorOperationCallable() {
return resumeCollectorOperationCallable;
}
@Override
public UnaryCallable registerCollectorCallable() {
return registerCollectorCallable;
}
@Override
public OperationCallable
registerCollectorOperationCallable() {
return registerCollectorOperationCallable;
}
@Override
public UnaryCallable pauseCollectorCallable() {
return pauseCollectorCallable;
}
@Override
public OperationCallable
pauseCollectorOperationCallable() {
return pauseCollectorOperationCallable;
}
@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);
}
}