Class ClusterControllerClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
String clusterName = "clusterName-1141738587";
Cluster response = clusterControllerClient.getCluster(projectId, region, clusterName);
}
Note: close() needs to be called on the ClusterControllerClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
CreateCluster |
Creates a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateCluster |
Updates a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). The cluster must be in a [`RUNNING`][google.cloud.dataproc.v1.ClusterStatus.State] state or an error is returned. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
StopCluster |
Stops a cluster in a project. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
StartCluster |
Starts a cluster in a project. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteCluster |
Deletes a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetCluster |
Gets the resource representation for a cluster in a project. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListClusters |
Lists all regions/{region}/clusters in a project alphabetically. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DiagnoseCluster |
Gets cluster diagnostic information. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). After the operation completes, [Operation.response][google.longrunning.Operation.response] contains [DiagnoseClusterResults](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#diagnoseclusterresults). |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
SetIamPolicy |
Sets the access control policy on the specified resource. Replacesany existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetIamPolicy |
Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
TestIamPermissions |
Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of ClusterControllerSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ClusterControllerSettings clusterControllerSettings =
ClusterControllerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ClusterControllerClient clusterControllerClient =
ClusterControllerClient.create(clusterControllerSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ClusterControllerSettings clusterControllerSettings =
ClusterControllerSettings.newBuilder().setEndpoint(myEndpoint).build();
ClusterControllerClient clusterControllerClient =
ClusterControllerClient.create(clusterControllerSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ClusterControllerSettings clusterControllerSettings =
ClusterControllerSettings.newHttpJsonBuilder().build();
ClusterControllerClient clusterControllerClient =
ClusterControllerClient.create(clusterControllerSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an instance of ClusterControllerClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) final voidclose()static final ClusterControllerClientcreate()Constructs an instance of ClusterControllerClient with default settings.static final ClusterControllerClientcreate(ClusterControllerSettings settings) Constructs an instance of ClusterControllerClient, using the given settings.static final ClusterControllerClientcreate(ClusterControllerStub stub) Constructs an instance of ClusterControllerClient, using the given stub for making calls.createClusterAsync(CreateClusterRequest request) Creates a cluster in a project.createClusterAsync(String projectId, String region, Cluster cluster) Creates a cluster in a project.Creates a cluster in a project.Creates a cluster in a project.final OperationFuture<com.google.protobuf.Empty,ClusterOperationMetadata> deleteClusterAsync(DeleteClusterRequest request) Deletes a cluster in a project.final OperationFuture<com.google.protobuf.Empty,ClusterOperationMetadata> deleteClusterAsync(String projectId, String region, String clusterName) Deletes a cluster in a project.Deletes a cluster in a project.final OperationCallable<DeleteClusterRequest,com.google.protobuf.Empty, ClusterOperationMetadata> Deletes a cluster in a project.Gets cluster diagnostic information.diagnoseClusterAsync(String projectId, String region, String clusterName) Gets cluster diagnostic information.Gets cluster diagnostic information.Gets cluster diagnostic information.final ClustergetCluster(GetClusterRequest request) Gets the resource representation for a cluster in a project.final ClustergetCluster(String projectId, String region, String clusterName) Gets the resource representation for a cluster in a project.Gets the resource representation for a cluster in a project.final OperationsClientReturns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.final PolicygetIamPolicy(GetIamPolicyRequest request) Gets the access control policy for a resource.Gets the access control policy for a resource.final OperationsClientReturns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.getStub()booleanbooleanlistClusters(ListClustersRequest request) Lists all regions/{region}/clusters in a project alphabetically.listClusters(String projectId, String region) Lists all regions/{region}/clusters in a project alphabetically.listClusters(String projectId, String region, String filter) Lists all regions/{region}/clusters in a project alphabetically.Lists all regions/{region}/clusters in a project alphabetically.Lists all regions/{region}/clusters in a project alphabetically.final PolicysetIamPolicy(SetIamPolicyRequest request) Sets the access control policy on the specified resource.Sets the access control policy on the specified resource.voidshutdown()voidstartClusterAsync(StartClusterRequest request) Starts a cluster in a project.Starts a cluster in a project.Starts a cluster in a project.stopClusterAsync(StopClusterRequest request) Stops a cluster in a project.Stops a cluster in a project.Stops a cluster in a project.Returns permissions that a caller has on the specified resource.Returns permissions that a caller has on the specified resource.updateClusterAsync(UpdateClusterRequest request) Updates a cluster in a project.updateClusterAsync(String projectId, String region, String clusterName, Cluster cluster, com.google.protobuf.FieldMask updateMask) Updates a cluster in a project.Updates a cluster in a project.Updates a cluster in a project.
-
Constructor Details
-
ClusterControllerClient
Constructs an instance of ClusterControllerClient, 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.- Throws:
IOException
-
ClusterControllerClient
-
-
Method Details
-
create
Constructs an instance of ClusterControllerClient with default settings.- Throws:
IOException
-
create
public static final ClusterControllerClient create(ClusterControllerSettings settings) throws IOException Constructs an instance of ClusterControllerClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
IOException
-
create
Constructs an instance of ClusterControllerClient, using the given stub for making calls. This is for advanced usage - prefer using create(ClusterControllerSettings). -
getSettings
-
getStub
-
getOperationsClient
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call. -
getHttpJsonOperationsClient
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call. -
createClusterAsync
public final OperationFuture<Cluster,ClusterOperationMetadata> createClusterAsync(String projectId, String region, Cluster cluster) Creates a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { String projectId = "projectId-894832108"; String region = "region-934795532"; Cluster cluster = Cluster.newBuilder().build(); Cluster response = clusterControllerClient.createClusterAsync(projectId, region, cluster).get(); }- Parameters:
projectId- Required. The ID of the Google Cloud Platform project that the cluster belongs to.region- Required. The Dataproc region in which to handle the request.cluster- Required. The cluster to create.- Throws:
ApiException- if the remote call fails
-
createClusterAsync
public final OperationFuture<Cluster,ClusterOperationMetadata> createClusterAsync(CreateClusterRequest request) Creates a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { CreateClusterRequest request = CreateClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setCluster(Cluster.newBuilder().build()) .setRequestId("requestId693933066") .setActionOnFailedPrimaryWorkers(FailureAction.forNumber(0)) .build(); Cluster response = clusterControllerClient.createClusterAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createClusterOperationCallable
public final OperationCallable<CreateClusterRequest,Cluster, createClusterOperationCallable()ClusterOperationMetadata> Creates a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { CreateClusterRequest request = CreateClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setCluster(Cluster.newBuilder().build()) .setRequestId("requestId693933066") .setActionOnFailedPrimaryWorkers(FailureAction.forNumber(0)) .build(); OperationFuture<Cluster, ClusterOperationMetadata> future = clusterControllerClient.createClusterOperationCallable().futureCall(request); // Do something. Cluster response = future.get(); } -
createClusterCallable
Creates a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { CreateClusterRequest request = CreateClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setCluster(Cluster.newBuilder().build()) .setRequestId("requestId693933066") .setActionOnFailedPrimaryWorkers(FailureAction.forNumber(0)) .build(); ApiFuture<Operation> future = clusterControllerClient.createClusterCallable().futureCall(request); // Do something. Operation response = future.get(); } -
updateClusterAsync
public final OperationFuture<Cluster,ClusterOperationMetadata> updateClusterAsync(String projectId, String region, String clusterName, Cluster cluster, com.google.protobuf.FieldMask updateMask) Updates a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). The cluster must be in a [`RUNNING`][google.cloud.dataproc.v1.ClusterStatus.State] state or an error is returned.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { String projectId = "projectId-894832108"; String region = "region-934795532"; String clusterName = "clusterName-1141738587"; Cluster cluster = Cluster.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); Cluster response = clusterControllerClient .updateClusterAsync(projectId, region, clusterName, cluster, updateMask) .get(); }- Parameters:
projectId- Required. The ID of the Google Cloud Platform project the cluster belongs to.region- Required. The Dataproc region in which to handle the request.clusterName- Required. The cluster name.cluster- Required. The changes to the cluster.updateMask- Required. Specifies the path, relative to `Cluster`, of the field to update. For example, to change the number of workers in a cluster to 5, the `update_mask` parameter would be specified as `config.worker_config.num_instances`, and the `PATCH` request body would specify the new value, as follows:{ "config":{ "workerConfig":{ "numInstances":"5" } } } Similarly, to change the number of preemptible workers in a cluster to 5, the `update_mask` parameter would be `config.secondary_worker_config.num_instances`, and the `PATCH` request body would be set as follows:
{ "config":{ "secondaryWorkerConfig":{ "numInstances":"5" } } } <strong>Note:</strong> Currently, only the following fields can be updated:
<table> <tbody> <tr> <td><strong>Mask</strong></td> <td><strong>Purpose</strong></td> </tr> <tr> <td><strong><em>labels</em></strong></td> <td>Update labels</td> </tr> <tr> <td><strong><em>config.worker_config.num_instances</em></strong></td> <td>Resize primary worker group</td> </tr> <tr> <td><strong><em>config.secondary_worker_config.num_instances</em></strong></td> <td>Resize secondary worker group</td> </tr> <tr> <td>config.autoscaling_config.policy_uri</td><td>Use, stop using, or change autoscaling policies</td> </tr> </tbody> </table>
- Throws:
ApiException- if the remote call fails
-
updateClusterAsync
public final OperationFuture<Cluster,ClusterOperationMetadata> updateClusterAsync(UpdateClusterRequest request) Updates a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). The cluster must be in a [`RUNNING`][google.cloud.dataproc.v1.ClusterStatus.State] state or an error is returned.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { UpdateClusterRequest request = UpdateClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setCluster(Cluster.newBuilder().build()) .setGracefulDecommissionTimeout(Duration.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .setRequestId("requestId693933066") .build(); Cluster response = clusterControllerClient.updateClusterAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
updateClusterOperationCallable
public final OperationCallable<UpdateClusterRequest,Cluster, updateClusterOperationCallable()ClusterOperationMetadata> Updates a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). The cluster must be in a [`RUNNING`][google.cloud.dataproc.v1.ClusterStatus.State] state or an error is returned.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { UpdateClusterRequest request = UpdateClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setCluster(Cluster.newBuilder().build()) .setGracefulDecommissionTimeout(Duration.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .setRequestId("requestId693933066") .build(); OperationFuture<Cluster, ClusterOperationMetadata> future = clusterControllerClient.updateClusterOperationCallable().futureCall(request); // Do something. Cluster response = future.get(); } -
updateClusterCallable
Updates a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). The cluster must be in a [`RUNNING`][google.cloud.dataproc.v1.ClusterStatus.State] state or an error is returned.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { UpdateClusterRequest request = UpdateClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setCluster(Cluster.newBuilder().build()) .setGracefulDecommissionTimeout(Duration.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .setRequestId("requestId693933066") .build(); ApiFuture<Operation> future = clusterControllerClient.updateClusterCallable().futureCall(request); // Do something. Operation response = future.get(); } -
stopClusterAsync
public final OperationFuture<Cluster,ClusterOperationMetadata> stopClusterAsync(StopClusterRequest request) Stops a cluster in a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { StopClusterRequest request = StopClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setClusterUuid("clusterUuid-1141510955") .setRequestId("requestId693933066") .build(); Cluster response = clusterControllerClient.stopClusterAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
stopClusterOperationCallable
public final OperationCallable<StopClusterRequest,Cluster, stopClusterOperationCallable()ClusterOperationMetadata> Stops a cluster in a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { StopClusterRequest request = StopClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setClusterUuid("clusterUuid-1141510955") .setRequestId("requestId693933066") .build(); OperationFuture<Cluster, ClusterOperationMetadata> future = clusterControllerClient.stopClusterOperationCallable().futureCall(request); // Do something. Cluster response = future.get(); } -
stopClusterCallable
Stops a cluster in a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { StopClusterRequest request = StopClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setClusterUuid("clusterUuid-1141510955") .setRequestId("requestId693933066") .build(); ApiFuture<Operation> future = clusterControllerClient.stopClusterCallable().futureCall(request); // Do something. Operation response = future.get(); } -
startClusterAsync
public final OperationFuture<Cluster,ClusterOperationMetadata> startClusterAsync(StartClusterRequest request) Starts a cluster in a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { StartClusterRequest request = StartClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setClusterUuid("clusterUuid-1141510955") .setRequestId("requestId693933066") .build(); Cluster response = clusterControllerClient.startClusterAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
startClusterOperationCallable
public final OperationCallable<StartClusterRequest,Cluster, startClusterOperationCallable()ClusterOperationMetadata> Starts a cluster in a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { StartClusterRequest request = StartClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setClusterUuid("clusterUuid-1141510955") .setRequestId("requestId693933066") .build(); OperationFuture<Cluster, ClusterOperationMetadata> future = clusterControllerClient.startClusterOperationCallable().futureCall(request); // Do something. Cluster response = future.get(); } -
startClusterCallable
Starts a cluster in a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { StartClusterRequest request = StartClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setClusterUuid("clusterUuid-1141510955") .setRequestId("requestId693933066") .build(); ApiFuture<Operation> future = clusterControllerClient.startClusterCallable().futureCall(request); // Do something. Operation response = future.get(); } -
deleteClusterAsync
public final OperationFuture<com.google.protobuf.Empty,ClusterOperationMetadata> deleteClusterAsync(String projectId, String region, String clusterName) Deletes a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { String projectId = "projectId-894832108"; String region = "region-934795532"; String clusterName = "clusterName-1141738587"; clusterControllerClient.deleteClusterAsync(projectId, region, clusterName).get(); }- Parameters:
projectId- Required. The ID of the Google Cloud Platform project that the cluster belongs to.region- Required. The Dataproc region in which to handle the request.clusterName- Required. The cluster name.- Throws:
ApiException- if the remote call fails
-
deleteClusterAsync
public final OperationFuture<com.google.protobuf.Empty,ClusterOperationMetadata> deleteClusterAsync(DeleteClusterRequest request) Deletes a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { DeleteClusterRequest request = DeleteClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setClusterUuid("clusterUuid-1141510955") .setRequestId("requestId693933066") .build(); clusterControllerClient.deleteClusterAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deleteClusterOperationCallable
public final OperationCallable<DeleteClusterRequest,com.google.protobuf.Empty, deleteClusterOperationCallable()ClusterOperationMetadata> Deletes a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { DeleteClusterRequest request = DeleteClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setClusterUuid("clusterUuid-1141510955") .setRequestId("requestId693933066") .build(); OperationFuture<Empty, ClusterOperationMetadata> future = clusterControllerClient.deleteClusterOperationCallable().futureCall(request); // Do something. future.get(); } -
deleteClusterCallable
Deletes a cluster in a project. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { DeleteClusterRequest request = DeleteClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setClusterUuid("clusterUuid-1141510955") .setRequestId("requestId693933066") .build(); ApiFuture<Operation> future = clusterControllerClient.deleteClusterCallable().futureCall(request); // Do something. future.get(); } -
getCluster
Gets the resource representation for a cluster in a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { String projectId = "projectId-894832108"; String region = "region-934795532"; String clusterName = "clusterName-1141738587"; Cluster response = clusterControllerClient.getCluster(projectId, region, clusterName); }- Parameters:
projectId- Required. The ID of the Google Cloud Platform project that the cluster belongs to.region- Required. The Dataproc region in which to handle the request.clusterName- Required. The cluster name.- Throws:
ApiException- if the remote call fails
-
getCluster
Gets the resource representation for a cluster in a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { GetClusterRequest request = GetClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .build(); Cluster response = clusterControllerClient.getCluster(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getClusterCallable
Gets the resource representation for a cluster in a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { GetClusterRequest request = GetClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .build(); ApiFuture<Cluster> future = clusterControllerClient.getClusterCallable().futureCall(request); // Do something. Cluster response = future.get(); } -
listClusters
public final ClusterControllerClient.ListClustersPagedResponse listClusters(String projectId, String region) Lists all regions/{region}/clusters in a project alphabetically.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { String projectId = "projectId-894832108"; String region = "region-934795532"; for (Cluster element : clusterControllerClient.listClusters(projectId, region).iterateAll()) { // doThingsWith(element); } }- Parameters:
projectId- Required. The ID of the Google Cloud Platform project that the cluster belongs to.region- Required. The Dataproc region in which to handle the request.- Throws:
ApiException- if the remote call fails
-
listClusters
public final ClusterControllerClient.ListClustersPagedResponse listClusters(String projectId, String region, String filter) Lists all regions/{region}/clusters in a project alphabetically.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { String projectId = "projectId-894832108"; String region = "region-934795532"; String filter = "filter-1274492040"; for (Cluster element : clusterControllerClient.listClusters(projectId, region, filter).iterateAll()) { // doThingsWith(element); } }- Parameters:
projectId- Required. The ID of the Google Cloud Platform project that the cluster belongs to.region- Required. The Dataproc region in which to handle the request.filter- Optional. A filter constraining the clusters to list. Filters are case-sensitive and have the following syntax:field = value [AND [field = value]] ...
where **field** is one of `status.state`, `clusterName`, or `labels.[KEY]`, and `[KEY]` is a label key. **value** can be `*` to match all values. `status.state` can be one of the following: `ACTIVE`, `INACTIVE`, `CREATING`, `RUNNING`, `ERROR`, `DELETING`, `UPDATING`, `STOPPING`, or `STOPPED`. `ACTIVE` contains the `CREATING`, `UPDATING`, and `RUNNING` states. `INACTIVE` contains the `DELETING`, `ERROR`, `STOPPING`, and `STOPPED` states. `clusterName` is the name of the cluster provided at creation time. Only the logical `AND` operator is supported; space-separated items are treated as having an implicit `AND` operator.
Example filter:
status.state = ACTIVE AND clusterName = mycluster AND labels.env = staging AND labels.starred = *
- Throws:
ApiException- if the remote call fails
-
listClusters
public final ClusterControllerClient.ListClustersPagedResponse listClusters(ListClustersRequest request) Lists all regions/{region}/clusters in a project alphabetically.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { ListClustersRequest request = ListClustersRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (Cluster element : clusterControllerClient.listClusters(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listClustersPagedCallable
public final UnaryCallable<ListClustersRequest,ClusterControllerClient.ListClustersPagedResponse> listClustersPagedCallable()Lists all regions/{region}/clusters in a project alphabetically.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { ListClustersRequest request = ListClustersRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<Cluster> future = clusterControllerClient.listClustersPagedCallable().futureCall(request); // Do something. for (Cluster element : future.get().iterateAll()) { // doThingsWith(element); } } -
listClustersCallable
Lists all regions/{region}/clusters in a project alphabetically.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { ListClustersRequest request = ListClustersRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListClustersResponse response = clusterControllerClient.listClustersCallable().call(request); for (Cluster element : response.getClustersList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
diagnoseClusterAsync
public final OperationFuture<DiagnoseClusterResults,ClusterOperationMetadata> diagnoseClusterAsync(String projectId, String region, String clusterName) Gets cluster diagnostic information. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). After the operation completes, [Operation.response][google.longrunning.Operation.response] contains [DiagnoseClusterResults](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#diagnoseclusterresults).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { String projectId = "projectId-894832108"; String region = "region-934795532"; String clusterName = "clusterName-1141738587"; DiagnoseClusterResults response = clusterControllerClient.diagnoseClusterAsync(projectId, region, clusterName).get(); }- Parameters:
projectId- Required. The ID of the Google Cloud Platform project that the cluster belongs to.region- Required. The Dataproc region in which to handle the request.clusterName- Required. The cluster name.- Throws:
ApiException- if the remote call fails
-
diagnoseClusterAsync
public final OperationFuture<DiagnoseClusterResults,ClusterOperationMetadata> diagnoseClusterAsync(DiagnoseClusterRequest request) Gets cluster diagnostic information. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). After the operation completes, [Operation.response][google.longrunning.Operation.response] contains [DiagnoseClusterResults](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#diagnoseclusterresults).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { DiagnoseClusterRequest request = DiagnoseClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setTarballGcsDir("tarballGcsDir-1602093510") .setDiagnosisInterval(Interval.newBuilder().build()) .addAllJobs(new ArrayList<String>()) .addAllYarnApplicationIds(new ArrayList<String>()) .build(); DiagnoseClusterResults response = clusterControllerClient.diagnoseClusterAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
diagnoseClusterOperationCallable
public final OperationCallable<DiagnoseClusterRequest,DiagnoseClusterResults, diagnoseClusterOperationCallable()ClusterOperationMetadata> Gets cluster diagnostic information. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). After the operation completes, [Operation.response][google.longrunning.Operation.response] contains [DiagnoseClusterResults](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#diagnoseclusterresults).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { DiagnoseClusterRequest request = DiagnoseClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setTarballGcsDir("tarballGcsDir-1602093510") .setDiagnosisInterval(Interval.newBuilder().build()) .addAllJobs(new ArrayList<String>()) .addAllYarnApplicationIds(new ArrayList<String>()) .build(); OperationFuture<DiagnoseClusterResults, ClusterOperationMetadata> future = clusterControllerClient.diagnoseClusterOperationCallable().futureCall(request); // Do something. DiagnoseClusterResults response = future.get(); } -
diagnoseClusterCallable
Gets cluster diagnostic information. The returned [Operation.metadata][google.longrunning.Operation.metadata] will be [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). After the operation completes, [Operation.response][google.longrunning.Operation.response] contains [DiagnoseClusterResults](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#diagnoseclusterresults).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { DiagnoseClusterRequest request = DiagnoseClusterRequest.newBuilder() .setProjectId("projectId-894832108") .setRegion("region-934795532") .setClusterName("clusterName-1141738587") .setTarballGcsDir("tarballGcsDir-1602093510") .setDiagnosisInterval(Interval.newBuilder().build()) .addAllJobs(new ArrayList<String>()) .addAllYarnApplicationIds(new ArrayList<String>()) .build(); ApiFuture<Operation> future = clusterControllerClient.diagnoseClusterCallable().futureCall(request); // Do something. Operation response = future.get(); } -
setIamPolicy
Sets the access control policy on the specified resource. Replacesany existing policy.Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource( AutoscalingPolicyName.ofProjectRegionAutoscalingPolicyName( "[PROJECT]", "[REGION]", "[AUTOSCALING_POLICY]") .toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Policy response = clusterControllerClient.setIamPolicy(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
setIamPolicyCallable
Sets the access control policy on the specified resource. Replacesany existing policy.Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource( AutoscalingPolicyName.ofProjectRegionAutoscalingPolicyName( "[PROJECT]", "[REGION]", "[AUTOSCALING_POLICY]") .toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Policy> future = clusterControllerClient.setIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); } -
getIamPolicy
Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource( AutoscalingPolicyName.ofProjectRegionAutoscalingPolicyName( "[PROJECT]", "[REGION]", "[AUTOSCALING_POLICY]") .toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); Policy response = clusterControllerClient.getIamPolicy(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getIamPolicyCallable
Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource( AutoscalingPolicyName.ofProjectRegionAutoscalingPolicyName( "[PROJECT]", "[REGION]", "[AUTOSCALING_POLICY]") .toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); ApiFuture<Policy> future = clusterControllerClient.getIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); } -
testIamPermissions
Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource( AutoscalingPolicyName.ofProjectRegionAutoscalingPolicyName( "[PROJECT]", "[REGION]", "[AUTOSCALING_POLICY]") .toString()) .addAllPermissions(new ArrayList<String>()) .build(); TestIamPermissionsResponse response = clusterControllerClient.testIamPermissions(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
testIamPermissionsCallable
public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource( AutoscalingPolicyName.ofProjectRegionAutoscalingPolicyName( "[PROJECT]", "[REGION]", "[AUTOSCALING_POLICY]") .toString()) .addAllPermissions(new ArrayList<String>()) .build(); ApiFuture<TestIamPermissionsResponse> future = clusterControllerClient.testIamPermissionsCallable().futureCall(request); // Do something. TestIamPermissionsResponse response = future.get(); } -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceBackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceBackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceBackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNowin interfaceBackgroundResource
-
awaitTermination
- Specified by:
awaitTerminationin interfaceBackgroundResource- Throws:
InterruptedException
-