
com.google.cloud.gkehub.v1beta.stub.GrpcGkeHubStub Maven / Gradle / Ivy
Show all versions of google-cloud-gkehub 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.gkehub.v1beta.stub;
import static com.google.cloud.gkehub.v1beta.GkeHubClient.ListFeaturesPagedResponse;
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.gkehub.v1beta.CreateFeatureRequest;
import com.google.cloud.gkehub.v1beta.DeleteFeatureRequest;
import com.google.cloud.gkehub.v1beta.Feature;
import com.google.cloud.gkehub.v1beta.GetFeatureRequest;
import com.google.cloud.gkehub.v1beta.ListFeaturesRequest;
import com.google.cloud.gkehub.v1beta.ListFeaturesResponse;
import com.google.cloud.gkehub.v1beta.OperationMetadata;
import com.google.cloud.gkehub.v1beta.UpdateFeatureRequest;
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 GkeHub service API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@BetaApi
@Generated("by gapic-generator-java")
public class GrpcGkeHubStub extends GkeHubStub {
private static final MethodDescriptor
listFeaturesMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.gkehub.v1beta.GkeHub/ListFeatures")
.setRequestMarshaller(ProtoUtils.marshaller(ListFeaturesRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListFeaturesResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor getFeatureMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.gkehub.v1beta.GkeHub/GetFeature")
.setRequestMarshaller(ProtoUtils.marshaller(GetFeatureRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Feature.getDefaultInstance()))
.build();
private static final MethodDescriptor
createFeatureMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.gkehub.v1beta.GkeHub/CreateFeature")
.setRequestMarshaller(
ProtoUtils.marshaller(CreateFeatureRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
deleteFeatureMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.gkehub.v1beta.GkeHub/DeleteFeature")
.setRequestMarshaller(
ProtoUtils.marshaller(DeleteFeatureRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
updateFeatureMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.gkehub.v1beta.GkeHub/UpdateFeature")
.setRequestMarshaller(
ProtoUtils.marshaller(UpdateFeatureRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private final UnaryCallable listFeaturesCallable;
private final UnaryCallable
listFeaturesPagedCallable;
private final UnaryCallable getFeatureCallable;
private final UnaryCallable createFeatureCallable;
private final OperationCallable
createFeatureOperationCallable;
private final UnaryCallable deleteFeatureCallable;
private final OperationCallable
deleteFeatureOperationCallable;
private final UnaryCallable updateFeatureCallable;
private final OperationCallable
updateFeatureOperationCallable;
private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
private final GrpcStubCallableFactory callableFactory;
public static final GrpcGkeHubStub create(GkeHubStubSettings settings) throws IOException {
return new GrpcGkeHubStub(settings, ClientContext.create(settings));
}
public static final GrpcGkeHubStub create(ClientContext clientContext) throws IOException {
return new GrpcGkeHubStub(GkeHubStubSettings.newBuilder().build(), clientContext);
}
public static final GrpcGkeHubStub create(
ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
return new GrpcGkeHubStub(
GkeHubStubSettings.newBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of GrpcGkeHubStub, 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 GrpcGkeHubStub(GkeHubStubSettings settings, ClientContext clientContext)
throws IOException {
this(settings, clientContext, new GrpcGkeHubCallableFactory());
}
/**
* Constructs an instance of GrpcGkeHubStub, 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 GrpcGkeHubStub(
GkeHubStubSettings settings,
ClientContext clientContext,
GrpcStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
GrpcCallSettings listFeaturesTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(listFeaturesMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
GrpcCallSettings getFeatureTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getFeatureMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings createFeatureTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createFeatureMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
GrpcCallSettings deleteFeatureTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deleteFeatureMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings updateFeatureTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(updateFeatureMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
this.listFeaturesCallable =
callableFactory.createUnaryCallable(
listFeaturesTransportSettings, settings.listFeaturesSettings(), clientContext);
this.listFeaturesPagedCallable =
callableFactory.createPagedCallable(
listFeaturesTransportSettings, settings.listFeaturesSettings(), clientContext);
this.getFeatureCallable =
callableFactory.createUnaryCallable(
getFeatureTransportSettings, settings.getFeatureSettings(), clientContext);
this.createFeatureCallable =
callableFactory.createUnaryCallable(
createFeatureTransportSettings, settings.createFeatureSettings(), clientContext);
this.createFeatureOperationCallable =
callableFactory.createOperationCallable(
createFeatureTransportSettings,
settings.createFeatureOperationSettings(),
clientContext,
operationsStub);
this.deleteFeatureCallable =
callableFactory.createUnaryCallable(
deleteFeatureTransportSettings, settings.deleteFeatureSettings(), clientContext);
this.deleteFeatureOperationCallable =
callableFactory.createOperationCallable(
deleteFeatureTransportSettings,
settings.deleteFeatureOperationSettings(),
clientContext,
operationsStub);
this.updateFeatureCallable =
callableFactory.createUnaryCallable(
updateFeatureTransportSettings, settings.updateFeatureSettings(), clientContext);
this.updateFeatureOperationCallable =
callableFactory.createOperationCallable(
updateFeatureTransportSettings,
settings.updateFeatureOperationSettings(),
clientContext,
operationsStub);
this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
}
public GrpcOperationsStub getOperationsStub() {
return operationsStub;
}
@Override
public UnaryCallable listFeaturesCallable() {
return listFeaturesCallable;
}
@Override
public UnaryCallable listFeaturesPagedCallable() {
return listFeaturesPagedCallable;
}
@Override
public UnaryCallable getFeatureCallable() {
return getFeatureCallable;
}
@Override
public UnaryCallable createFeatureCallable() {
return createFeatureCallable;
}
@Override
public OperationCallable
createFeatureOperationCallable() {
return createFeatureOperationCallable;
}
@Override
public UnaryCallable deleteFeatureCallable() {
return deleteFeatureCallable;
}
@Override
public OperationCallable
deleteFeatureOperationCallable() {
return deleteFeatureOperationCallable;
}
@Override
public UnaryCallable updateFeatureCallable() {
return updateFeatureCallable;
}
@Override
public OperationCallable
updateFeatureOperationCallable() {
return updateFeatureOperationCallable;
}
@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);
}
}