Class BatchServiceClient (0.12.0)

public class BatchServiceClient implements BackgroundResource

Service Description: Google Batch Service. The service manages user submitted batch jobs and allocates Google Compute Engine VM instances to run the jobs.

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().

The surface of this class includes several types of Java methods for each of the API's methods:

  1. 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.
  2. 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.
  3. 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 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.

Inheritance

java.lang.Object > BatchServiceClient

Implements

BackgroundResource

Static Methods

create()

public static final BatchServiceClient create()

Constructs an instance of BatchServiceClient with default settings.

Returns
TypeDescription
BatchServiceClient
Exceptions
TypeDescription
IOException

create(BatchServiceSettings settings)

public static final BatchServiceClient create(BatchServiceSettings settings)

Constructs an instance of BatchServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
NameDescription
settingsBatchServiceSettings
Returns
TypeDescription
BatchServiceClient
Exceptions
TypeDescription
IOException

create(BatchServiceStub stub)

public static final BatchServiceClient create(BatchServiceStub stub)

Constructs an instance of BatchServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(BatchServiceSettings).

Parameter
NameDescription
stubBatchServiceStub
Returns
TypeDescription
BatchServiceClient

Constructors

BatchServiceClient(BatchServiceSettings settings)

protected BatchServiceClient(BatchServiceSettings settings)

Constructs an instance of BatchServiceClient, 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.

Parameter
NameDescription
settingsBatchServiceSettings

BatchServiceClient(BatchServiceStub stub)

protected BatchServiceClient(BatchServiceStub stub)
Parameter
NameDescription
stubBatchServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

createJob(CreateJobRequest request)

public final Job createJob(CreateJobRequest request)

Create a Job.

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);
 }
 
Parameter
NameDescription
requestCreateJobRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Job

createJob(LocationName parent, Job job, String jobId)

public final Job createJob(LocationName parent, Job job, String jobId)

Create a Job.

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);
 }
 
Parameters
NameDescription
parentLocationName

Required. The parent resource name where the Job will be created. Pattern: "projects/{project}/locations/{location}"

jobJob

Required. The Job to create.

jobIdString

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}".

Returns
TypeDescription
Job

createJob(String parent, Job job, String jobId)

public final Job createJob(String parent, Job job, String jobId)

Create a Job.

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);
 }
 
Parameters
NameDescription
parentString

Required. The parent resource name where the Job will be created. Pattern: "projects/{project}/locations/{location}"

jobJob

Required. The Job to create.

jobIdString

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}".

Returns
TypeDescription
Job

createJobCallable()

public final UnaryCallable<CreateJobRequest,Job> createJobCallable()

Create a Job.

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();
 }
 
Returns
TypeDescription
UnaryCallable<CreateJobRequest,Job>

deleteJobAsync(DeleteJobRequest request)

public final OperationFuture<Empty,OperationMetadata> deleteJobAsync(DeleteJobRequest request)

Delete a Job.

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();
 }
 
Parameter
NameDescription
requestDeleteJobRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Empty,OperationMetadata>

deleteJobAsync(String name)

public final OperationFuture<Empty,OperationMetadata> deleteJobAsync(String name)

Delete a Job.

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();
 }
 
Parameter
NameDescription
nameString

Job name.

Returns
TypeDescription
OperationFuture<Empty,OperationMetadata>

deleteJobCallable()

public final UnaryCallable<DeleteJobRequest,Operation> deleteJobCallable()

Delete a Job.

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();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteJobRequest,Operation>

deleteJobOperationCallable()

public final OperationCallable<DeleteJobRequest,Empty,OperationMetadata> deleteJobOperationCallable()

Delete a Job.

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();
 }
 
Returns
TypeDescription
OperationCallable<DeleteJobRequest,Empty,OperationMetadata>

getHttpJsonOperationsClient()

public final OperationsClient getHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getIamPolicy(GetIamPolicyRequest request)

public final Policy getIamPolicy(GetIamPolicyRequest request)

Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
   GetIamPolicyRequest request =
       GetIamPolicyRequest.newBuilder()
           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
           .setOptions(GetPolicyOptions.newBuilder().build())
           .build();
   Policy response = batchServiceClient.getIamPolicy(request);
 }
 
