@Generated(value="by gapic-generator") @BetaApi public class CloudSchedulerClient extends Object implements 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:
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:
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:
CloudSchedulerSettings cloudSchedulerSettings =
CloudSchedulerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CloudSchedulerClient cloudSchedulerClient =
CloudSchedulerClient.create(cloudSchedulerSettings);
To customize the endpoint:
CloudSchedulerSettings cloudSchedulerSettings =
CloudSchedulerSettings.newBuilder().setEndpoint(myEndpoint).build();
CloudSchedulerClient cloudSchedulerClient =
CloudSchedulerClient.create(cloudSchedulerSettings);
Modifier and Type | Class and Description |
---|---|
static class |
CloudSchedulerClient.ListJobsFixedSizeCollection |
static class |
CloudSchedulerClient.ListJobsPage |
static class |
CloudSchedulerClient.ListJobsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
CloudSchedulerClient(CloudSchedulerSettings settings)
Constructs an instance of CloudSchedulerClient, using the given settings.
|
protected |
CloudSchedulerClient(CloudSchedulerStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static CloudSchedulerClient |
create()
Constructs an instance of CloudSchedulerClient with default settings.
|
static CloudSchedulerClient |
create(CloudSchedulerSettings settings)
Constructs an instance of CloudSchedulerClient, using the given settings.
|
static CloudSchedulerClient |
create(CloudSchedulerStub stub)
Constructs an instance of CloudSchedulerClient, using the given stub for making calls.
|
com.google.cloud.scheduler.v1beta1.Job |
createJob(com.google.cloud.scheduler.v1beta1.CreateJobRequest request)
Creates a job.
|
com.google.cloud.scheduler.v1beta1.Job |
createJob(com.google.cloud.scheduler.v1beta1.LocationName parent,
com.google.cloud.scheduler.v1beta1.Job job)
Creates a job.
|
com.google.cloud.scheduler.v1beta1.Job |
createJob(String parent,
com.google.cloud.scheduler.v1beta1.Job job)
Creates a job.
|
UnaryCallable<com.google.cloud.scheduler.v1beta1.CreateJobRequest,com.google.cloud.scheduler.v1beta1.Job> |
createJobCallable()
Creates a job.
|
void |
deleteJob(com.google.cloud.scheduler.v1beta1.DeleteJobRequest request)
Deletes a job.
|
void |
deleteJob(com.google.cloud.scheduler.v1beta1.JobName name)
Deletes a job.
|
void |
deleteJob(String name)
Deletes a job.
|
UnaryCallable<com.google.cloud.scheduler.v1beta1.DeleteJobRequest,Empty> |
deleteJobCallable()
Deletes a job.
|
com.google.cloud.scheduler.v1beta1.Job |
getJob(com.google.cloud.scheduler.v1beta1.GetJobRequest request)
Gets a job.
|
com.google.cloud.scheduler.v1beta1.Job |
getJob(com.google.cloud.scheduler.v1beta1.JobName name)
Gets a job.
|
com.google.cloud.scheduler.v1beta1.Job |
getJob(String name)
Gets a job.
|
UnaryCallable<com.google.cloud.scheduler.v1beta1.GetJobRequest,com.google.cloud.scheduler.v1beta1.Job> |
getJobCallable()
Gets a job.
|
CloudSchedulerSettings |
getSettings() |
CloudSchedulerStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
CloudSchedulerClient.ListJobsPagedResponse |
listJobs(com.google.cloud.scheduler.v1beta1.ListJobsRequest request)
Lists jobs.
|
CloudSchedulerClient.ListJobsPagedResponse |
listJobs(com.google.cloud.scheduler.v1beta1.LocationName parent)
Lists jobs.
|
CloudSchedulerClient.ListJobsPagedResponse |
listJobs(String parent)
Lists jobs.
|
UnaryCallable<com.google.cloud.scheduler.v1beta1.ListJobsRequest,com.google.cloud.scheduler.v1beta1.ListJobsResponse> |
listJobsCallable()
Lists jobs.
|
UnaryCallable<com.google.cloud.scheduler.v1beta1.ListJobsRequest,CloudSchedulerClient.ListJobsPagedResponse> |
listJobsPagedCallable()
Lists jobs.
|
com.google.cloud.scheduler.v1beta1.Job |
pauseJob(com.google.cloud.scheduler.v1beta1.JobName name)
Pauses a job.
|
com.google.cloud.scheduler.v1beta1.Job |
pauseJob(com.google.cloud.scheduler.v1beta1.PauseJobRequest request)
Pauses a job.
|
com.google.cloud.scheduler.v1beta1.Job |
pauseJob(String name)
Pauses a job.
|
UnaryCallable<com.google.cloud.scheduler.v1beta1.PauseJobRequest,com.google.cloud.scheduler.v1beta1.Job> |
pauseJobCallable()
Pauses a job.
|
com.google.cloud.scheduler.v1beta1.Job |
resumeJob(com.google.cloud.scheduler.v1beta1.JobName name)
Resume a job.
|
com.google.cloud.scheduler.v1beta1.Job |
resumeJob(com.google.cloud.scheduler.v1beta1.ResumeJobRequest request)
Resume a job.
|
com.google.cloud.scheduler.v1beta1.Job |
resumeJob(String name)
Resume a job.
|
UnaryCallable<com.google.cloud.scheduler.v1beta1.ResumeJobRequest,com.google.cloud.scheduler.v1beta1.Job> |
resumeJobCallable()
Resume a job.
|
com.google.cloud.scheduler.v1beta1.Job |
runJob(com.google.cloud.scheduler.v1beta1.JobName name)
Forces a job to run now.
|
com.google.cloud.scheduler.v1beta1.Job |
runJob(com.google.cloud.scheduler.v1beta1.RunJobRequest request)
Forces a job to run now.
|
com.google.cloud.scheduler.v1beta1.Job |
runJob(String name)
Forces a job to run now.
|
UnaryCallable<com.google.cloud.scheduler.v1beta1.RunJobRequest,com.google.cloud.scheduler.v1beta1.Job> |
runJobCallable()
Forces a job to run now.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.cloud.scheduler.v1beta1.Job |
updateJob(com.google.cloud.scheduler.v1beta1.Job job,
FieldMask updateMask)
Updates a job.
|
com.google.cloud.scheduler.v1beta1.Job |
updateJob(com.google.cloud.scheduler.v1beta1.UpdateJobRequest request)
Updates a job.
|
UnaryCallable<com.google.cloud.scheduler.v1beta1.UpdateJobRequest,com.google.cloud.scheduler.v1beta1.Job> |
updateJobCallable()
Updates a job.
|
protected CloudSchedulerClient(CloudSchedulerSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected CloudSchedulerClient(CloudSchedulerStub stub)
public static final CloudSchedulerClient create() throws IOException
IOException
public static final CloudSchedulerClient create(CloudSchedulerSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final CloudSchedulerClient create(CloudSchedulerStub stub)
public final CloudSchedulerSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public CloudSchedulerStub getStub()
public final CloudSchedulerClient.ListJobsPagedResponse listJobs(com.google.cloud.scheduler.v1beta1.LocationName parent)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required.
The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`.
ApiException
- if the remote call failspublic final CloudSchedulerClient.ListJobsPagedResponse listJobs(String parent)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Job element : cloudSchedulerClient.listJobs(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required.
The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`.
ApiException
- if the remote call failspublic final CloudSchedulerClient.ListJobsPagedResponse listJobs(com.google.cloud.scheduler.v1beta1.ListJobsRequest request)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListJobsRequest request = ListJobsRequest.newBuilder()
.setParent(parent.toString())
.build();
for (Job element : cloudSchedulerClient.listJobs(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.scheduler.v1beta1.ListJobsRequest,CloudSchedulerClient.ListJobsPagedResponse> listJobsPagedCallable()
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListJobsRequest request = ListJobsRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListJobsPagedResponse> future = cloudSchedulerClient.listJobsPagedCallable().futureCall(request);
// Do something
for (Job element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.cloud.scheduler.v1beta1.ListJobsRequest,com.google.cloud.scheduler.v1beta1.ListJobsResponse> listJobsCallable()
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListJobsRequest request = ListJobsRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListJobsResponse response = cloudSchedulerClient.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.cloud.scheduler.v1beta1.Job getJob(com.google.cloud.scheduler.v1beta1.JobName name)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.getJob(name);
}
name
- Required.
The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
ApiException
- if the remote call failspublic final com.google.cloud.scheduler.v1beta1.Job getJob(String name)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.getJob(name.toString());
}
name
- Required.
The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
ApiException
- if the remote call failspublic final com.google.cloud.scheduler.v1beta1.Job getJob(com.google.cloud.scheduler.v1beta1.GetJobRequest request)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
GetJobRequest request = GetJobRequest.newBuilder()
.setName(name.toString())
.build();
Job response = cloudSchedulerClient.getJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.scheduler.v1beta1.GetJobRequest,com.google.cloud.scheduler.v1beta1.Job> getJobCallable()
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
GetJobRequest request = GetJobRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Job> future = cloudSchedulerClient.getJobCallable().futureCall(request);
// Do something
Job response = future.get();
}
public final com.google.cloud.scheduler.v1beta1.Job createJob(com.google.cloud.scheduler.v1beta1.LocationName parent, com.google.cloud.scheduler.v1beta1.Job job)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Job job = Job.newBuilder().build();
Job response = cloudSchedulerClient.createJob(parent, job);
}
parent
- Required.
The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`.
job
- Required.
The job to add. The user can optionally specify a name for the job in [name][google.cloud.scheduler.v1beta1.Job.name]. [name][google.cloud.scheduler.v1beta1.Job.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][google.cloud.scheduler.v1beta1.Job.name]) in the response.
ApiException
- if the remote call failspublic final com.google.cloud.scheduler.v1beta1.Job createJob(String parent, com.google.cloud.scheduler.v1beta1.Job job)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Job job = Job.newBuilder().build();
Job response = cloudSchedulerClient.createJob(parent.toString(), job);
}
parent
- Required.
The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`.
job
- Required.
The job to add. The user can optionally specify a name for the job in [name][google.cloud.scheduler.v1beta1.Job.name]. [name][google.cloud.scheduler.v1beta1.Job.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][google.cloud.scheduler.v1beta1.Job.name]) in the response.
ApiException
- if the remote call failspublic final com.google.cloud.scheduler.v1beta1.Job createJob(com.google.cloud.scheduler.v1beta1.CreateJobRequest request)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Job job = Job.newBuilder().build();
CreateJobRequest request = CreateJobRequest.newBuilder()
.setParent(parent.toString())
.setJob(job)
.build();
Job response = cloudSchedulerClient.createJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.scheduler.v1beta1.CreateJobRequest,com.google.cloud.scheduler.v1beta1.Job> createJobCallable()
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Job job = Job.newBuilder().build();
CreateJobRequest request = CreateJobRequest.newBuilder()
.setParent(parent.toString())
.setJob(job)
.build();
ApiFuture<Job> future = cloudSchedulerClient.createJobCallable().futureCall(request);
// Do something
Job response = future.get();
}
public final com.google.cloud.scheduler.v1beta1.Job updateJob(com.google.cloud.scheduler.v1beta1.Job job, FieldMask updateMask)
If successful, the updated [Job][google.cloud.scheduler.v1beta1.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][google.cloud.scheduler.v1beta1.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:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
Job job = Job.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Job response = cloudSchedulerClient.updateJob(job, updateMask);
}
job
- Required.
The new job properties. [name][google.cloud.scheduler.v1beta1.Job.name] must be specified.
Output only fields cannot be modified using UpdateJob. Any value specified for an output only field will be ignored.
updateMask
- A mask used to specify which fields of the job are being updated.ApiException
- if the remote call failspublic final com.google.cloud.scheduler.v1beta1.Job updateJob(com.google.cloud.scheduler.v1beta1.UpdateJobRequest request)
If successful, the updated [Job][google.cloud.scheduler.v1beta1.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][google.cloud.scheduler.v1beta1.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:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
Job job = Job.newBuilder().build();
UpdateJobRequest request = UpdateJobRequest.newBuilder()
.setJob(job)
.build();
Job response = cloudSchedulerClient.updateJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.scheduler.v1beta1.UpdateJobRequest,com.google.cloud.scheduler.v1beta1.Job> updateJobCallable()
If successful, the updated [Job][google.cloud.scheduler.v1beta1.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][google.cloud.scheduler.v1beta1.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:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
Job job = Job.newBuilder().build();
UpdateJobRequest request = UpdateJobRequest.newBuilder()
.setJob(job)
.build();
ApiFuture<Job> future = cloudSchedulerClient.updateJobCallable().futureCall(request);
// Do something
Job response = future.get();
}
public final void deleteJob(com.google.cloud.scheduler.v1beta1.JobName name)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
cloudSchedulerClient.deleteJob(name);
}
name
- Required.
The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
ApiException
- if the remote call failspublic final void deleteJob(String name)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
cloudSchedulerClient.deleteJob(name.toString());
}
name
- Required.
The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
ApiException
- if the remote call failspublic final void deleteJob(com.google.cloud.scheduler.v1beta1.DeleteJobRequest request)
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
DeleteJobRequest request = DeleteJobRequest.newBuilder()
.setName(name.toString())
.build();
cloudSchedulerClient.deleteJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.scheduler.v1beta1.DeleteJobRequest,Empty> deleteJobCallable()
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
DeleteJobRequest request = DeleteJobRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> future = cloudSchedulerClient.deleteJobCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.cloud.scheduler.v1beta1.Job pauseJob(com.google.cloud.scheduler.v1beta1.JobName name)
If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be paused.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.pauseJob(name);
}
name
- Required.
The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
ApiException
- if the remote call failspublic final com.google.cloud.scheduler.v1beta1.Job pauseJob(String name)
If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be paused.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.pauseJob(name.toString());
}
name
- Required.
The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
ApiException
- if the remote call failspublic final com.google.cloud.scheduler.v1beta1.Job pauseJob(com.google.cloud.scheduler.v1beta1.PauseJobRequest request)
If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be paused.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
PauseJobRequest request = PauseJobRequest.newBuilder()
.setName(name.toString())
.build();
Job response = cloudSchedulerClient.pauseJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.scheduler.v1beta1.PauseJobRequest,com.google.cloud.scheduler.v1beta1.Job> pauseJobCallable()
If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be paused.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
PauseJobRequest request = PauseJobRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Job> future = cloudSchedulerClient.pauseJobCallable().futureCall(request);
// Do something
Job response = future.get();
}
public final com.google.cloud.scheduler.v1beta1.Job resumeJob(com.google.cloud.scheduler.v1beta1.JobName name)
This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be resumed.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.resumeJob(name);
}
name
- Required.
The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
ApiException
- if the remote call failspublic final com.google.cloud.scheduler.v1beta1.Job resumeJob(String name)
This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be resumed.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.resumeJob(name.toString());
}
name
- Required.
The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
ApiException
- if the remote call failspublic final com.google.cloud.scheduler.v1beta1.Job resumeJob(com.google.cloud.scheduler.v1beta1.ResumeJobRequest request)
This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be resumed.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
ResumeJobRequest request = ResumeJobRequest.newBuilder()
.setName(name.toString())
.build();
Job response = cloudSchedulerClient.resumeJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.scheduler.v1beta1.ResumeJobRequest,com.google.cloud.scheduler.v1beta1.Job> resumeJobCallable()
This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be resumed.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
ResumeJobRequest request = ResumeJobRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Job> future = cloudSchedulerClient.resumeJobCallable().futureCall(request);
// Do something
Job response = future.get();
}
public final com.google.cloud.scheduler.v1beta1.Job runJob(com.google.cloud.scheduler.v1beta1.JobName name)
When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.runJob(name);
}
name
- Required.
The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
ApiException
- if the remote call failspublic final com.google.cloud.scheduler.v1beta1.Job runJob(String name)
When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = cloudSchedulerClient.runJob(name.toString());
}
name
- Required.
The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
ApiException
- if the remote call failspublic final com.google.cloud.scheduler.v1beta1.Job runJob(com.google.cloud.scheduler.v1beta1.RunJobRequest request)
When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
RunJobRequest request = RunJobRequest.newBuilder()
.setName(name.toString())
.build();
Job response = cloudSchedulerClient.runJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.scheduler.v1beta1.RunJobRequest,com.google.cloud.scheduler.v1beta1.Job> runJobCallable()
When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.
Sample code:
try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
RunJobRequest request = RunJobRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Job> future = cloudSchedulerClient.runJobCallable().futureCall(request);
// Do something
Job response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.