- 4.50.0 (latest)
- 4.49.0
- 4.48.0
- 4.46.0
- 4.45.0
- 4.44.0
- 4.43.0
- 4.42.0
- 4.41.0
- 4.40.0
- 4.39.0
- 4.38.0
- 4.37.0
- 4.36.0
- 4.34.0
- 4.33.0
- 4.32.0
- 4.31.0
- 4.30.0
- 4.29.0
- 4.28.0
- 4.27.0
- 4.26.0
- 4.25.0
- 4.24.0
- 4.21.0
- 4.20.0
- 4.19.0
- 4.18.0
- 4.17.0
- 4.16.0
- 4.15.0
- 4.14.0
- 4.13.0
- 4.12.0
- 4.11.0
- 4.10.0
- 4.9.0
- 4.8.0
- 4.6.0
- 4.5.0
- 4.4.0
- 4.3.0
- 4.2.0
- 4.1.0
- 4.0.8
- 3.1.2
- 3.0.3
- 2.3.1
public class BatchControllerClient implements BackgroundResource
Service Description: The BatchController provides methods to manage batch workloads.
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:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
BatchName name = BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]");
Batch response = batchControllerClient.getBatch(name);
}
Note: close() needs to be called on the BatchControllerClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns 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 BatchControllerSettings to create(). For example:
To customize credentials:
BatchControllerSettings batchControllerSettings =
BatchControllerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
BatchControllerClient batchControllerClient =
BatchControllerClient.create(batchControllerSettings);
To customize the endpoint:
BatchControllerSettings batchControllerSettings =
BatchControllerSettings.newBuilder().setEndpoint(myEndpoint).build();
BatchControllerClient batchControllerClient =
BatchControllerClient.create(batchControllerSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceConstructors
BatchControllerClient(BatchControllerSettings settings)
protected BatchControllerClient(BatchControllerSettings settings)
Constructs an instance of BatchControllerClient, 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.
Name | Description |
settings | BatchControllerSettings |
BatchControllerClient(BatchControllerStub stub)
protected BatchControllerClient(BatchControllerStub stub)
Name | Description |
stub | BatchControllerStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
create()
public static final BatchControllerClient create()
Constructs an instance of BatchControllerClient with default settings.
Type | Description |
BatchControllerClient |
Type | Description |
IOException |
create(BatchControllerSettings settings)
public static final BatchControllerClient create(BatchControllerSettings settings)
Constructs an instance of BatchControllerClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | BatchControllerSettings |
Type | Description |
BatchControllerClient |
Type | Description |
IOException |
create(BatchControllerStub stub)
public static final BatchControllerClient create(BatchControllerStub stub)
Constructs an instance of BatchControllerClient, using the given stub for making calls. This is for advanced usage - prefer using create(BatchControllerSettings).
Name | Description |
stub | BatchControllerStub |
Type | Description |
BatchControllerClient |
createBatchAsync(CreateBatchRequest request)
public final OperationFuture<Batch,BatchOperationMetadata> createBatchAsync(CreateBatchRequest request)
Creates a batch workload that executes asynchronously.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
CreateBatchRequest request =
CreateBatchRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setBatch(Batch.newBuilder().build())
.setBatchId("batchId-331744779")
.setRequestId("requestId693933066")
.build();
Batch response = batchControllerClient.createBatchAsync(request).get();
}
Name | Description |
request | CreateBatchRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Batch,BatchOperationMetadata> |
createBatchAsync(LocationName parent, Batch batch, String batchId)
public final OperationFuture<Batch,BatchOperationMetadata> createBatchAsync(LocationName parent, Batch batch, String batchId)
Creates a batch workload that executes asynchronously.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Batch batch = Batch.newBuilder().build();
String batchId = "batchId-331744779";
Batch response = batchControllerClient.createBatchAsync(parent, batch, batchId).get();
}
Name | Description |
parent | LocationName Required. The parent resource where this batch will be created. |
batch | Batch Required. The batch to create. |
batchId | String Optional. The ID to use for the batch, which will become the final component of the batch's resource name. This value must be 4-63 characters. Valid characters are |
Type | Description |
OperationFuture<Batch,BatchOperationMetadata> |
createBatchAsync(String parent, Batch batch, String batchId)
public final OperationFuture<Batch,BatchOperationMetadata> createBatchAsync(String parent, Batch batch, String batchId)
Creates a batch workload that executes asynchronously.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
Batch batch = Batch.newBuilder().build();
String batchId = "batchId-331744779";
Batch response = batchControllerClient.createBatchAsync(parent, batch, batchId).get();
}
Name | Description |
parent | String Required. The parent resource where this batch will be created. |
batch | Batch Required. The batch to create. |
batchId | String Optional. The ID to use for the batch, which will become the final component of the batch's resource name. This value must be 4-63 characters. Valid characters are |
Type | Description |
OperationFuture<Batch,BatchOperationMetadata> |
createBatchCallable()
public final UnaryCallable<CreateBatchRequest,Operation> createBatchCallable()
Creates a batch workload that executes asynchronously.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
CreateBatchRequest request =
CreateBatchRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setBatch(Batch.newBuilder().build())
.setBatchId("batchId-331744779")
.setRequestId("requestId693933066")
.build();
ApiFuture<Operation> future = batchControllerClient.createBatchCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
Type | Description |
UnaryCallable<CreateBatchRequest,Operation> |
createBatchOperationCallable()
public final OperationCallable<CreateBatchRequest,Batch,BatchOperationMetadata> createBatchOperationCallable()
Creates a batch workload that executes asynchronously.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
CreateBatchRequest request =
CreateBatchRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setBatch(Batch.newBuilder().build())
.setBatchId("batchId-331744779")
.setRequestId("requestId693933066")
.build();
OperationFuture
Type | Description |
OperationCallable<CreateBatchRequest,Batch,BatchOperationMetadata> |
deleteBatch(BatchName name)
public final void deleteBatch(BatchName name)
Deletes the batch workload resource. If the batch is not in terminal state, the delete fails
and the response returns FAILED_PRECONDITION
.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
BatchName name = BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]");
batchControllerClient.deleteBatch(name);
}
Name | Description |
name | BatchName Required. The name of the batch resource to delete. |
deleteBatch(DeleteBatchRequest request)
public final void deleteBatch(DeleteBatchRequest request)
Deletes the batch workload resource. If the batch is not in terminal state, the delete fails
and the response returns FAILED_PRECONDITION
.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
DeleteBatchRequest request =
DeleteBatchRequest.newBuilder()
.setName(BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]").toString())
.build();
batchControllerClient.deleteBatch(request);
}
Name | Description |
request | DeleteBatchRequest The request object containing all of the parameters for the API call. |
deleteBatch(String name)
public final void deleteBatch(String name)
Deletes the batch workload resource. If the batch is not in terminal state, the delete fails
and the response returns FAILED_PRECONDITION
.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
String name = BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]").toString();
batchControllerClient.deleteBatch(name);
}
Name | Description |
name | String Required. The name of the batch resource to delete. |
deleteBatchCallable()
public final UnaryCallable<DeleteBatchRequest,Empty> deleteBatchCallable()
Deletes the batch workload resource. If the batch is not in terminal state, the delete fails
and the response returns FAILED_PRECONDITION
.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
DeleteBatchRequest request =
DeleteBatchRequest.newBuilder()
.setName(BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]").toString())
.build();
ApiFuture<Empty> future = batchControllerClient.deleteBatchCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DeleteBatchRequest,Empty> |
getBatch(BatchName name)
public final Batch getBatch(BatchName name)
Gets the batch workload resource representation.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
BatchName name = BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]");
Batch response = batchControllerClient.getBatch(name);
}
Name | Description |
name | BatchName Required. The name of the batch to retrieve. |
Type | Description |
Batch |
getBatch(GetBatchRequest request)
public final Batch getBatch(GetBatchRequest request)
Gets the batch workload resource representation.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
GetBatchRequest request =
GetBatchRequest.newBuilder()
.setName(BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]").toString())
.build();
Batch response = batchControllerClient.getBatch(request);
}
Name | Description |
request | GetBatchRequest The request object containing all of the parameters for the API call. |
Type | Description |
Batch |
getBatch(String name)
public final Batch getBatch(String name)
Gets the batch workload resource representation.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
String name = BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]").toString();
Batch response = batchControllerClient.getBatch(name);
}
Name | Description |
name | String Required. The name of the batch to retrieve. |
Type | Description |
Batch |
getBatchCallable()
public final UnaryCallable<GetBatchRequest,Batch> getBatchCallable()
Gets the batch workload resource representation.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
GetBatchRequest request =
GetBatchRequest.newBuilder()
.setName(BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]").toString())
.build();
ApiFuture<Batch> future = batchControllerClient.getBatchCallable().futureCall(request);
// Do something.
Batch response = future.get();
}
Type | Description |
UnaryCallable<GetBatchRequest,Batch> |
getOperationsClient()
public final OperationsClient getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
Type | Description |
OperationsClient |
getSettings()
public final BatchControllerSettings getSettings()
Type | Description |
BatchControllerSettings |
getStub()
public BatchControllerStub getStub()
Type | Description |
BatchControllerStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listBatches(ListBatchesRequest request)
public final BatchControllerClient.ListBatchesPagedResponse listBatches(ListBatchesRequest request)
Lists batch workloads.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
ListBatchesRequest request =
ListBatchesRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Batch element : batchControllerClient.listBatches(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListBatchesRequest The request object containing all of the parameters for the API call. |
Type | Description |
BatchControllerClient.ListBatchesPagedResponse |
listBatches(LocationName parent)
public final BatchControllerClient.ListBatchesPagedResponse listBatches(LocationName parent)
Lists batch workloads.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Batch element : batchControllerClient.listBatches(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | LocationName Required. The parent, which owns this collection of batches. |
Type | Description |
BatchControllerClient.ListBatchesPagedResponse |
listBatches(String parent)
public final BatchControllerClient.ListBatchesPagedResponse listBatches(String parent)
Lists batch workloads.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (Batch element : batchControllerClient.listBatches(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The parent, which owns this collection of batches. |
Type | Description |
BatchControllerClient.ListBatchesPagedResponse |
listBatchesCallable()
public final UnaryCallable<ListBatchesRequest,ListBatchesResponse> listBatchesCallable()
Lists batch workloads.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
ListBatchesRequest request =
ListBatchesRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListBatchesResponse response = batchControllerClient.listBatchesCallable().call(request);
for (Batch element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListBatchesRequest,ListBatchesResponse> |
listBatchesPagedCallable()
public final UnaryCallable<ListBatchesRequest,BatchControllerClient.ListBatchesPagedResponse> listBatchesPagedCallable()
Lists batch workloads.
Sample code:
try (BatchControllerClient batchControllerClient = BatchControllerClient.create()) {
ListBatchesRequest request =
ListBatchesRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Batch> future =
batchControllerClient.listBatchesPagedCallable().futureCall(request);
// Do something.
for (Batch element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListBatchesRequest,ListBatchesPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()