@Generated(value="by gapic-generator-java") public class BatchServiceClient 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Job job = Job.newBuilder().build();
String jobId = "jobId101296568";
Job response = batchServiceClient.createJob(parent, job, jobId);
}
Note: close() needs to be called on the BatchServiceClient 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 |
|---|---|---|
| CreateJob | Create a Job. |
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.
|
| GetJob | Get a Job specified by its resource name. |
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.
|
| DeleteJob | Delete a Job. |
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.
|
| ListJobs | List all Jobs for a project within a region. |
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.
|
| GetTask | Return a single Task. |
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.
|
| ListTasks | List Tasks associated with a job. |
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.
|
| ListLocations | Lists information about the supported locations for this service. |
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.
|
| GetLocation | Gets information about a location. |
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 BatchServiceSettings 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
BatchServiceSettings batchServiceSettings =
BatchServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings);
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
BatchServiceSettings batchServiceSettings =
BatchServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings);
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
BatchServiceSettings batchServiceSettings = BatchServiceSettings.newHttpJsonBuilder().build();
BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
BatchServiceClient.ListJobsFixedSizeCollection |
static class |
BatchServiceClient.ListJobsPage |
static class |
BatchServiceClient.ListJobsPagedResponse |
static class |
BatchServiceClient.ListLocationsFixedSizeCollection |
static class |
BatchServiceClient.ListLocationsPage |
static class |
BatchServiceClient.ListLocationsPagedResponse |
static class |
BatchServiceClient.ListTasksFixedSizeCollection |
static class |
BatchServiceClient.ListTasksPage |
static class |
BatchServiceClient.ListTasksPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
BatchServiceClient(BatchServiceSettings settings)
Constructs an instance of BatchServiceClient, using the given settings.
|
protected |
BatchServiceClient(BatchServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static BatchServiceClient |
create()
Constructs an instance of BatchServiceClient with default settings.
|
static BatchServiceClient |
create(BatchServiceSettings settings)
Constructs an instance of BatchServiceClient, using the given settings.
|
static BatchServiceClient |
create(BatchServiceStub stub)
Constructs an instance of BatchServiceClient, using the given stub for making calls.
|
Job |
createJob(CreateJobRequest request)
Create a Job.
|
Job |
createJob(LocationName parent,
Job job,
String jobId)
Create a Job.
|
Job |
createJob(String parent,
Job job,
String jobId)
Create a Job.
|
com.google.api.gax.rpc.UnaryCallable<CreateJobRequest,Job> |
createJobCallable()
Create a Job.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,OperationMetadata> |
deleteJobAsync(DeleteJobRequest request)
Delete a Job.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,OperationMetadata> |
deleteJobAsync(String name)
Delete a Job.
|
com.google.api.gax.rpc.UnaryCallable<DeleteJobRequest,com.google.longrunning.Operation> |
deleteJobCallable()
Delete a Job.
|
com.google.api.gax.rpc.OperationCallable<DeleteJobRequest,com.google.protobuf.Empty,OperationMetadata> |
deleteJobOperationCallable()
Delete a Job.
|
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.
|
Job |
getJob(GetJobRequest request)
Get a Job specified by its resource name.
|
Job |
getJob(JobName name)
Get a Job specified by its resource name.
|
Job |
getJob(String name)
Get a Job specified by its resource name.
|
com.google.api.gax.rpc.UnaryCallable<GetJobRequest,Job> |
getJobCallable()
Get a Job specified by its resource name.
|
com.google.cloud.location.Location |
getLocation(com.google.cloud.location.GetLocationRequest request)
Gets information about a location.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> |
getLocationCallable()
Gets information about a location.
|
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.
|
BatchServiceSettings |
getSettings() |
BatchServiceStub |
getStub() |
Task |
getTask(GetTaskRequest request)
Return a single Task.
|
Task |
getTask(String name)
Return a single Task.
|
Task |
getTask(TaskName name)
Return a single Task.
|
com.google.api.gax.rpc.UnaryCallable<GetTaskRequest,Task> |
getTaskCallable()
Return a single Task.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
BatchServiceClient.ListJobsPagedResponse |
listJobs(ListJobsRequest request)
List all Jobs for a project within a region.
|
BatchServiceClient.ListJobsPagedResponse |
listJobs(String parent)
List all Jobs for a project within a region.
|
com.google.api.gax.rpc.UnaryCallable<ListJobsRequest,ListJobsResponse> |
listJobsCallable()
List all Jobs for a project within a region.
|
com.google.api.gax.rpc.UnaryCallable<ListJobsRequest,BatchServiceClient.ListJobsPagedResponse> |
listJobsPagedCallable()
List all Jobs for a project within a region.
|
BatchServiceClient.ListLocationsPagedResponse |
listLocations(com.google.cloud.location.ListLocationsRequest request)
Lists information about the supported locations for this service.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> |
listLocationsCallable()
Lists information about the supported locations for this service.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,BatchServiceClient.ListLocationsPagedResponse> |
listLocationsPagedCallable()
Lists information about the supported locations for this service.
|
BatchServiceClient.ListTasksPagedResponse |
listTasks(ListTasksRequest request)
List Tasks associated with a job.
|
BatchServiceClient.ListTasksPagedResponse |
listTasks(String parent)
List Tasks associated with a job.
|
BatchServiceClient.ListTasksPagedResponse |
listTasks(TaskGroupName parent)
List Tasks associated with a job.
|
com.google.api.gax.rpc.UnaryCallable<ListTasksRequest,ListTasksResponse> |
listTasksCallable()
List Tasks associated with a job.
|
com.google.api.gax.rpc.UnaryCallable<ListTasksRequest,BatchServiceClient.ListTasksPagedResponse> |
listTasksPagedCallable()
List Tasks associated with a job.
|
void |
shutdown() |
void |
shutdownNow() |
protected BatchServiceClient(BatchServiceSettings settings) throws IOException
IOExceptionprotected BatchServiceClient(BatchServiceStub stub)
public static final BatchServiceClient create() throws IOException
IOExceptionpublic static final BatchServiceClient create(BatchServiceSettings settings) throws IOException
IOExceptionpublic static final BatchServiceClient create(BatchServiceStub stub)
public final BatchServiceSettings getSettings()
public BatchServiceStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
public final Job createJob(LocationName parent, Job job, String jobId)
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Job job = Job.newBuilder().build();
String jobId = "jobId101296568";
Job response = batchServiceClient.createJob(parent, job, jobId);
}
parent - Required. The parent resource name where the Job will be created. Pattern:
"projects/{project}/locations/{location}"job - Required. The Job to create.jobId - ID used to uniquely identify the Job within its parent scope. This field should
contain at most 63 characters and must start with lowercase characters. Only lowercase
characters, numbers and '-' are accepted. The '-' character cannot be the first or the last
one. A system generated ID will be used if the field is not set.
The job.name field in the request will be ignored and the created resource name of the Job will be "{parent}/jobs/{job_id}".
com.google.api.gax.rpc.ApiException - if the remote call failspublic final Job createJob(String parent, Job job, String jobId)
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
Job job = Job.newBuilder().build();
String jobId = "jobId101296568";
Job response = batchServiceClient.createJob(parent, job, jobId);
}
parent - Required. The parent resource name where the Job will be created. Pattern:
"projects/{project}/locations/{location}"job - Required. The Job to create.jobId - ID used to uniquely identify the Job within its parent scope. This field should
contain at most 63 characters and must start with lowercase characters. Only lowercase
characters, numbers and '-' are accepted. The '-' character cannot be the first or the last
one. A system generated ID will be used if the field is not set.
The job.name field in the request will be ignored and the created resource name of the Job will be "{parent}/jobs/{job_id}".
com.google.api.gax.rpc.ApiException - if the remote call failspublic final Job createJob(CreateJobRequest 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
CreateJobRequest request =
CreateJobRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setJobId("jobId101296568")
.setJob(Job.newBuilder().build())
.setRequestId("requestId693933066")
.build();
Job response = batchServiceClient.createJob(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<CreateJobRequest,Job> createJobCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
CreateJobRequest request =
CreateJobRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setJobId("jobId101296568")
.setJob(Job.newBuilder().build())
.setRequestId("requestId693933066")
.build();
ApiFuture<Job> future = batchServiceClient.createJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
public final Job getJob(JobName 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = batchServiceClient.getJob(name);
}
name - Required. Job name.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Job getJob(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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString();
Job response = batchServiceClient.getJob(name);
}
name - Required. Job name.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Job getJob(GetJobRequest 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
GetJobRequest request =
GetJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
Job response = batchServiceClient.getJob(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<GetJobRequest,Job> getJobCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
GetJobRequest request =
GetJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
ApiFuture<Job> future = batchServiceClient.getJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,OperationMetadata> deleteJobAsync(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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String name = "name3373707";
batchServiceClient.deleteJobAsync(name).get();
}
name - Job name.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,OperationMetadata> deleteJobAsync(DeleteJobRequest 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setName("name3373707")
.setReason("reason-934964668")
.setRequestId("requestId693933066")
.build();
batchServiceClient.deleteJobAsync(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<DeleteJobRequest,com.google.protobuf.Empty,OperationMetadata> deleteJobOperationCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setName("name3373707")
.setReason("reason-934964668")
.setRequestId("requestId693933066")
.build();
OperationFuture<Empty, OperationMetadata> future =
batchServiceClient.deleteJobOperationCallable().futureCall(request);
// Do something.
future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<DeleteJobRequest,com.google.longrunning.Operation> deleteJobCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setName("name3373707")
.setReason("reason-934964668")
.setRequestId("requestId693933066")
.build();
ApiFuture<Operation> future = batchServiceClient.deleteJobCallable().futureCall(request);
// Do something.
future.get();
}
public final BatchServiceClient.ListJobsPagedResponse listJobs(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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String parent = "parent-995424086";
for (Job element : batchServiceClient.listJobs(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Parent path.com.google.api.gax.rpc.ApiException - if the remote call failspublic final BatchServiceClient.ListJobsPagedResponse listJobs(ListJobsRequest 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent("parent-995424086")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Job element : batchServiceClient.listJobs(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<ListJobsRequest,BatchServiceClient.ListJobsPagedResponse> listJobsPagedCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent("parent-995424086")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Job> future = batchServiceClient.listJobsPagedCallable().futureCall(request);
// Do something.
for (Job element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListJobsRequest,ListJobsResponse> listJobsCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent("parent-995424086")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListJobsResponse response = batchServiceClient.listJobsCallable().call(request);
for (Job element : response.getJobsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Task getTask(TaskName 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]");
Task response = batchServiceClient.getTask(name);
}
name - Required. Task name.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Task getTask(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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String name =
TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]").toString();
Task response = batchServiceClient.getTask(name);
}
name - Required. Task name.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Task getTask(GetTaskRequest 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
GetTaskRequest request =
GetTaskRequest.newBuilder()
.setName(
TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]")
.toString())
.build();
Task response = batchServiceClient.getTask(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<GetTaskRequest,Task> getTaskCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
GetTaskRequest request =
GetTaskRequest.newBuilder()
.setName(
TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]")
.toString())
.build();
ApiFuture<Task> future = batchServiceClient.getTaskCallable().futureCall(request);
// Do something.
Task response = future.get();
}
public final BatchServiceClient.ListTasksPagedResponse listTasks(TaskGroupName 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
TaskGroupName parent = TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]");
for (Task element : batchServiceClient.listTasks(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Name of a TaskGroup from which Tasks are being requested. Pattern:
"projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}"com.google.api.gax.rpc.ApiException - if the remote call failspublic final BatchServiceClient.ListTasksPagedResponse listTasks(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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String parent =
TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString();
for (Task element : batchServiceClient.listTasks(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Name of a TaskGroup from which Tasks are being requested. Pattern:
"projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}"com.google.api.gax.rpc.ApiException - if the remote call failspublic final BatchServiceClient.ListTasksPagedResponse listTasks(ListTasksRequest 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListTasksRequest request =
ListTasksRequest.newBuilder()
.setParent(
TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Task element : batchServiceClient.listTasks(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<ListTasksRequest,BatchServiceClient.ListTasksPagedResponse> listTasksPagedCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListTasksRequest request =
ListTasksRequest.newBuilder()
.setParent(
TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Task> future = batchServiceClient.listTasksPagedCallable().futureCall(request);
// Do something.
for (Task element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListTasksRequest,ListTasksResponse> listTasksCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListTasksRequest request =
ListTasksRequest.newBuilder()
.setParent(
TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListTasksResponse response = batchServiceClient.listTasksCallable().call(request);
for (Task element : response.getTasksList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final BatchServiceClient.ListLocationsPagedResponse listLocations(com.google.cloud.location.ListLocationsRequest 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Location element : batchServiceClient.listLocations(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<com.google.cloud.location.ListLocationsRequest,BatchServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location> future =
batchServiceClient.listLocationsPagedCallable().futureCall(request);
// Do something.
for (Location element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> listLocationsCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListLocationsResponse response = batchServiceClient.listLocationsCallable().call(request);
for (Location element : response.getLocationsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.cloud.location.Location getLocation(com.google.cloud.location.GetLocationRequest 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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
Location response = batchServiceClient.getLocation(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.cloud.location.GetLocationRequest,com.google.cloud.location.Location> getLocationCallable()
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 (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
ApiFuture<Location> future = batchServiceClient.getLocationCallable().futureCall(request);
// Do something.
Location 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 © 2024 Google LLC. All rights reserved.