- 2.55.0 (latest)
- 2.54.0
- 2.53.0
- 2.52.0
- 2.51.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.40.0
- 2.39.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.28.0
- 2.27.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.13
- 2.2.0
- 2.1.23
public class CloudSchedulerClient implements BackgroundResource
Service Description: The Cloud Scheduler API allows external entities to reliably schedule asynchronous 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 for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.getJob(name);
}
Note: close() needs to be called on the CloudSchedulerClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of CloudSchedulerSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
CloudSchedulerSettings cloudSchedulerSettings =
CloudSchedulerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings);
To customize the endpoint:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
CloudSchedulerSettings cloudSchedulerSettings =
CloudSchedulerSettings.newBuilder().setEndpoint(myEndpoint).build();
CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final CloudSchedulerClient create()
Constructs an instance of CloudSchedulerClient with default settings.
Type | Description |
CloudSchedulerClient |
Type | Description |
IOException |
create(CloudSchedulerSettings settings)
public static final CloudSchedulerClient create(CloudSchedulerSettings settings)
Constructs an instance of CloudSchedulerClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | CloudSchedulerSettings |
Type | Description |
CloudSchedulerClient |
Type | Description |
IOException |
create(CloudSchedulerStub stub)
public static final CloudSchedulerClient create(CloudSchedulerStub stub)
Constructs an instance of CloudSchedulerClient, using the given stub for making calls. This is for advanced usage - prefer using create(CloudSchedulerSettings).
Name | Description |
stub | CloudSchedulerStub |
Type | Description |
CloudSchedulerClient |
Constructors
CloudSchedulerClient(CloudSchedulerSettings settings)
protected CloudSchedulerClient(CloudSchedulerSettings settings)
Constructs an instance of CloudSchedulerClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Name | Description |
settings | CloudSchedulerSettings |
CloudSchedulerClient(CloudSchedulerStub stub)
protected CloudSchedulerClient(CloudSchedulerStub stub)
Name | Description |
stub | CloudSchedulerStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
createJob(CreateJobRequest request)
public final Job createJob(CreateJobRequest request)
Creates a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
CreateJobRequest request =
CreateJobRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setJob(Job.newBuilder().build())
.build();
Job response = cloudSchedulerClient.createJob(request);
}
Name | Description |
request | CreateJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
createJob(LocationName parent, Job job)
public final Job createJob(LocationName parent, Job job)
Creates a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Job job = Job.newBuilder().build();
Job response = cloudSchedulerClient.createJob(parent, job);
}
Name | Description |
parent | LocationName Required. The location name. For example:
|
job | Job Required. The job to add. The user can optionally specify a name for the job in name. name cannot be the same as an existing job. If a name is not specified then the system will generate a random unique name that will be returned (name) in the response. |
Type | Description |
Job |
createJob(String parent, Job job)
public final Job createJob(String parent, Job job)
Creates a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
Job job = Job.newBuilder().build();
Job response = cloudSchedulerClient.createJob(parent, job);
}
Name | Description |
parent | String Required. The location name. For example:
|
job | Job Required. The job to add. The user can optionally specify a name for the job in name. name cannot be the same as an existing job. If a name is not specified then the system will generate a random unique name that will be returned (name) in the response. |
Type | Description |
Job |
createJobCallable()
public final UnaryCallable<CreateJobRequest,Job> createJobCallable()
Creates a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
CreateJobRequest request =
CreateJobRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setJob(Job.newBuilder().build())
.build();
ApiFuture<Job> future = cloudSchedulerClient.createJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
UnaryCallable<CreateJobRequest,Job> |
deleteJob(DeleteJobRequest request)
public final void deleteJob(DeleteJobRequest request)
Deletes a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
cloudSchedulerClient.deleteJob(request);
}
Name | Description |
request | DeleteJobRequest The request object containing all of the parameters for the API call. |
deleteJob(JobName name)
public final void deleteJob(JobName name)
Deletes a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
cloudSchedulerClient.deleteJob(name);
}
Name | Description |
name | JobName Required. The job name. For example:
|
deleteJob(String name)
public final void deleteJob(String name)
Deletes a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString();
cloudSchedulerClient.deleteJob(name);
}
Name | Description |
name | String Required. The job name. For example:
|
deleteJobCallable()
public final UnaryCallable<DeleteJobRequest,Empty> deleteJobCallable()
Deletes a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
ApiFuture<Empty> future = cloudSchedulerClient.deleteJobCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DeleteJobRequest,Empty> |
getJob(GetJobRequest request)
public final Job getJob(GetJobRequest request)
Gets a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
GetJobRequest request =
GetJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
Job response = cloudSchedulerClient.getJob(request);
}
Name | Description |
request | GetJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
getJob(JobName name)
public final Job getJob(JobName name)
Gets a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.getJob(name);
}
Name | Description |
name | JobName Required. The job name. For example:
|
Type | Description |
Job |
getJob(String name)
public final Job getJob(String name)
Gets a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString();
Job response = cloudSchedulerClient.getJob(name);
}
Name | Description |
name | String Required. The job name. For example:
|
Type | Description |
Job |
getJobCallable()
public final UnaryCallable<GetJobRequest,Job> getJobCallable()
Gets a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
GetJobRequest request =
GetJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
ApiFuture<Job> future = cloudSchedulerClient.getJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
UnaryCallable<GetJobRequest,Job> |
getSettings()
public final CloudSchedulerSettings getSettings()
Type | Description |
CloudSchedulerSettings |
getStub()
public CloudSchedulerStub getStub()
Type | Description |
CloudSchedulerStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listJobs(ListJobsRequest request)
public final CloudSchedulerClient.ListJobsPagedResponse listJobs(ListJobsRequest request)
Lists jobs.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Job element : cloudSchedulerClient.listJobs(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListJobsRequest The request object containing all of the parameters for the API call. |
Type | Description |
CloudSchedulerClient.ListJobsPagedResponse |
listJobs(LocationName parent)
public final CloudSchedulerClient.ListJobsPagedResponse listJobs(LocationName parent)
Lists jobs.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | LocationName Required. The location name. For example:
|
Type | Description |
CloudSchedulerClient.ListJobsPagedResponse |
listJobs(String parent)
public final CloudSchedulerClient.ListJobsPagedResponse listJobs(String parent)
Lists jobs.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The location name. For example:
|
Type | Description |
CloudSchedulerClient.ListJobsPagedResponse |
listJobsCallable()
public final UnaryCallable<ListJobsRequest,ListJobsResponse> listJobsCallable()
Lists jobs.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListJobsResponse response = cloudSchedulerClient.listJobsCallable().call(request);
for (Job element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListJobsRequest,ListJobsResponse> |
listJobsPagedCallable()
public final UnaryCallable<ListJobsRequest,CloudSchedulerClient.ListJobsPagedResponse> listJobsPagedCallable()
Lists jobs.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Job> future = cloudSchedulerClient.listJobsPagedCallable().futureCall(request);
// Do something.
for (Job element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListJobsRequest,ListJobsPagedResponse> |
pauseJob(JobName name)
public final Job pauseJob(JobName name)
Pauses a job.
If a job is paused then the system will stop executing the job until it is re-enabled via ResumeJob. The state of the job is stored in state; if paused it will be set to Job.State.PAUSED. A job must be in Job.State.ENABLED to be paused.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.pauseJob(name);
}
Name | Description |
name | JobName Required. The job name. For example:
|
Type | Description |
Job |
pauseJob(PauseJobRequest request)
public final Job pauseJob(PauseJobRequest request)
Pauses a job.
If a job is paused then the system will stop executing the job until it is re-enabled via ResumeJob. The state of the job is stored in state; if paused it will be set to Job.State.PAUSED. A job must be in Job.State.ENABLED to be paused.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
PauseJobRequest request =
PauseJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
Job response = cloudSchedulerClient.pauseJob(request);
}
Name | Description |
request | PauseJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
pauseJob(String name)
public final Job pauseJob(String name)
Pauses a job.
If a job is paused then the system will stop executing the job until it is re-enabled via ResumeJob. The state of the job is stored in state; if paused it will be set to Job.State.PAUSED. A job must be in Job.State.ENABLED to be paused.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString();
Job response = cloudSchedulerClient.pauseJob(name);
}
Name | Description |
name | String Required. The job name. For example:
|
Type | Description |
Job |
pauseJobCallable()
public final UnaryCallable<PauseJobRequest,Job> pauseJobCallable()
Pauses a job.
If a job is paused then the system will stop executing the job until it is re-enabled via ResumeJob. The state of the job is stored in state; if paused it will be set to Job.State.PAUSED. A job must be in Job.State.ENABLED to be paused.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
PauseJobRequest request =
PauseJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
ApiFuture<Job> future = cloudSchedulerClient.pauseJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
UnaryCallable<PauseJobRequest,Job> |
resumeJob(JobName name)
public final Job resumeJob(JobName name)
Resume a job.
This method reenables a job after it has been Job.State.PAUSED. The state of a job is stored in Job.state; after calling this method it will be set to Job.State.ENABLED. A job must be in Job.State.PAUSED to be resumed.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.resumeJob(name);
}
Name | Description |
name | JobName Required. The job name. For example:
|
Type | Description |
Job |
resumeJob(ResumeJobRequest request)
public final Job resumeJob(ResumeJobRequest request)
Resume a job.
This method reenables a job after it has been Job.State.PAUSED. The state of a job is stored in Job.state; after calling this method it will be set to Job.State.ENABLED. A job must be in Job.State.PAUSED to be resumed.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
ResumeJobRequest request =
ResumeJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
Job response = cloudSchedulerClient.resumeJob(request);
}
Name | Description |
request | ResumeJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
resumeJob(String name)
public final Job resumeJob(String name)
Resume a job.
This method reenables a job after it has been Job.State.PAUSED. The state of a job is stored in Job.state; after calling this method it will be set to Job.State.ENABLED. A job must be in Job.State.PAUSED to be resumed.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString();
Job response = cloudSchedulerClient.resumeJob(name);
}
Name | Description |
name | String Required. The job name. For example:
|
Type | Description |
Job |
resumeJobCallable()
public final UnaryCallable<ResumeJobRequest,Job> resumeJobCallable()
Resume a job.
This method reenables a job after it has been Job.State.PAUSED. The state of a job is stored in Job.state; after calling this method it will be set to Job.State.ENABLED. A job must be in Job.State.PAUSED to be resumed.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
ResumeJobRequest request =
ResumeJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
ApiFuture<Job> future = cloudSchedulerClient.resumeJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
UnaryCallable<ResumeJobRequest,Job> |
runJob(JobName name)
public final Job runJob(JobName name)
Forces a job to run now.
When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.runJob(name);
}
Name | Description |
name | JobName Required. The job name. For example:
|
Type | Description |
Job |
runJob(RunJobRequest request)
public final Job runJob(RunJobRequest request)
Forces a job to run now.
When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
RunJobRequest request =
RunJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
Job response = cloudSchedulerClient.runJob(request);
}
Name | Description |
request | RunJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
runJob(String name)
public final Job runJob(String name)
Forces a job to run now.
When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString();
Job response = cloudSchedulerClient.runJob(name);
}
Name | Description |
name | String Required. The job name. For example:
|
Type | Description |
Job |
runJobCallable()
public final UnaryCallable<RunJobRequest,Job> runJobCallable()
Forces a job to run now.
When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
RunJobRequest request =
RunJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
ApiFuture<Job> future = cloudSchedulerClient.runJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
UnaryCallable<RunJobRequest,Job> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
updateJob(Job job, FieldMask updateMask)
public final Job updateJob(Job job, FieldMask updateMask)
Updates a job.
If successful, the updated Job is returned. If the job does
not exist, NOT_FOUND
is returned.
If UpdateJob does not successfully return, it is possible for the job to be in an Job.State.UPDATE_FAILED state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
Job job = Job.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Job response = cloudSchedulerClient.updateJob(job, updateMask);
}
Name | Description |
job | Job Required. The new job properties. name must be specified. Output only fields cannot be modified using UpdateJob. Any value specified for an output only field will be ignored. |
updateMask | FieldMask A mask used to specify which fields of the job are being updated. |
Type | Description |
Job |
updateJob(UpdateJobRequest request)
public final Job updateJob(UpdateJobRequest request)
Updates a job.
If successful, the updated Job is returned. If the job does
not exist, NOT_FOUND
is returned.
If UpdateJob does not successfully return, it is possible for the job to be in an Job.State.UPDATE_FAILED state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
UpdateJobRequest request =
UpdateJobRequest.newBuilder()
.setJob(Job.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Job response = cloudSchedulerClient.updateJob(request);
}
Name | Description |
request | UpdateJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
updateJobCallable()
public final UnaryCallable<UpdateJobRequest,Job> updateJobCallable()
Updates a job.
If successful, the updated Job is returned. If the job does
not exist, NOT_FOUND
is returned.
If UpdateJob does not successfully return, it is possible for the job to be in an Job.State.UPDATE_FAILED state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
UpdateJobRequest request =
UpdateJobRequest.newBuilder()
.setJob(Job.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Job> future = cloudSchedulerClient.updateJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
UnaryCallable<UpdateJobRequest,Job> |