Class CloudSchedulerClient (2.35.0)

GitHub RepositoryProduct ReferenceREST DocumentationRPC Documentation

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

Methods
MethodDescriptionMethod Variants

ListJobs

Lists jobs.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listJobs(ListJobsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listJobs(LocationName parent)

  • listJobs(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listJobsPagedCallable()

  • listJobsCallable()

GetJob

Gets a job.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getJob(GetJobRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getJob(JobName name)

  • getJob(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getJobCallable()

CreateJob

Creates a job.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createJob(CreateJobRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createJob(LocationName parent, Job job)

  • createJob(String parent, Job job)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createJobCallable()

UpdateJob

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.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateJob(UpdateJobRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateJob(Job job, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateJobCallable()

DeleteJob

Deletes a job.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteJob(DeleteJobRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteJob(JobName name)

  • deleteJob(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteJobCallable()

PauseJob

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.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • pauseJob(PauseJobRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • pauseJob(JobName name)

  • pauseJob(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • pauseJobCallable()

ResumeJob

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.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • resumeJob(ResumeJobRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • resumeJob(JobName name)

  • resumeJob(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • resumeJobCallable()

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.

  • runJob(RunJobRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • runJob(JobName name)

  • runJob(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • runJobCallable()

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.

  • listLocations(ListLocationsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listLocationsPagedCallable()

  • listLocationsCallable()

GetLocation

Gets information about a location.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getLocation(GetLocationRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getLocationCallable()

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.

Inheritance

java.lang.Object > CloudSchedulerClient

Static Methods

create()

public static final CloudSchedulerClient create()

Constructs an instance of CloudSchedulerClient with default settings.

Returns
TypeDescription
CloudSchedulerClient
Exceptions
TypeDescription
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.

Parameter
NameDescription
settingsCloudSchedulerSettings
Returns
TypeDescription
CloudSchedulerClient
Exceptions
TypeDescription
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).

Parameter
NameDescription
stubCloudSchedulerStub
Returns
TypeDescription
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.

Parameter
NameDescription
settingsCloudSchedulerSettings

CloudSchedulerClient(CloudSchedulerStub stub)

protected CloudSchedulerClient(CloudSchedulerStub stub)
Parameter
NameDescription
stubCloudSchedulerStub

Methods

awaitTermination(long duration, TimeUnit unit)

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

close()

public final void close()

createJob(CreateJobRequest request)

public final Job createJob(CreateJobRequest request)

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

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

Returns
TypeDescription
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 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
NameDescription
parentLocationName

Required. The location name. For example: projects/PROJECT_ID/locations/LOCATION_ID.

jobJob

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.

Returns
TypeDescription
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 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
NameDescription
parentString

Required. The location name. For example: projects/PROJECT_ID/locations/LOCATION_ID.

jobJob

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.

Returns
TypeDescription
Job

createJobCallable()

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

deleteJob(DeleteJobRequest request)

public final void deleteJob(DeleteJobRequest request)

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())
           .build();
   cloudSchedulerClient.deleteJob(request);
 }
 
Parameter
NameDescription
requestDeleteJobRequest

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

Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

deleteJob(String name)

public final void deleteJob(String name)

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

Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

deleteJobCallable()

public final UnaryCallable<DeleteJobRequest,Empty> 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())
           .build();
   ApiFuture<Empty> future = cloudSchedulerClient.deleteJobCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteJobRequest,Empty>

getJob(GetJobRequest request)

public final Job getJob(GetJobRequest request)

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

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

Returns
TypeDescription
Job

getJob(JobName name)

public final Job getJob(JobName name)

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

Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

Returns
TypeDescription
Job

getJob(String name)

public final Job getJob(String name)

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

Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

Returns
TypeDescription
Job

getJobCallable()

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

getLocation(GetLocationRequest request)

public final Location getLocation(GetLocationRequest request)

Gets information about a location.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   Location response = cloudSchedulerClient.getLocation(request);
 }
 
Parameter
NameDescription
requestcom.google.cloud.location.GetLocationRequest

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

Returns
TypeDescription
com.google.cloud.location.Location

getLocationCallable()

public final UnaryCallable<GetLocationRequest,Location> getLocationCallable()

Gets information about a location.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   ApiFuture<Location> future = cloudSchedulerClient.getLocationCallable().futureCall(request);
   // Do something.
   Location response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location>

getSettings()

public final CloudSchedulerSettings getSettings()
Returns
TypeDescription
CloudSchedulerSettings

getStub()

public CloudSchedulerStub getStub()
Returns
TypeDescription
CloudSchedulerStub

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listJobs(ListJobsRequest request)

public final CloudSchedulerClient.ListJobsPagedResponse listJobs(ListJobsRequest request)

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

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

Returns
TypeDescription
CloudSchedulerClient.ListJobsPagedResponse

listJobs(LocationName parent)

public final CloudSchedulerClient.ListJobsPagedResponse listJobs(LocationName parent)

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

Required. The location name. For example: projects/PROJECT_ID/locations/LOCATION_ID.

Returns
TypeDescription
CloudSchedulerClient.ListJobsPagedResponse

listJobs(String parent)

public final CloudSchedulerClient.ListJobsPagedResponse listJobs(String parent)

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

Required. The location name. For example: projects/PROJECT_ID/locations/LOCATION_ID.

Returns
TypeDescription
CloudSchedulerClient.ListJobsPagedResponse

listJobsCallable()

public final UnaryCallable<ListJobsRequest,ListJobsResponse> 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())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .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;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListJobsRequest,ListJobsResponse>

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

listLocations(ListLocationsRequest request)

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

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

Returns
TypeDescription
CloudSchedulerClient.ListLocationsPagedResponse

listLocationsCallable()

public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> listLocationsCallable()

Lists information about the supported locations for this service.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (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;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse>

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

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

Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

Returns
TypeDescription
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 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);
 }
 
Parameter
NameDescription
requestPauseJobRequest

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

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

Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

Returns
TypeDescription
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 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();
 }
 
Returns
TypeDescription
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 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);
 }
 
Parameter
NameDescription
nameJobName

Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

Returns
TypeDescription
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 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);
 }
 
Parameter
NameDescription
requestResumeJobRequest

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

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

Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

Returns
TypeDescription
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 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();
 }
 
Returns
TypeDescription
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 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);
 }
 
Parameter
NameDescription
nameJobName

Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

Returns
TypeDescription
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 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())
           .build();
   Job response = cloudSchedulerClient.runJob(request);
 }
 
Parameter
NameDescription
requestRunJobRequest

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

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

Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

Returns
TypeDescription
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 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())
           .build();
   ApiFuture<Job> future = cloudSchedulerClient.runJobCallable().futureCall(request);
   // Do something.
   Job response = future.get();
 }
 
Returns
TypeDescription
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 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
NameDescription
jobJob

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.

updateMaskFieldMask

A mask used to specify which fields of the job are being updated.

Returns
TypeDescription
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 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);
 }
 
Parameter
NameDescription
requestUpdateJobRequest

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

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