
com.google.cloud.dataproc.v1.ClusterControllerClient 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;
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.dataproc.v1.stub.ClusterControllerStub;
import com.google.cloud.dataproc.v1.stub.ClusterControllerStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
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.protobuf.Empty;
import com.google.protobuf.FieldMask;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* Service Description: The ClusterControllerService provides methods to manage clusters of Compute
* Engine instances.
*
* 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:
*
*
{@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);
* }
* }
*
* 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().
*
*
* Methods
*
* 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.
*
* createClusterAsync(CreateClusterRequest request)
*
* Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
*
* createClusterAsync(String projectId, String region, Cluster cluster)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* createClusterOperationCallable()
*
createClusterCallable()
*
*
*
*
* 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.
*
* updateClusterAsync(UpdateClusterRequest request)
*
* Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
*
* updateClusterAsync(String projectId, String region, String clusterName, Cluster cluster, FieldMask updateMask)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* updateClusterOperationCallable()
*
updateClusterCallable()
*
*
*
*
* 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.
*
* stopClusterAsync(StopClusterRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* stopClusterOperationCallable()
*
stopClusterCallable()
*
*
*
*
* 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.
*
* startClusterAsync(StartClusterRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* startClusterOperationCallable()
*
startClusterCallable()
*
*
*
*
* 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.
*
* deleteClusterAsync(DeleteClusterRequest request)
*
* Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
*
* deleteClusterAsync(String projectId, String region, String clusterName)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* deleteClusterOperationCallable()
*
deleteClusterCallable()
*
*
*
*
* 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.
*
* getCluster(GetClusterRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* getCluster(String projectId, String region, String clusterName)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* getClusterCallable()
*
*
*
*
* 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.
*
* listClusters(ListClustersRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* listClusters(String projectId, String region)
*
listClusters(String projectId, String region, String filter)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* listClustersPagedCallable()
*
listClustersCallable()
*
*
*
*
* 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.
*
* diagnoseClusterAsync(DiagnoseClusterRequest request)
*
* Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
*
* diagnoseClusterAsync(String projectId, String region, String clusterName)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* diagnoseClusterOperationCallable()
*
diagnoseClusterCallable()
*
*
*
*
* 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.
*
* setIamPolicy(SetIamPolicyRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* setIamPolicyCallable()
*
*
*
*
* 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.
*
* getIamPolicy(GetIamPolicyRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* getIamPolicyCallable()
*
*
*
*
* 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.
*
* testIamPermissions(TestIamPermissionsRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* testIamPermissionsCallable()
*
*
*
*
*
* 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:
*
*
{@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
* ClusterControllerSettings clusterControllerSettings =
* ClusterControllerSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* ClusterControllerClient clusterControllerClient =
* ClusterControllerClient.create(clusterControllerSettings);
* }
*
* To customize the endpoint:
*
*
{@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
* 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:
*
*
{@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
* ClusterControllerSettings clusterControllerSettings =
* ClusterControllerSettings.newHttpJsonBuilder().build();
* ClusterControllerClient clusterControllerClient =
* ClusterControllerClient.create(clusterControllerSettings);
* }
*
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class ClusterControllerClient implements BackgroundResource {
private final ClusterControllerSettings settings;
private final ClusterControllerStub stub;
private final OperationsClient httpJsonOperationsClient;
private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of ClusterControllerClient with default settings. */
public static final ClusterControllerClient create() throws IOException {
return create(ClusterControllerSettings.newBuilder().build());
}
/**
* 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.
*/
public static final ClusterControllerClient create(ClusterControllerSettings settings)
throws IOException {
return new ClusterControllerClient(settings);
}
/**
* Constructs an instance of ClusterControllerClient, using the given stub for making calls. This
* is for advanced usage - prefer using create(ClusterControllerSettings).
*/
public static final ClusterControllerClient create(ClusterControllerStub stub) {
return new ClusterControllerClient(stub);
}
/**
* 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.
*/
protected ClusterControllerClient(ClusterControllerSettings settings) throws IOException {
this.settings = settings;
this.stub = ((ClusterControllerStubSettings) settings.getStubSettings()).createStub();
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
protected ClusterControllerClient(ClusterControllerStub stub) {
this.settings = null;
this.stub = stub;
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
public final ClusterControllerSettings getSettings() {
return settings;
}
public ClusterControllerStub getStub() {
return stub;
}
/**
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}
/**
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
@BetaApi
public final OperationsClient getHttpJsonOperationsClient() {
return httpJsonOperationsClient;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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();
* }
* }
*
* @param projectId Required. The ID of the Google Cloud Platform project that the cluster belongs
* to.
* @param region Required. The Dataproc region in which to handle the request.
* @param cluster Required. The cluster to create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture createClusterAsync(
String projectId, String region, Cluster cluster) {
CreateClusterRequest request =
CreateClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setCluster(cluster)
.build();
return createClusterAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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();
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture createClusterAsync(
CreateClusterRequest request) {
return createClusterOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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 future =
* clusterControllerClient.createClusterOperationCallable().futureCall(request);
* // Do something.
* Cluster response = future.get();
* }
* }
*/
public final OperationCallable
createClusterOperationCallable() {
return stub.createClusterOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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 future =
* clusterControllerClient.createClusterCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable createClusterCallable() {
return stub.createClusterCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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();
* }
* }
*
* @param projectId Required. The ID of the Google Cloud Platform project the cluster belongs to.
* @param region Required. The Dataproc region in which to handle the request.
* @param clusterName Required. The cluster name.
* @param cluster Required. The changes to the cluster.
* @param 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 com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture updateClusterAsync(
String projectId, String region, String clusterName, Cluster cluster, FieldMask updateMask) {
UpdateClusterRequest request =
UpdateClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.setCluster(cluster)
.setUpdateMask(updateMask)
.build();
return updateClusterAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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();
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture updateClusterAsync(
UpdateClusterRequest request) {
return updateClusterOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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 future =
* clusterControllerClient.updateClusterOperationCallable().futureCall(request);
* // Do something.
* Cluster response = future.get();
* }
* }
*/
public final OperationCallable
updateClusterOperationCallable() {
return stub.updateClusterOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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 future =
* clusterControllerClient.updateClusterCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable updateClusterCallable() {
return stub.updateClusterCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Stops a cluster in a project.
*
* Sample code:
*
*
{@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();
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture stopClusterAsync(
StopClusterRequest request) {
return stopClusterOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Stops a cluster in a project.
*
* Sample code:
*
*
{@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 future =
* clusterControllerClient.stopClusterOperationCallable().futureCall(request);
* // Do something.
* Cluster response = future.get();
* }
* }
*/
public final OperationCallable
stopClusterOperationCallable() {
return stub.stopClusterOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Stops a cluster in a project.
*
* Sample code:
*
*
{@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 future =
* clusterControllerClient.stopClusterCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable stopClusterCallable() {
return stub.stopClusterCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Starts a cluster in a project.
*
* Sample code:
*
*
{@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();
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture startClusterAsync(
StartClusterRequest request) {
return startClusterOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Starts a cluster in a project.
*
* Sample code:
*
*
{@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 future =
* clusterControllerClient.startClusterOperationCallable().futureCall(request);
* // Do something.
* Cluster response = future.get();
* }
* }
*/
public final OperationCallable
startClusterOperationCallable() {
return stub.startClusterOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Starts a cluster in a project.
*
* Sample code:
*
*
{@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 future =
* clusterControllerClient.startClusterCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable startClusterCallable() {
return stub.startClusterCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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();
* }
* }
*
* @param projectId Required. The ID of the Google Cloud Platform project that the cluster belongs
* to.
* @param region Required. The Dataproc region in which to handle the request.
* @param clusterName Required. The cluster name.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture deleteClusterAsync(
String projectId, String region, String clusterName) {
DeleteClusterRequest request =
DeleteClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.build();
return deleteClusterAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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();
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture deleteClusterAsync(
DeleteClusterRequest request) {
return deleteClusterOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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 future =
* clusterControllerClient.deleteClusterOperationCallable().futureCall(request);
* // Do something.
* future.get();
* }
* }
*/
public final OperationCallable
deleteClusterOperationCallable() {
return stub.deleteClusterOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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 future =
* clusterControllerClient.deleteClusterCallable().futureCall(request);
* // Do something.
* future.get();
* }
* }
*/
public final UnaryCallable deleteClusterCallable() {
return stub.deleteClusterCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the resource representation for a cluster in a project.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param projectId Required. The ID of the Google Cloud Platform project that the cluster belongs
* to.
* @param region Required. The Dataproc region in which to handle the request.
* @param clusterName Required. The cluster name.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Cluster getCluster(String projectId, String region, String clusterName) {
GetClusterRequest request =
GetClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.build();
return getCluster(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the resource representation for a cluster in a project.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Cluster getCluster(GetClusterRequest request) {
return getClusterCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the resource representation for a cluster in a project.
*
* Sample code:
*
*
{@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 future = clusterControllerClient.getClusterCallable().futureCall(request);
* // Do something.
* Cluster response = future.get();
* }
* }
*/
public final UnaryCallable getClusterCallable() {
return stub.getClusterCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists all regions/{region}/clusters in a project alphabetically.
*
* Sample code:
*
*
{@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);
* }
* }
* }
*
* @param projectId Required. The ID of the Google Cloud Platform project that the cluster belongs
* to.
* @param region Required. The Dataproc region in which to handle the request.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListClustersPagedResponse listClusters(String projectId, String region) {
ListClustersRequest request =
ListClustersRequest.newBuilder().setProjectId(projectId).setRegion(region).build();
return listClusters(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists all regions/{region}/clusters in a project alphabetically.
*
* Sample code:
*
*
{@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);
* }
* }
* }
*
* @param projectId Required. The ID of the Google Cloud Platform project that the cluster belongs
* to.
* @param region Required. The Dataproc region in which to handle the request.
* @param 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 com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListClustersPagedResponse listClusters(
String projectId, String region, String filter) {
ListClustersRequest request =
ListClustersRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setFilter(filter)
.build();
return listClusters(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists all regions/{region}/clusters in a project alphabetically.
*
*
Sample code:
*
*
{@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);
* }
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListClustersPagedResponse listClusters(ListClustersRequest request) {
return listClustersPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists all regions/{region}/clusters in a project alphabetically.
*
* Sample code:
*
*
{@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 future =
* clusterControllerClient.listClustersPagedCallable().futureCall(request);
* // Do something.
* for (Cluster element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable
listClustersPagedCallable() {
return stub.listClustersPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists all regions/{region}/clusters in a project alphabetically.
*
* Sample code:
*
*
{@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;
* }
* }
* }
* }
*/
public final UnaryCallable listClustersCallable() {
return stub.listClustersCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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();
* }
* }
*
* @param projectId Required. The ID of the Google Cloud Platform project that the cluster belongs
* to.
* @param region Required. The Dataproc region in which to handle the request.
* @param clusterName Required. The cluster name.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture
diagnoseClusterAsync(String projectId, String region, String clusterName) {
DiagnoseClusterRequest request =
DiagnoseClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.build();
return diagnoseClusterAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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())
* .addAllYarnApplicationIds(new ArrayList())
* .build();
* DiagnoseClusterResults response = clusterControllerClient.diagnoseClusterAsync(request).get();
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture
diagnoseClusterAsync(DiagnoseClusterRequest request) {
return diagnoseClusterOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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())
* .addAllYarnApplicationIds(new ArrayList())
* .build();
* OperationFuture future =
* clusterControllerClient.diagnoseClusterOperationCallable().futureCall(request);
* // Do something.
* DiagnoseClusterResults response = future.get();
* }
* }
*/
public final OperationCallable<
DiagnoseClusterRequest, DiagnoseClusterResults, ClusterOperationMetadata>
diagnoseClusterOperationCallable() {
return stub.diagnoseClusterOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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())
* .addAllYarnApplicationIds(new ArrayList())
* .build();
* ApiFuture future =
* clusterControllerClient.diagnoseClusterCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable diagnoseClusterCallable() {
return stub.diagnoseClusterCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the access control policy on the specified resource. Replacesany existing policy.
*
* Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.
*
*
Sample code:
*
*
{@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);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy setIamPolicy(SetIamPolicyRequest request) {
return setIamPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the access control policy on the specified resource. Replacesany existing policy.
*
* Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.
*
*
Sample code:
*
*
{@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 future = clusterControllerClient.setIamPolicyCallable().futureCall(request);
* // Do something.
* Policy response = future.get();
* }
* }
*/
public final UnaryCallable setIamPolicyCallable() {
return stub.setIamPolicyCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the access control policy for a resource. Returns an empty policyif the resource exists
* and does not have a policy set.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy getIamPolicy(GetIamPolicyRequest request) {
return getIamPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the access control policy for a resource. Returns an empty policyif the resource exists
* and does not have a policy set.
*
* Sample code:
*
*
{@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 future = clusterControllerClient.getIamPolicyCallable().futureCall(request);
* // Do something.
* Policy response = future.get();
* }
* }
*/
public final UnaryCallable getIamPolicyCallable() {
return stub.getIamPolicyCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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())
* .build();
* TestIamPermissionsResponse response = clusterControllerClient.testIamPermissions(request);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) {
return testIamPermissionsCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
{@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())
* .build();
* ApiFuture future =
* clusterControllerClient.testIamPermissionsCallable().futureCall(request);
* // Do something.
* TestIamPermissionsResponse response = future.get();
* }
* }
*/
public final UnaryCallable
testIamPermissionsCallable() {
return stub.testIamPermissionsCallable();
}
@Override
public final void close() {
stub.close();
}
@Override
public void shutdown() {
stub.shutdown();
}
@Override
public boolean isShutdown() {
return stub.isShutdown();
}
@Override
public boolean isTerminated() {
return stub.isTerminated();
}
@Override
public void shutdownNow() {
stub.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}
public static class ListClustersPagedResponse
extends AbstractPagedListResponse<
ListClustersRequest,
ListClustersResponse,
Cluster,
ListClustersPage,
ListClustersFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListClustersPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListClustersPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListClustersPagedResponse(ListClustersPage page) {
super(page, ListClustersFixedSizeCollection.createEmptyCollection());
}
}
public static class ListClustersPage
extends AbstractPage {
private ListClustersPage(
PageContext context,
ListClustersResponse response) {
super(context, response);
}
private static ListClustersPage createEmptyPage() {
return new ListClustersPage(null, null);
}
@Override
protected ListClustersPage createPage(
PageContext context,
ListClustersResponse response) {
return new ListClustersPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListClustersFixedSizeCollection
extends AbstractFixedSizeCollection<
ListClustersRequest,
ListClustersResponse,
Cluster,
ListClustersPage,
ListClustersFixedSizeCollection> {
private ListClustersFixedSizeCollection(List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListClustersFixedSizeCollection createEmptyCollection() {
return new ListClustersFixedSizeCollection(null, 0);
}
@Override
protected ListClustersFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListClustersFixedSizeCollection(pages, collectionSize);
}
}
}