@Generated(value="by gapic-generator-java") public class JobsClient 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 (JobsClient jobsClient = JobsClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = jobsClient.getJob(name);
}
Note: close() needs to be called on the JobsClient 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 |
Creates 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.
|
GetJob |
Gets information about 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.
|
ListJobs |
Lists Jobs. Results are sorted by creation time, descending. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateJob |
Updates 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.
|
DeleteJob |
Deletes 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.
|
RunJob |
Triggers creation of a new Execution of this 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.
|
GetIamPolicy |
Gets the IAM Access Control policy currently in effect for the given Job. This result does not include any inherited policies. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
SetIamPolicy |
Sets the IAM Access control policy for the specified Job. Overwrites any existing policy. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
TestIamPermissions |
Returns permissions that a caller has on the specified Project. There are no permissions required for making this API call. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of JobsSettings 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
JobsSettings jobsSettings =
JobsSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
JobsClient jobsClient = JobsClient.create(jobsSettings);
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
JobsSettings jobsSettings = JobsSettings.newBuilder().setEndpoint(myEndpoint).build();
JobsClient jobsClient = JobsClient.create(jobsSettings);
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
JobsSettings jobsSettings = JobsSettings.newHttpJsonBuilder().build();
JobsClient jobsClient = JobsClient.create(jobsSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
JobsClient.ListJobsFixedSizeCollection |
static class |
JobsClient.ListJobsPage |
static class |
JobsClient.ListJobsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
JobsClient(JobsSettings settings)
Constructs an instance of JobsClient, using the given settings.
|
protected |
JobsClient(JobsStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static JobsClient |
create()
Constructs an instance of JobsClient with default settings.
|
static JobsClient |
create(JobsSettings settings)
Constructs an instance of JobsClient, using the given settings.
|
static JobsClient |
create(JobsStub stub)
Constructs an instance of JobsClient, using the given stub for making calls.
|
com.google.api.gax.longrunning.OperationFuture<Job,Job> |
createJobAsync(CreateJobRequest request)
Creates a Job.
|
com.google.api.gax.longrunning.OperationFuture<Job,Job> |
createJobAsync(LocationName parent,
Job job,
String jobId)
Creates a Job.
|
com.google.api.gax.longrunning.OperationFuture<Job,Job> |
createJobAsync(String parent,
Job job,
String jobId)
Creates a Job.
|
com.google.api.gax.rpc.UnaryCallable<CreateJobRequest,com.google.longrunning.Operation> |
createJobCallable()
Creates a Job.
|
com.google.api.gax.rpc.OperationCallable<CreateJobRequest,Job,Job> |
createJobOperationCallable()
Creates a Job.
|
com.google.api.gax.longrunning.OperationFuture<Job,Job> |
deleteJobAsync(DeleteJobRequest request)
Deletes a Job.
|
com.google.api.gax.longrunning.OperationFuture<Job,Job> |
deleteJobAsync(JobName name)
Deletes a Job.
|
com.google.api.gax.longrunning.OperationFuture<Job,Job> |
deleteJobAsync(String name)
Deletes a Job.
|
com.google.api.gax.rpc.UnaryCallable<DeleteJobRequest,com.google.longrunning.Operation> |
deleteJobCallable()
Deletes a Job.
|
com.google.api.gax.rpc.OperationCallable<DeleteJobRequest,Job,Job> |
deleteJobOperationCallable()
Deletes 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.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the IAM Access Control policy currently in effect for the given Job.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getIamPolicyCallable()
Gets the IAM Access Control policy currently in effect for the given Job.
|
Job |
getJob(GetJobRequest request)
Gets information about a Job.
|
Job |
getJob(JobName name)
Gets information about a Job.
|
Job |
getJob(String name)
Gets information about a Job.
|
com.google.api.gax.rpc.UnaryCallable<GetJobRequest,Job> |
getJobCallable()
Gets information about a Job.
|
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.
|
JobsSettings |
getSettings() |
JobsStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
JobsClient.ListJobsPagedResponse |
listJobs(ListJobsRequest request)
Lists Jobs.
|
JobsClient.ListJobsPagedResponse |
listJobs(LocationName parent)
Lists Jobs.
|
JobsClient.ListJobsPagedResponse |
listJobs(String parent)
Lists Jobs.
|
com.google.api.gax.rpc.UnaryCallable<ListJobsRequest,ListJobsResponse> |
listJobsCallable()
Lists Jobs.
|
com.google.api.gax.rpc.UnaryCallable<ListJobsRequest,JobsClient.ListJobsPagedResponse> |
listJobsPagedCallable()
Lists Jobs.
|
com.google.api.gax.longrunning.OperationFuture<Execution,Execution> |
runJobAsync(JobName name)
Triggers creation of a new Execution of this Job.
|
com.google.api.gax.longrunning.OperationFuture<Execution,Execution> |
runJobAsync(RunJobRequest request)
Triggers creation of a new Execution of this Job.
|
com.google.api.gax.longrunning.OperationFuture<Execution,Execution> |
runJobAsync(String name)
Triggers creation of a new Execution of this Job.
|
com.google.api.gax.rpc.UnaryCallable<RunJobRequest,com.google.longrunning.Operation> |
runJobCallable()
Triggers creation of a new Execution of this Job.
|
com.google.api.gax.rpc.OperationCallable<RunJobRequest,Execution,Execution> |
runJobOperationCallable()
Triggers creation of a new Execution of this Job.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the IAM Access control policy for the specified Job.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
setIamPolicyCallable()
Sets the IAM Access control policy for the specified Job.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Returns permissions that a caller has on the specified Project.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
testIamPermissionsCallable()
Returns permissions that a caller has on the specified Project.
|
com.google.api.gax.longrunning.OperationFuture<Job,Job> |
updateJobAsync(Job job)
Updates a Job.
|
com.google.api.gax.longrunning.OperationFuture<Job,Job> |
updateJobAsync(UpdateJobRequest request)
Updates a Job.
|
com.google.api.gax.rpc.UnaryCallable<UpdateJobRequest,com.google.longrunning.Operation> |
updateJobCallable()
Updates a Job.
|
com.google.api.gax.rpc.OperationCallable<UpdateJobRequest,Job,Job> |
updateJobOperationCallable()
Updates a Job.
|
protected JobsClient(JobsSettings settings) throws IOException
IOExceptionprotected JobsClient(JobsStub stub)
public static final JobsClient create() throws IOException
IOExceptionpublic static final JobsClient create(JobsSettings settings) throws IOException
IOExceptionpublic static final JobsClient create(JobsStub stub)
public final JobsSettings getSettings()
public JobsStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
public final com.google.api.gax.longrunning.OperationFuture<Job,Job> createJobAsync(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 (JobsClient jobsClient = JobsClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Job job = Job.newBuilder().build();
String jobId = "jobId101296568";
Job response = jobsClient.createJobAsync(parent, job, jobId).get();
}
parent - Required. The location and project in which this Job should be created. Format:
projects/{project}/locations/{location}, where {project} can be project id or number.job - Required. The Job instance to create.jobId - Required. The unique identifier for the Job. The name of the job becomes
{parent}/jobs/{job_id}.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Job,Job> createJobAsync(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 (JobsClient jobsClient = JobsClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
Job job = Job.newBuilder().build();
String jobId = "jobId101296568";
Job response = jobsClient.createJobAsync(parent, job, jobId).get();
}
parent - Required. The location and project in which this Job should be created. Format:
projects/{project}/locations/{location}, where {project} can be project id or number.job - Required. The Job instance to create.jobId - Required. The unique identifier for the Job. The name of the job becomes
{parent}/jobs/{job_id}.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Job,Job> createJobAsync(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 (JobsClient jobsClient = JobsClient.create()) {
CreateJobRequest request =
CreateJobRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setJob(Job.newBuilder().build())
.setJobId("jobId101296568")
.setValidateOnly(true)
.build();
Job response = jobsClient.createJobAsync(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<CreateJobRequest,Job,Job> createJobOperationCallable()
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 (JobsClient jobsClient = JobsClient.create()) {
CreateJobRequest request =
CreateJobRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setJob(Job.newBuilder().build())
.setJobId("jobId101296568")
.setValidateOnly(true)
.build();
OperationFuture<Job, Job> future =
jobsClient.createJobOperationCallable().futureCall(request);
// Do something.
Job response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<CreateJobRequest,com.google.longrunning.Operation> 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 (JobsClient jobsClient = JobsClient.create()) {
CreateJobRequest request =
CreateJobRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setJob(Job.newBuilder().build())
.setJobId("jobId101296568")
.setValidateOnly(true)
.build();
ApiFuture<Operation> future = jobsClient.createJobCallable().futureCall(request);
// Do something.
Operation 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 (JobsClient jobsClient = JobsClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = jobsClient.getJob(name);
}
name - Required. The full name of the Job. Format:
projects/{project}/locations/{location}/jobs/{job}, where {project} can be project id or
number.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 (JobsClient jobsClient = JobsClient.create()) {
String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString();
Job response = jobsClient.getJob(name);
}
name - Required. The full name of the Job. Format:
projects/{project}/locations/{location}/jobs/{job}, where {project} can be project id or
number.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 (JobsClient jobsClient = JobsClient.create()) {
GetJobRequest request =
GetJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
Job response = jobsClient.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 (JobsClient jobsClient = JobsClient.create()) {
GetJobRequest request =
GetJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
ApiFuture<Job> future = jobsClient.getJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
public final JobsClient.ListJobsPagedResponse listJobs(LocationName parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (JobsClient jobsClient = JobsClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Job element : jobsClient.listJobs(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The location and project to list resources on. Format:
projects/{project}/locations/{location}, where {project} can be project id or number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final JobsClient.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 (JobsClient jobsClient = JobsClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (Job element : jobsClient.listJobs(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The location and project to list resources on. Format:
projects/{project}/locations/{location}, where {project} can be project id or number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final JobsClient.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 (JobsClient jobsClient = JobsClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setShowDeleted(true)
.build();
for (Job element : jobsClient.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,JobsClient.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 (JobsClient jobsClient = JobsClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setShowDeleted(true)
.build();
ApiFuture<Job> future = jobsClient.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 (JobsClient jobsClient = JobsClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setShowDeleted(true)
.build();
while (true) {
ListJobsResponse response = jobsClient.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 com.google.api.gax.longrunning.OperationFuture<Job,Job> updateJobAsync(Job 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 (JobsClient jobsClient = JobsClient.create()) {
Job job = Job.newBuilder().build();
Job response = jobsClient.updateJobAsync(job).get();
}
job - Required. The Job to be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Job,Job> updateJobAsync(UpdateJobRequest 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 (JobsClient jobsClient = JobsClient.create()) {
UpdateJobRequest request =
UpdateJobRequest.newBuilder()
.setJob(Job.newBuilder().build())
.setValidateOnly(true)
.setAllowMissing(true)
.build();
Job response = jobsClient.updateJobAsync(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<UpdateJobRequest,Job,Job> updateJobOperationCallable()
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 (JobsClient jobsClient = JobsClient.create()) {
UpdateJobRequest request =
UpdateJobRequest.newBuilder()
.setJob(Job.newBuilder().build())
.setValidateOnly(true)
.setAllowMissing(true)
.build();
OperationFuture<Job, Job> future =
jobsClient.updateJobOperationCallable().futureCall(request);
// Do something.
Job response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<UpdateJobRequest,com.google.longrunning.Operation> updateJobCallable()
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 (JobsClient jobsClient = JobsClient.create()) {
UpdateJobRequest request =
UpdateJobRequest.newBuilder()
.setJob(Job.newBuilder().build())
.setValidateOnly(true)
.setAllowMissing(true)
.build();
ApiFuture<Operation> future = jobsClient.updateJobCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<Job,Job> deleteJobAsync(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 (JobsClient jobsClient = JobsClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = jobsClient.deleteJobAsync(name).get();
}
name - Required. The full name of the Job. Format:
projects/{project}/locations/{location}/jobs/{job}, where {project} can be project id or
number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Job,Job> 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 (JobsClient jobsClient = JobsClient.create()) {
String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString();
Job response = jobsClient.deleteJobAsync(name).get();
}
name - Required. The full name of the Job. Format:
projects/{project}/locations/{location}/jobs/{job}, where {project} can be project id or
number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Job,Job> 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 (JobsClient jobsClient = JobsClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.setValidateOnly(true)
.setEtag("etag3123477")
.build();
Job response = jobsClient.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,Job,Job> 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 (JobsClient jobsClient = JobsClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.setValidateOnly(true)
.setEtag("etag3123477")
.build();
OperationFuture<Job, Job> future =
jobsClient.deleteJobOperationCallable().futureCall(request);
// Do something.
Job response = 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 (JobsClient jobsClient = JobsClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.setValidateOnly(true)
.setEtag("etag3123477")
.build();
ApiFuture<Operation> future = jobsClient.deleteJobCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<Execution,Execution> runJobAsync(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 (JobsClient jobsClient = JobsClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Execution response = jobsClient.runJobAsync(name).get();
}
name - Required. The full name of the Job. Format:
projects/{project}/locations/{location}/jobs/{job}, where {project} can be project id or
number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Execution,Execution> runJobAsync(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 (JobsClient jobsClient = JobsClient.create()) {
String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString();
Execution response = jobsClient.runJobAsync(name).get();
}
name - Required. The full name of the Job. Format:
projects/{project}/locations/{location}/jobs/{job}, where {project} can be project id or
number.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Execution,Execution> runJobAsync(RunJobRequest 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 (JobsClient jobsClient = JobsClient.create()) {
RunJobRequest request =
RunJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.setValidateOnly(true)
.setEtag("etag3123477")
.setOverrides(RunJobRequest.Overrides.newBuilder().build())
.build();
Execution response = jobsClient.runJobAsync(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<RunJobRequest,Execution,Execution> runJobOperationCallable()
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 (JobsClient jobsClient = JobsClient.create()) {
RunJobRequest request =
RunJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.setValidateOnly(true)
.setEtag("etag3123477")
.setOverrides(RunJobRequest.Overrides.newBuilder().build())
.build();
OperationFuture<Execution, Execution> future =
jobsClient.runJobOperationCallable().futureCall(request);
// Do something.
Execution response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<RunJobRequest,com.google.longrunning.Operation> runJobCallable()
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 (JobsClient jobsClient = JobsClient.create()) {
RunJobRequest request =
RunJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.setValidateOnly(true)
.setEtag("etag3123477")
.setOverrides(RunJobRequest.Overrides.newBuilder().build())
.build();
ApiFuture<Operation> future = jobsClient.runJobCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (JobsClient jobsClient = JobsClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policy response = jobsClient.getIamPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (JobsClient jobsClient = JobsClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy> future = jobsClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (JobsClient jobsClient = JobsClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Policy response = jobsClient.setIamPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (JobsClient jobsClient = JobsClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Policy> future = jobsClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
There are no permissions required for making this API call.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (JobsClient jobsClient = JobsClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
TestIamPermissionsResponse response = jobsClient.testIamPermissions(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
There are no permissions required for making this API call.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (JobsClient jobsClient = JobsClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse> future =
jobsClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestIamPermissionsResponse response = future.get();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2025 Google LLC. All rights reserved.