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

com.google.cloud.dataproc.v1.stub.GrpcClusterControllerStub 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.dataproc.v1.stub;

import static com.google.cloud.dataproc.v1.ClusterControllerClient.ListClustersPagedResponse;

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.dataproc.v1.Cluster;
import com.google.cloud.dataproc.v1.ClusterOperationMetadata;
import com.google.cloud.dataproc.v1.CreateClusterRequest;
import com.google.cloud.dataproc.v1.DeleteClusterRequest;
import com.google.cloud.dataproc.v1.DiagnoseClusterRequest;
import com.google.cloud.dataproc.v1.DiagnoseClusterResults;
import com.google.cloud.dataproc.v1.GetClusterRequest;
import com.google.cloud.dataproc.v1.ListClustersRequest;
import com.google.cloud.dataproc.v1.ListClustersResponse;
import com.google.cloud.dataproc.v1.StartClusterRequest;
import com.google.cloud.dataproc.v1.StopClusterRequest;
import com.google.cloud.dataproc.v1.UpdateClusterRequest;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
import com.google.iam.v1.TestIamPermissionsRequest;
import com.google.iam.v1.TestIamPermissionsResponse;
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 ClusterController service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator-java") public class GrpcClusterControllerStub extends ClusterControllerStub { private static final MethodDescriptor createClusterMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dataproc.v1.ClusterController/CreateCluster") .setRequestMarshaller( ProtoUtils.marshaller(CreateClusterRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor updateClusterMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dataproc.v1.ClusterController/UpdateCluster") .setRequestMarshaller( ProtoUtils.marshaller(UpdateClusterRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor stopClusterMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dataproc.v1.ClusterController/StopCluster") .setRequestMarshaller(ProtoUtils.marshaller(StopClusterRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor startClusterMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dataproc.v1.ClusterController/StartCluster") .setRequestMarshaller(ProtoUtils.marshaller(StartClusterRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor deleteClusterMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dataproc.v1.ClusterController/DeleteCluster") .setRequestMarshaller( ProtoUtils.marshaller(DeleteClusterRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor getClusterMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dataproc.v1.ClusterController/GetCluster") .setRequestMarshaller(ProtoUtils.marshaller(GetClusterRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Cluster.getDefaultInstance())) .build(); private static final MethodDescriptor listClustersMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dataproc.v1.ClusterController/ListClusters") .setRequestMarshaller(ProtoUtils.marshaller(ListClustersRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListClustersResponse.getDefaultInstance())) .build(); private static final MethodDescriptor diagnoseClusterMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.dataproc.v1.ClusterController/DiagnoseCluster") .setRequestMarshaller( ProtoUtils.marshaller(DiagnoseClusterRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor setIamPolicyMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.iam.v1.IAMPolicy/SetIamPolicy") .setRequestMarshaller(ProtoUtils.marshaller(SetIamPolicyRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) .build(); private static final MethodDescriptor getIamPolicyMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.iam.v1.IAMPolicy/GetIamPolicy") .setRequestMarshaller(ProtoUtils.marshaller(GetIamPolicyRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) .build(); private static final MethodDescriptor testIamPermissionsMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.iam.v1.IAMPolicy/TestIamPermissions") .setRequestMarshaller( ProtoUtils.marshaller(TestIamPermissionsRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance())) .build(); private final UnaryCallable createClusterCallable; private final OperationCallable createClusterOperationCallable; private final UnaryCallable updateClusterCallable; private final OperationCallable updateClusterOperationCallable; private final UnaryCallable stopClusterCallable; private final OperationCallable stopClusterOperationCallable; private final UnaryCallable startClusterCallable; private final OperationCallable startClusterOperationCallable; private final UnaryCallable deleteClusterCallable; private final OperationCallable deleteClusterOperationCallable; private final UnaryCallable getClusterCallable; private final UnaryCallable listClustersCallable; private final UnaryCallable listClustersPagedCallable; private final UnaryCallable diagnoseClusterCallable; private final OperationCallable< DiagnoseClusterRequest, DiagnoseClusterResults, ClusterOperationMetadata> diagnoseClusterOperationCallable; private final UnaryCallable setIamPolicyCallable; private final UnaryCallable getIamPolicyCallable; private final UnaryCallable testIamPermissionsCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcClusterControllerStub create(ClusterControllerStubSettings settings) throws IOException { return new GrpcClusterControllerStub(settings, ClientContext.create(settings)); } public static final GrpcClusterControllerStub create(ClientContext clientContext) throws IOException { return new GrpcClusterControllerStub( ClusterControllerStubSettings.newBuilder().build(), clientContext); } public static final GrpcClusterControllerStub create( ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { return new GrpcClusterControllerStub( ClusterControllerStubSettings.newBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of GrpcClusterControllerStub, 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 GrpcClusterControllerStub( ClusterControllerStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new GrpcClusterControllerCallableFactory()); } /** * Constructs an instance of GrpcClusterControllerStub, 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 GrpcClusterControllerStub( ClusterControllerStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings createClusterTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createClusterMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("project_id", String.valueOf(request.getProjectId())); builder.add("region", String.valueOf(request.getRegion())); return builder.build(); }) .build(); GrpcCallSettings updateClusterTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateClusterMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("cluster_name", String.valueOf(request.getClusterName())); builder.add("project_id", String.valueOf(request.getProjectId())); builder.add("region", String.valueOf(request.getRegion())); return builder.build(); }) .build(); GrpcCallSettings stopClusterTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(stopClusterMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("cluster_name", String.valueOf(request.getClusterName())); builder.add("project_id", String.valueOf(request.getProjectId())); builder.add("region", String.valueOf(request.getRegion())); return builder.build(); }) .build(); GrpcCallSettings startClusterTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(startClusterMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("cluster_name", String.valueOf(request.getClusterName())); builder.add("project_id", String.valueOf(request.getProjectId())); builder.add("region", String.valueOf(request.getRegion())); return builder.build(); }) .build(); GrpcCallSettings deleteClusterTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteClusterMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("cluster_name", String.valueOf(request.getClusterName())); builder.add("project_id", String.valueOf(request.getProjectId())); builder.add("region", String.valueOf(request.getRegion())); return builder.build(); }) .build(); GrpcCallSettings getClusterTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getClusterMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("cluster_name", String.valueOf(request.getClusterName())); builder.add("project_id", String.valueOf(request.getProjectId())); builder.add("region", String.valueOf(request.getRegion())); return builder.build(); }) .build(); GrpcCallSettings listClustersTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listClustersMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("project_id", String.valueOf(request.getProjectId())); builder.add("region", String.valueOf(request.getRegion())); return builder.build(); }) .build(); GrpcCallSettings diagnoseClusterTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(diagnoseClusterMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("cluster_name", String.valueOf(request.getClusterName())); builder.add("project_id", String.valueOf(request.getProjectId())); builder.add("region", String.valueOf(request.getRegion())); return builder.build(); }) .build(); GrpcCallSettings setIamPolicyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(setIamPolicyMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("resource", String.valueOf(request.getResource())); return builder.build(); }) .build(); GrpcCallSettings getIamPolicyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getIamPolicyMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("resource", String.valueOf(request.getResource())); return builder.build(); }) .build(); GrpcCallSettings testIamPermissionsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(testIamPermissionsMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("resource", String.valueOf(request.getResource())); return builder.build(); }) .build(); this.createClusterCallable = callableFactory.createUnaryCallable( createClusterTransportSettings, settings.createClusterSettings(), clientContext); this.createClusterOperationCallable = callableFactory.createOperationCallable( createClusterTransportSettings, settings.createClusterOperationSettings(), clientContext, operationsStub); this.updateClusterCallable = callableFactory.createUnaryCallable( updateClusterTransportSettings, settings.updateClusterSettings(), clientContext); this.updateClusterOperationCallable = callableFactory.createOperationCallable( updateClusterTransportSettings, settings.updateClusterOperationSettings(), clientContext, operationsStub); this.stopClusterCallable = callableFactory.createUnaryCallable( stopClusterTransportSettings, settings.stopClusterSettings(), clientContext); this.stopClusterOperationCallable = callableFactory.createOperationCallable( stopClusterTransportSettings, settings.stopClusterOperationSettings(), clientContext, operationsStub); this.startClusterCallable = callableFactory.createUnaryCallable( startClusterTransportSettings, settings.startClusterSettings(), clientContext); this.startClusterOperationCallable = callableFactory.createOperationCallable( startClusterTransportSettings, settings.startClusterOperationSettings(), clientContext, operationsStub); this.deleteClusterCallable = callableFactory.createUnaryCallable( deleteClusterTransportSettings, settings.deleteClusterSettings(), clientContext); this.deleteClusterOperationCallable = callableFactory.createOperationCallable( deleteClusterTransportSettings, settings.deleteClusterOperationSettings(), clientContext, operationsStub); this.getClusterCallable = callableFactory.createUnaryCallable( getClusterTransportSettings, settings.getClusterSettings(), clientContext); this.listClustersCallable = callableFactory.createUnaryCallable( listClustersTransportSettings, settings.listClustersSettings(), clientContext); this.listClustersPagedCallable = callableFactory.createPagedCallable( listClustersTransportSettings, settings.listClustersSettings(), clientContext); this.diagnoseClusterCallable = callableFactory.createUnaryCallable( diagnoseClusterTransportSettings, settings.diagnoseClusterSettings(), clientContext); this.diagnoseClusterOperationCallable = callableFactory.createOperationCallable( diagnoseClusterTransportSettings, settings.diagnoseClusterOperationSettings(), clientContext, operationsStub); this.setIamPolicyCallable = callableFactory.createUnaryCallable( setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); this.getIamPolicyCallable = callableFactory.createUnaryCallable( getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); this.testIamPermissionsCallable = callableFactory.createUnaryCallable( testIamPermissionsTransportSettings, settings.testIamPermissionsSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } public GrpcOperationsStub getOperationsStub() { return operationsStub; } @Override public UnaryCallable createClusterCallable() { return createClusterCallable; } @Override public OperationCallable createClusterOperationCallable() { return createClusterOperationCallable; } @Override public UnaryCallable updateClusterCallable() { return updateClusterCallable; } @Override public OperationCallable updateClusterOperationCallable() { return updateClusterOperationCallable; } @Override public UnaryCallable stopClusterCallable() { return stopClusterCallable; } @Override public OperationCallable stopClusterOperationCallable() { return stopClusterOperationCallable; } @Override public UnaryCallable startClusterCallable() { return startClusterCallable; } @Override public OperationCallable startClusterOperationCallable() { return startClusterOperationCallable; } @Override public UnaryCallable deleteClusterCallable() { return deleteClusterCallable; } @Override public OperationCallable deleteClusterOperationCallable() { return deleteClusterOperationCallable; } @Override public UnaryCallable getClusterCallable() { return getClusterCallable; } @Override public UnaryCallable listClustersCallable() { return listClustersCallable; } @Override public UnaryCallable listClustersPagedCallable() { return listClustersPagedCallable; } @Override public UnaryCallable diagnoseClusterCallable() { return diagnoseClusterCallable; } @Override public OperationCallable diagnoseClusterOperationCallable() { return diagnoseClusterOperationCallable; } @Override public UnaryCallable setIamPolicyCallable() { return setIamPolicyCallable; } @Override public UnaryCallable getIamPolicyCallable() { return getIamPolicyCallable; } @Override public UnaryCallable testIamPermissionsCallable() { return testIamPermissionsCallable; } @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