Parameter
NameDescription
requestcom.google.iam.v1.GetIamPolicyRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
com.google.iam.v1.Policy

getIamPolicyCallable()

public final UnaryCallable<GetIamPolicyRequest,Policy> getIamPolicyCallable()

Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
   GetIamPolicyRequest request =
       GetIamPolicyRequest.newBuilder()
           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
           .setOptions(GetPolicyOptions.newBuilder().build())
           .build();
   ApiFuture<Policy> future = batchServiceClient.getIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy>

getJob(GetJobRequest request)

public final Job getJob(GetJobRequest request)

Get a Job specified by its resource 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()) {
   GetJobRequest request =
       GetJobRequest.newBuilder()
           .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
           .build();
   Job response = batchServiceClient.getJob(request);
 }
 
Parameter
NameDescription
requestGetJobRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Job

getJob(JobName name)

public final Job getJob(JobName name)

Get a Job specified by its resource 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);
 }
 
Parameter
NameDescription
nameJobName

Required. Job name.

Returns
TypeDescription
Job

getJob(String name)

public final Job getJob(String name)

Get a Job specified by its resource 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);
 }
 
Parameter
NameDescription
nameString

Required. Job name.

Returns
TypeDescription
Job

getJobCallable()

public final UnaryCallable<GetJobRequest,Job> getJobCallable()

Get a Job specified by its resource 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()) {
   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();
 }
 
Returns
TypeDescription
UnaryCallable<GetJobRequest,Job>

getLocation(GetLocationRequest request)

public final Location getLocation(GetLocationRequest request)

Gets information about a location.

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);
 }
 
Parameter
NameDescription
requestcom.google.cloud.location.GetLocationRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
com.google.cloud.location.Location

getLocationCallable()

public final UnaryCallable<GetLocationRequest,Location> getLocationCallable()

Gets information about a location.

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();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location>

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.

Returns
TypeDescription
OperationsClient

getSettings()

public final BatchServiceSettings getSettings()
Returns
TypeDescription
BatchServiceSettings

getStub()

public BatchServiceStub getStub()
Returns
TypeDescription
BatchServiceStub

getTask(GetTaskRequest request)

public final Task getTask(GetTaskRequest request)

Return a single Task.

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);
 }
 
Parameter
NameDescription
requestGetTaskRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Task

getTask(TaskName name)

public final Task getTask(TaskName name)

Return a single Task.

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);
 }
 
Parameter
NameDescription
nameTaskName

Required. Task name.

Returns
TypeDescription
Task

getTask(String name)

public final Task getTask(String name)

Return a single Task.

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);
 }
 
Parameter
NameDescription
nameString

Required. Task name.

Returns
TypeDescription
Task

getTaskCallable()

public final UnaryCallable<GetTaskRequest,Task> getTaskCallable()

Return a single Task.

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();
 }
 
Returns
TypeDescription
UnaryCallable<GetTaskRequest,Task>

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listJobs(ListJobsRequest request)

public final BatchServiceClient.ListJobsPagedResponse listJobs(ListJobsRequest request)

List all Jobs for a project within a region.

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")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Job element : batchServiceClient.listJobs(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListJobsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
BatchServiceClient.ListJobsPagedResponse

listJobs(String parent)

public final BatchServiceClient.ListJobsPagedResponse listJobs(String parent)

List all Jobs for a project within a region.

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);
   }
 }
 
Parameter
NameDescription
parentString

Parent path.

Returns
TypeDescription
BatchServiceClient.ListJobsPagedResponse

listJobsCallable()

public final UnaryCallable<ListJobsRequest,ListJobsResponse> listJobsCallable()

List all Jobs for a project within a region.

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")
           .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;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListJobsRequest,ListJobsResponse>

listJobsPagedCallable()

public final UnaryCallable<ListJobsRequest,BatchServiceClient.ListJobsPagedResponse> listJobsPagedCallable()

