@Generated(value="by gapic-generator-java") public class WorkerPoolsClient extends Object implements com.google.api.gax.core.BackgroundResource
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
WorkerPoolName name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]");
WorkerPool response = workerPoolsClient.getWorkerPool(name);
}
Note: close() needs to be called on the WorkerPoolsClient 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 |
|---|---|---|
CreateWorkerPool |
Creates a new WorkerPool in a given project and location. |
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.
|
GetWorkerPool |
Gets information about a WorkerPool. |
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.
|
ListWorkerPools |
Lists WorkerPools. Results are sorted by creation time, descending. |
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.
|
UpdateWorkerPool |
Updates a WorkerPool. |
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.
|
DeleteWorkerPool |
Deletes a WorkerPool. |
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.
|
GetIamPolicy |
Gets the IAM Access Control policy currently in effect for the given Cloud Run WorkerPool. This result does not include any inherited policies. |
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.
|
SetIamPolicy |
Sets the IAM Access control policy for the specified WorkerPool. Overwrites any existing policy. |
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 Project. There are no permissions required for making this API call. |
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 WorkerPoolsSettings 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
WorkerPoolsSettings workerPoolsSettings =
WorkerPoolsSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create(workerPoolsSettings);
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
WorkerPoolsSettings workerPoolsSettings =
WorkerPoolsSettings.newBuilder().setEndpoint(myEndpoint).build();
WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create(workerPoolsSettings);
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
WorkerPoolsSettings workerPoolsSettings = WorkerPoolsSettings.newHttpJsonBuilder().build();
WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create(workerPoolsSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
WorkerPoolsClient.ListWorkerPoolsFixedSizeCollection |
static class |
WorkerPoolsClient.ListWorkerPoolsPage |
static class |
WorkerPoolsClient.ListWorkerPoolsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
WorkerPoolsClient(WorkerPoolsSettings settings)
Constructs an instance of WorkerPoolsClient, using the given settings.
|
protected |
WorkerPoolsClient(WorkerPoolsStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static WorkerPoolsClient |
create()
Constructs an instance of WorkerPoolsClient with default settings.
|
static WorkerPoolsClient |
create(WorkerPoolsSettings settings)
Constructs an instance of WorkerPoolsClient, using the given settings.
|
static WorkerPoolsClient |
create(WorkerPoolsStub stub)
Constructs an instance of WorkerPoolsClient, using the given stub for making calls.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> |
createWorkerPoolAsync(CreateWorkerPoolRequest request)
Creates a new WorkerPool in a given project and location.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> |
createWorkerPoolAsync(LocationName parent,
WorkerPool workerPool,
String workerPoolId)
Creates a new WorkerPool in a given project and location.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> |
createWorkerPoolAsync(String parent,
WorkerPool workerPool,
String workerPoolId)
Creates a new WorkerPool in a given project and location.
|
com.google.api.gax.rpc.UnaryCallable<CreateWorkerPoolRequest,com.google.longrunning.Operation> |
createWorkerPoolCallable()
Creates a new WorkerPool in a given project and location.
|
com.google.api.gax.rpc.OperationCallable<CreateWorkerPoolRequest,WorkerPool,WorkerPool> |
createWorkerPoolOperationCallable()
Creates a new WorkerPool in a given project and location.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> |
deleteWorkerPoolAsync(DeleteWorkerPoolRequest request)
Deletes a WorkerPool.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> |
deleteWorkerPoolAsync(String name)
Deletes a WorkerPool.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> |
deleteWorkerPoolAsync(WorkerPoolName name)
Deletes a WorkerPool.
|
com.google.api.gax.rpc.UnaryCallable<DeleteWorkerPoolRequest,com.google.longrunning.Operation> |
deleteWorkerPoolCallable()
Deletes a WorkerPool.
|
com.google.api.gax.rpc.OperationCallable<DeleteWorkerPoolRequest,WorkerPool,WorkerPool> |
deleteWorkerPoolOperationCallable()
Deletes a WorkerPool.
|
com.google.api.gax.httpjson.longrunning.OperationsClient |
getHttpJsonOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the IAM Access Control policy currently in effect for the given Cloud Run WorkerPool.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getIamPolicyCallable()
Gets the IAM Access Control policy currently in effect for the given Cloud Run WorkerPool.
|
com.google.longrunning.OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
WorkerPoolsSettings |
getSettings() |
WorkerPoolsStub |
getStub() |
WorkerPool |
getWorkerPool(GetWorkerPoolRequest request)
Gets information about a WorkerPool.
|
WorkerPool |
getWorkerPool(String name)
Gets information about a WorkerPool.
|
WorkerPool |
getWorkerPool(WorkerPoolName name)
Gets information about a WorkerPool.
|
com.google.api.gax.rpc.UnaryCallable<GetWorkerPoolRequest,WorkerPool> |
getWorkerPoolCallable()
Gets information about a WorkerPool.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
WorkerPoolsClient.ListWorkerPoolsPagedResponse |
listWorkerPools(ListWorkerPoolsRequest request)
Lists WorkerPools.
|
WorkerPoolsClient.ListWorkerPoolsPagedResponse |
listWorkerPools(LocationName parent)
Lists WorkerPools.
|
WorkerPoolsClient.ListWorkerPoolsPagedResponse |
listWorkerPools(String parent)
Lists WorkerPools.
|
com.google.api.gax.rpc.UnaryCallable<ListWorkerPoolsRequest,ListWorkerPoolsResponse> |
listWorkerPoolsCallable()
Lists WorkerPools.
|
com.google.api.gax.rpc.UnaryCallable<ListWorkerPoolsRequest,WorkerPoolsClient.ListWorkerPoolsPagedResponse> |
listWorkerPoolsPagedCallable()
Lists WorkerPools.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the IAM Access control policy for the specified WorkerPool.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
setIamPolicyCallable()
Sets the IAM Access control policy for the specified WorkerPool.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Returns permissions that a caller has on the specified Project.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
testIamPermissionsCallable()
Returns permissions that a caller has on the specified Project.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> |
updateWorkerPoolAsync(UpdateWorkerPoolRequest request)
Updates a WorkerPool.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> |
updateWorkerPoolAsync(WorkerPool workerPool)
Updates a WorkerPool.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> |
updateWorkerPoolAsync(WorkerPool workerPool,
com.google.protobuf.FieldMask updateMask)
Updates a WorkerPool.
|
com.google.api.gax.rpc.UnaryCallable<UpdateWorkerPoolRequest,com.google.longrunning.Operation> |
updateWorkerPoolCallable()
Updates a WorkerPool.
|
com.google.api.gax.rpc.OperationCallable<UpdateWorkerPoolRequest,WorkerPool,WorkerPool> |
updateWorkerPoolOperationCallable()
Updates a WorkerPool.
|
protected WorkerPoolsClient(WorkerPoolsSettings settings) throws IOException
IOExceptionprotected WorkerPoolsClient(WorkerPoolsStub stub)
public static final WorkerPoolsClient create() throws IOException
IOExceptionpublic static final WorkerPoolsClient create(WorkerPoolsSettings settings) throws IOException
IOExceptionpublic static final WorkerPoolsClient create(WorkerPoolsStub stub)
public final WorkerPoolsSettings getSettings()
public WorkerPoolsStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
public final com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> createWorkerPoolAsync(LocationName parent, WorkerPool workerPool, String workerPoolId)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
WorkerPool workerPool = WorkerPool.newBuilder().build();
String workerPoolId = "workerPoolId-46320779";
WorkerPool response =
workerPoolsClient.createWorkerPoolAsync(parent, workerPool, workerPoolId).get();
}
parent - Required. The location and project in which this worker pool should be created.
Format: `projects/{project}/locations/{location}`, where `{project}` can be project id or
number. Only lowercase characters, digits, and hyphens.workerPool - Required. The WorkerPool instance to create.workerPoolId - Required. The unique identifier for the WorkerPool. It must begin with
letter, and cannot end with hyphen; must contain fewer than 50 characters. The name of the
worker pool becomes `{parent}/workerPools/{worker_pool_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> createWorkerPoolAsync(String parent, WorkerPool workerPool, String workerPoolId)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
WorkerPool workerPool = WorkerPool.newBuilder().build();
String workerPoolId = "workerPoolId-46320779";
WorkerPool response =
workerPoolsClient.createWorkerPoolAsync(parent, workerPool, workerPoolId).get();
}
parent - Required. The location and project in which this worker pool should be created.
Format: `projects/{project}/locations/{location}`, where `{project}` can be project id or
number. Only lowercase characters, digits, and hyphens.workerPool - Required. The WorkerPool instance to create.workerPoolId - Required. The unique identifier for the WorkerPool. It must begin with
letter, and cannot end with hyphen; must contain fewer than 50 characters. The name of the
worker pool becomes `{parent}/workerPools/{worker_pool_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> createWorkerPoolAsync(CreateWorkerPoolRequest request)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
CreateWorkerPoolRequest request =
CreateWorkerPoolRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setWorkerPool(WorkerPool.newBuilder().build())
.setWorkerPoolId("workerPoolId-46320779")
.setValidateOnly(true)
.build();
WorkerPool response = workerPoolsClient.createWorkerPoolAsync(request).get();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<CreateWorkerPoolRequest,WorkerPool,WorkerPool> createWorkerPoolOperationCallable()
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
CreateWorkerPoolRequest request =
CreateWorkerPoolRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setWorkerPool(WorkerPool.newBuilder().build())
.setWorkerPoolId("workerPoolId-46320779")
.setValidateOnly(true)
.build();
OperationFuture<WorkerPool, WorkerPool> future =
workerPoolsClient.createWorkerPoolOperationCallable().futureCall(request);
// Do something.
WorkerPool response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<CreateWorkerPoolRequest,com.google.longrunning.Operation> createWorkerPoolCallable()
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
CreateWorkerPoolRequest request =
CreateWorkerPoolRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setWorkerPool(WorkerPool.newBuilder().build())
.setWorkerPoolId("workerPoolId-46320779")
.setValidateOnly(true)
.build();
ApiFuture<Operation> future =
workerPoolsClient.createWorkerPoolCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final WorkerPool getWorkerPool(WorkerPoolName name)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
WorkerPoolName name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]");
WorkerPool response = workerPoolsClient.getWorkerPool(name);
}
name - Required. The full name of the WorkerPool. Format:
`projects/{project}/locations/{location}/workerPools/{worker_pool}`, where `{project}` can
be project id or number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final WorkerPool getWorkerPool(String name)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
String name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString();
WorkerPool response = workerPoolsClient.getWorkerPool(name);
}
name - Required. The full name of the WorkerPool. Format:
`projects/{project}/locations/{location}/workerPools/{worker_pool}`, where `{project}` can
be project id or number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final WorkerPool getWorkerPool(GetWorkerPoolRequest request)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
GetWorkerPoolRequest request =
GetWorkerPoolRequest.newBuilder()
.setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.build();
WorkerPool response = workerPoolsClient.getWorkerPool(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetWorkerPoolRequest,WorkerPool> getWorkerPoolCallable()
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
GetWorkerPoolRequest request =
GetWorkerPoolRequest.newBuilder()
.setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.build();
ApiFuture<WorkerPool> future = workerPoolsClient.getWorkerPoolCallable().futureCall(request);
// Do something.
WorkerPool response = future.get();
}
public final WorkerPoolsClient.ListWorkerPoolsPagedResponse listWorkerPools(LocationName parent)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (WorkerPool element : workerPoolsClient.listWorkerPools(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The location and project to list resources on. Location must be a valid
Google Cloud region, and cannot be the "-" wildcard. Format:
`projects/{project}/locations/{location}`, where `{project}` can be project id or number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final WorkerPoolsClient.ListWorkerPoolsPagedResponse listWorkerPools(String parent)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (WorkerPool element : workerPoolsClient.listWorkerPools(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The location and project to list resources on. Location must be a valid
Google Cloud region, and cannot be the "-" wildcard. Format:
`projects/{project}/locations/{location}`, where `{project}` can be project id or number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final WorkerPoolsClient.ListWorkerPoolsPagedResponse listWorkerPools(ListWorkerPoolsRequest request)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
ListWorkerPoolsRequest request =
ListWorkerPoolsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setShowDeleted(true)
.build();
for (WorkerPool element : workerPoolsClient.listWorkerPools(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListWorkerPoolsRequest,WorkerPoolsClient.ListWorkerPoolsPagedResponse> listWorkerPoolsPagedCallable()
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
ListWorkerPoolsRequest request =
ListWorkerPoolsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setShowDeleted(true)
.build();
ApiFuture<WorkerPool> future =
workerPoolsClient.listWorkerPoolsPagedCallable().futureCall(request);
// Do something.
for (WorkerPool element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListWorkerPoolsRequest,ListWorkerPoolsResponse> listWorkerPoolsCallable()
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
ListWorkerPoolsRequest request =
ListWorkerPoolsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setShowDeleted(true)
.build();
while (true) {
ListWorkerPoolsResponse response =
workerPoolsClient.listWorkerPoolsCallable().call(request);
for (WorkerPool element : response.getWorkerPoolsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> updateWorkerPoolAsync(WorkerPool workerPool)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
WorkerPool workerPool = WorkerPool.newBuilder().build();
WorkerPool response = workerPoolsClient.updateWorkerPoolAsync(workerPool).get();
}
workerPool - Required. The WorkerPool to be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> updateWorkerPoolAsync(WorkerPool workerPool, com.google.protobuf.FieldMask updateMask)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
WorkerPool workerPool = WorkerPool.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
WorkerPool response = workerPoolsClient.updateWorkerPoolAsync(workerPool, updateMask).get();
}
workerPool - Required. The WorkerPool to be updated.updateMask - Optional. The list of fields to be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> updateWorkerPoolAsync(UpdateWorkerPoolRequest request)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
UpdateWorkerPoolRequest request =
UpdateWorkerPoolRequest.newBuilder()
.setUpdateMask(FieldMask.newBuilder().build())
.setWorkerPool(WorkerPool.newBuilder().build())
.setValidateOnly(true)
.setAllowMissing(true)
.setForceNewRevision(true)
.build();
WorkerPool response = workerPoolsClient.updateWorkerPoolAsync(request).get();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<UpdateWorkerPoolRequest,WorkerPool,WorkerPool> updateWorkerPoolOperationCallable()
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
UpdateWorkerPoolRequest request =
UpdateWorkerPoolRequest.newBuilder()
.setUpdateMask(FieldMask.newBuilder().build())
.setWorkerPool(WorkerPool.newBuilder().build())
.setValidateOnly(true)
.setAllowMissing(true)
.setForceNewRevision(true)
.build();
OperationFuture<WorkerPool, WorkerPool> future =
workerPoolsClient.updateWorkerPoolOperationCallable().futureCall(request);
// Do something.
WorkerPool response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<UpdateWorkerPoolRequest,com.google.longrunning.Operation> updateWorkerPoolCallable()
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
UpdateWorkerPoolRequest request =
UpdateWorkerPoolRequest.newBuilder()
.setUpdateMask(FieldMask.newBuilder().build())
.setWorkerPool(WorkerPool.newBuilder().build())
.setValidateOnly(true)
.setAllowMissing(true)
.setForceNewRevision(true)
.build();
ApiFuture<Operation> future =
workerPoolsClient.updateWorkerPoolCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> deleteWorkerPoolAsync(WorkerPoolName name)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
WorkerPoolName name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]");
WorkerPool response = workerPoolsClient.deleteWorkerPoolAsync(name).get();
}
name - Required. The full name of the WorkerPool. Format:
`projects/{project}/locations/{location}/workerPools/{worker_pool}`, where `{project}` can
be project id or number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> deleteWorkerPoolAsync(String name)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
String name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString();
WorkerPool response = workerPoolsClient.deleteWorkerPoolAsync(name).get();
}
name - Required. The full name of the WorkerPool. Format:
`projects/{project}/locations/{location}/workerPools/{worker_pool}`, where `{project}` can
be project id or number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<WorkerPool,WorkerPool> deleteWorkerPoolAsync(DeleteWorkerPoolRequest request)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
DeleteWorkerPoolRequest request =
DeleteWorkerPoolRequest.newBuilder()
.setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.setValidateOnly(true)
.setEtag("etag3123477")
.build();
WorkerPool response = workerPoolsClient.deleteWorkerPoolAsync(request).get();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<DeleteWorkerPoolRequest,WorkerPool,WorkerPool> deleteWorkerPoolOperationCallable()
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
DeleteWorkerPoolRequest request =
DeleteWorkerPoolRequest.newBuilder()
.setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.setValidateOnly(true)
.setEtag("etag3123477")
.build();
OperationFuture<WorkerPool, WorkerPool> future =
workerPoolsClient.deleteWorkerPoolOperationCallable().futureCall(request);
// Do something.
WorkerPool response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<DeleteWorkerPoolRequest,com.google.longrunning.Operation> deleteWorkerPoolCallable()
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
DeleteWorkerPoolRequest request =
DeleteWorkerPoolRequest.newBuilder()
.setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.setValidateOnly(true)
.setEtag("etag3123477")
.build();
ApiFuture<Operation> future =
workerPoolsClient.deleteWorkerPoolCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(
BuildWorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policy response = workerPoolsClient.getIamPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(
BuildWorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy> future = workerPoolsClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(
BuildWorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Policy response = workerPoolsClient.setIamPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(
BuildWorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Policy> future = workerPoolsClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
There are no permissions required for making this API call.
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(
BuildWorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
TestIamPermissionsResponse response = workerPoolsClient.testIamPermissions(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
There are no permissions required for making this API call.
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 (WorkerPoolsClient workerPoolsClient = WorkerPoolsClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(
BuildWorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse> future =
workerPoolsClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestIamPermissionsResponse response = future.get();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2025 Google LLC. All rights reserved.