Class CloudSchedulerClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
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 (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().
| Method | Description | Method Variants |
|---|---|---|
ListJobs |
Lists jobs. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetJob |
Gets 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.
|
CreateJob |
Creates 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.
|
UpdateJob |
Updates a job. 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. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteJob |
Deletes 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.
|
PauseJob |
Pauses a job. 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. |
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.
|
ResumeJob |
Resume a job. 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. |
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.
|
RunJob |
Forces a job to run now. When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListLocations |
Lists information about the supported locations for this service. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetLocation |
Gets information about a location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of CloudSchedulerSettings 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
CloudSchedulerSettings cloudSchedulerSettings =
CloudSchedulerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings);
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
CloudSchedulerSettings cloudSchedulerSettings =
CloudSchedulerSettings.newBuilder().setEndpoint(myEndpoint).build();
CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings);
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
CloudSchedulerSettings cloudSchedulerSettings =
CloudSchedulerSettings.newHttpJsonBuilder().build();
CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCloudSchedulerClient(CloudSchedulerSettings settings) Constructs an instance of CloudSchedulerClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) final voidclose()static final CloudSchedulerClientcreate()Constructs an instance of CloudSchedulerClient with default settings.static final CloudSchedulerClientcreate(CloudSchedulerSettings settings) Constructs an instance of CloudSchedulerClient, using the given settings.static final CloudSchedulerClientcreate(CloudSchedulerStub stub) Constructs an instance of CloudSchedulerClient, using the given stub for making calls.final JobcreateJob(CreateJobRequest request) Creates a job.final JobcreateJob(LocationName parent, Job job) Creates a job.final JobCreates a job.final UnaryCallable<CreateJobRequest,Job> Creates a job.final voiddeleteJob(DeleteJobRequest request) Deletes a job.final voidDeletes a job.final voidDeletes a job.final UnaryCallable<DeleteJobRequest,com.google.protobuf.Empty> Deletes a job.final JobgetJob(GetJobRequest request) Gets a job.final JobGets a job.final JobGets a job.final UnaryCallable<GetJobRequest,Job> Gets a job.final LocationgetLocation(GetLocationRequest request) Gets information about a location.Gets information about a location.final CloudSchedulerSettingsgetStub()booleanbooleanlistJobs(ListJobsRequest request) Lists jobs.listJobs(LocationName parent) Lists jobs.Lists jobs.Lists jobs.Lists jobs.listLocations(ListLocationsRequest request) Lists information about the supported locations for this service.Lists information about the supported locations for this service.Lists information about the supported locations for this service.final JobPauses a job.final JobpauseJob(PauseJobRequest request) Pauses a job.final JobPauses a job.final UnaryCallable<PauseJobRequest,Job> Pauses a job.final JobResume a job.final JobresumeJob(ResumeJobRequest request) Resume a job.final JobResume a job.final UnaryCallable<ResumeJobRequest,Job> Resume a job.final JobForces a job to run now.final JobrunJob(RunJobRequest request) Forces a job to run now.final JobForces a job to run now.final UnaryCallable<RunJobRequest,Job> Forces a job to run now.voidshutdown()voidfinal JobUpdates a job.final JobupdateJob(UpdateJobRequest request) Updates a job.final UnaryCallable<UpdateJobRequest,Job> Updates a job.
-
Constructor Details
-
CloudSchedulerClient
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.- Throws:
IOException
-
CloudSchedulerClient
-
-
Method Details
-
create
Constructs an instance of CloudSchedulerClient with default settings.- Throws:
IOException
-
create
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.- Throws:
IOException
-
create
Constructs an instance of CloudSchedulerClient, using the given stub for making calls. This is for advanced usage - prefer using create(CloudSchedulerSettings). -
getSettings
-
getStub
-
listJobs
Lists jobs.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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`.- Throws:
ApiException- if the remote call fails
-
listJobs
Lists jobs.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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`.- Throws:
ApiException- if the remote call fails
-
listJobs
Lists jobs.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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { ListJobsRequest request = ListJobsRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .setLegacyAppEngineCron(true) .build(); for (Job element : cloudSchedulerClient.listJobs(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listJobsPagedCallable
public final UnaryCallable<ListJobsRequest,CloudSchedulerClient.ListJobsPagedResponse> listJobsPagedCallable()Lists jobs.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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { ListJobsRequest request = ListJobsRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .setLegacyAppEngineCron(true) .build(); ApiFuture<Job> future = cloudSchedulerClient.listJobsPagedCallable().futureCall(request); // Do something. for (Job element : future.get().iterateAll()) { // doThingsWith(element); } } -
listJobsCallable
Lists jobs.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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { ListJobsRequest request = ListJobsRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .setLegacyAppEngineCron(true) .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; } } } -
getJob
Gets a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); Job response = cloudSchedulerClient.getJob(name); }- Parameters:
name- Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.- Throws:
ApiException- if the remote call fails
-
getJob
Gets a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); Job response = cloudSchedulerClient.getJob(name); }- Parameters:
name- Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.- Throws:
ApiException- if the remote call fails
-
getJob
Gets a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { GetJobRequest request = GetJobRequest.newBuilder() .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) .build(); Job response = cloudSchedulerClient.getJob(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getJobCallable
Gets a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (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(); } -
createJob
Creates a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); Job job = Job.newBuilder().build(); Job response = cloudSchedulerClient.createJob(parent, job); }- Parameters:
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.- Throws:
ApiException- if the remote call fails
-
createJob
Creates a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); Job job = Job.newBuilder().build(); Job response = cloudSchedulerClient.createJob(parent, job); }- Parameters:
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.- Throws:
ApiException- if the remote call fails
-
createJob
Creates a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { CreateJobRequest request = CreateJobRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setJob(Job.newBuilder().build()) .build(); Job response = cloudSchedulerClient.createJob(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createJobCallable
Creates a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (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(); } -
updateJob
Updates a job.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:
// 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { Job job = Job.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); Job response = cloudSchedulerClient.updateJob(job, updateMask); }- Parameters:
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.- Throws:
ApiException- if the remote call fails
-
updateJob
Updates a job.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:
// 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { UpdateJobRequest request = UpdateJobRequest.newBuilder() .setJob(Job.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Job response = cloudSchedulerClient.updateJob(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
updateJobCallable
Updates a job.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:
// 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 (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(); } -
deleteJob
Deletes a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); cloudSchedulerClient.deleteJob(name); }- Parameters:
name- Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.- Throws:
ApiException- if the remote call fails
-
deleteJob
Deletes a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); cloudSchedulerClient.deleteJob(name); }- Parameters:
name- Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.- Throws:
ApiException- if the remote call fails
-
deleteJob
Deletes a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { DeleteJobRequest request = DeleteJobRequest.newBuilder() .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) .setLegacyAppEngineCron(true) .build(); cloudSchedulerClient.deleteJob(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deleteJobCallable
Deletes a job.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { DeleteJobRequest request = DeleteJobRequest.newBuilder() .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) .setLegacyAppEngineCron(true) .build(); ApiFuture<Empty> future = cloudSchedulerClient.deleteJobCallable().futureCall(request); // Do something. future.get(); } -
pauseJob
Pauses a job.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:
// 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); Job response = cloudSchedulerClient.pauseJob(name); }- Parameters:
name- Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.- Throws:
ApiException- if the remote call fails
-
pauseJob
Pauses a job.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:
// 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); Job response = cloudSchedulerClient.pauseJob(name); }- Parameters:
name- Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.- Throws:
ApiException- if the remote call fails
-
pauseJob
Pauses a job.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:
// 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { PauseJobRequest request = PauseJobRequest.newBuilder() .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) .build(); Job response = cloudSchedulerClient.pauseJob(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
pauseJobCallable
Pauses a job.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:
// 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 (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(); } -
resumeJob
Resume a job.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:
// 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); Job response = cloudSchedulerClient.resumeJob(name); }- Parameters:
name- Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.- Throws:
ApiException- if the remote call fails
-
resumeJob
Resume a job.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:
// 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); Job response = cloudSchedulerClient.resumeJob(name); }- Parameters:
name- Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.- Throws:
ApiException- if the remote call fails
-
resumeJob
Resume a job.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:
// 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { ResumeJobRequest request = ResumeJobRequest.newBuilder() .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) .build(); Job response = cloudSchedulerClient.resumeJob(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
resumeJobCallable
Resume a job.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:
// 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 (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(); } -
runJob
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 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); Job response = cloudSchedulerClient.runJob(name); }- Parameters:
name- Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.- Throws:
ApiException- if the remote call fails
-
runJob
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 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); Job response = cloudSchedulerClient.runJob(name); }- Parameters:
name- Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.- Throws:
ApiException- if the remote call fails
-
runJob
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 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { RunJobRequest request = RunJobRequest.newBuilder() .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) .setLegacyAppEngineCron(true) .build(); Job response = cloudSchedulerClient.runJob(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
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 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 (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { RunJobRequest request = RunJobRequest.newBuilder() .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) .setLegacyAppEngineCron(true) .build(); ApiFuture<Job> future = cloudSchedulerClient.runJobCallable().futureCall(request); // Do something. Job response = future.get(); } -
listLocations
public final CloudSchedulerClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request) Lists information about the supported locations for this service.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (Location element : cloudSchedulerClient.listLocations(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listLocationsPagedCallable
public final UnaryCallable<ListLocationsRequest,CloudSchedulerClient.ListLocationsPagedResponse> listLocationsPagedCallable()Lists information about the supported locations for this service.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<Location> future = cloudSchedulerClient.listLocationsPagedCallable().futureCall(request); // Do something. for (Location element : future.get().iterateAll()) { // doThingsWith(element); } } -
listLocationsCallable
Lists information about the supported locations for this service.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListLocationsResponse response = cloudSchedulerClient.listLocationsCallable().call(request); for (Location element : response.getLocationsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
getLocation
Gets information about a location.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); Location response = cloudSchedulerClient.getLocation(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getLocationCallable
Gets information about a location.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); ApiFuture<Location> future = cloudSchedulerClient.getLocationCallable().futureCall(request); // Do something. Location response = future.get(); } -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceBackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceBackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceBackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNowin interfaceBackgroundResource
-
awaitTermination
- Specified by:
awaitTerminationin interfaceBackgroundResource- Throws:
InterruptedException
-