List all Jobs for a project within a region.

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")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Job> future = batchServiceClient.listJobsPagedCallable().futureCall(request);
   // Do something.
   for (Job element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListJobsRequest,ListJobsPagedResponse>

listLocations(ListLocationsRequest request)

public final BatchServiceClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request)

Lists information about the supported locations for this service.

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);
   }
 }
 
Parameter
NameDescription
requestcom.google.cloud.location.ListLocationsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
BatchServiceClient.ListLocationsPagedResponse

listLocationsCallable()

public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> listLocationsCallable()

Lists information about the supported locations for this service.

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;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse>

listLocationsPagedCallable()

public final UnaryCallable<ListLocationsRequest,BatchServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()

Lists information about the supported locations for this service.

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);
   }
 }
 
Returns
TypeDescription
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ListLocationsPagedResponse>

listTasks(ListTasksRequest request)

public final BatchServiceClient.ListTasksPagedResponse listTasks(ListTasksRequest request)

List Tasks associated with a job.

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);
   }
 }
 
Parameter
NameDescription
requestListTasksRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
BatchServiceClient.ListTasksPagedResponse

listTasks(TaskGroupName parent)

public final BatchServiceClient.ListTasksPagedResponse listTasks(TaskGroupName parent)

List Tasks associated with a job.

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);
   }
 }
 
Parameter
NameDescription
parentTaskGroupName

Required. Name of a TaskGroup from which Tasks are being requested. Pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}"

Returns
TypeDescription
BatchServiceClient.ListTasksPagedResponse

listTasks(String parent)

public final BatchServiceClient.ListTasksPagedResponse listTasks(String parent)

List Tasks associated with a job.

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);
   }
 }
 
Parameter
NameDescription
parentString

Required. Name of a TaskGroup from which Tasks are being requested. Pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}"

Returns
TypeDescription
BatchServiceClient.ListTasksPagedResponse

listTasksCallable()

public final UnaryCallable<ListTasksRequest,ListTasksResponse> listTasksCallable()

List Tasks associated with a job.

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;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListTasksRequest,ListTasksResponse>

listTasksPagedCallable()

public final UnaryCallable<ListTasksRequest,BatchServiceClient.ListTasksPagedResponse> listTasksPagedCallable()

List Tasks associated with a job.

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);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListTasksRequest,ListTasksPagedResponse>

setIamPolicy(SetIamPolicyRequest request)

public final Policy setIamPolicy(SetIamPolicyRequest request)

Sets the access control policy on the specified resource. Replacesany existing policy.

Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIEDerrors.

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()) {
   SetIamPolicyRequest request =
       SetIamPolicyRequest.newBuilder()
           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
           .setPolicy(Policy.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Policy response = batchServiceClient.setIamPolicy(request);
 }
 
Parameter
NameDescription
requestcom.google.iam.v1.SetIamPolicyRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
com.google.iam.v1.Policy

setIamPolicyCallable()

public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()

Sets the access control policy on the specified resource. Replacesany existing policy.

Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIEDerrors.

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()) {
   SetIamPolicyRequest request =
       SetIamPolicyRequest.newBuilder()
           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
           .setPolicy(Policy.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Policy> future = batchServiceClient.setIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

testIamPermissions(TestIamPermissionsRequest request)

public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)

Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a NOT_FOUND error.

Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
   TestIamPermissionsRequest request =
       TestIamPermissionsRequest.newBuilder()
           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
           .addAllPermissions(new ArrayList<String>())
           .build();
   TestIamPermissionsResponse response = batchServiceClient.testIamPermissions(request);
 }
 
Parameter
NameDescription
requestcom.google.iam.v1.TestIamPermissionsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissionsCallable()

public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()

Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a NOT_FOUND error.

Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
   TestIamPermissionsRequest request =
       TestIamPermissionsRequest.newBuilder()
           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
           .addAllPermissions(new ArrayList<String>())
           .build();
   ApiFuture<TestIamPermissionsResponse> future =
       batchServiceClient.testIamPermissionsCallable().futureCall(request);
   // Do something.
   TestIamPermissionsResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse>