Class CloudSchedulerClient (2.23.0)
Stay organized with collections
Save and categorize content based on your preferences.
- 2.78.0 (latest)
- 2.76.0
- 2.75.0
- 2.74.0
- 2.73.0
- 2.72.0
- 2.70.0
- 2.68.0
- 2.67.0
- 2.64.0
- 2.63.0
- 2.62.0
- 2.60.0
- 2.59.0
- 2.58.0
- 2.57.0
- 2.56.0
- 2.55.0
- 2.54.0
- 2.53.0
- 2.52.0
- 2.51.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.40.0
- 2.39.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.28.0
- 2.27.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.13
- 2.2.0
- 2.1.23
publicclass CloudSchedulerClientimplementsBackgroundResourceService 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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
JobNamename=JobName.of("[PROJECT]","[LOCATION]","[JOB]");
Jobresponse=cloudSchedulerClient.getJob(name);
}
Note: close() needs to be called on the CloudSchedulerClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of CloudSchedulerSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated 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
CloudSchedulerSettingscloudSchedulerSettings=
CloudSchedulerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CloudSchedulerClientcloudSchedulerClient=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
CloudSchedulerSettingscloudSchedulerSettings=
CloudSchedulerSettings.newBuilder().setEndpoint(myEndpoint).build();
CloudSchedulerClientcloudSchedulerClient=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
CloudSchedulerSettingscloudSchedulerSettings=
CloudSchedulerSettings.newHttpJsonBuilder().build();
CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create(cloudSchedulerSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceInherited Members
Static Methods
create()
publicstaticfinalCloudSchedulerClientcreate()Constructs an instance of CloudSchedulerClient with default settings.
| Returns | |
|---|---|
| Type | Description |
CloudSchedulerClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(CloudSchedulerSettings settings)
publicstaticfinalCloudSchedulerClientcreate(CloudSchedulerSettingssettings)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 | |
|---|---|
| Name | Description |
settings |
CloudSchedulerSettings |
| Returns | |
|---|---|
| Type | Description |
CloudSchedulerClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(CloudSchedulerStub stub)
publicstaticfinalCloudSchedulerClientcreate(CloudSchedulerStubstub)Constructs an instance of CloudSchedulerClient, using the given stub for making calls. This is for advanced usage - prefer using create(CloudSchedulerSettings).
| Parameter | |
|---|---|
| Name | Description |
stub |
CloudSchedulerStub |
| Returns | |
|---|---|
| Type | Description |
CloudSchedulerClient |
|
Constructors
CloudSchedulerClient(CloudSchedulerSettings settings)
protectedCloudSchedulerClient(CloudSchedulerSettingssettings)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 | |
|---|---|
| Name | Description |
settings |
CloudSchedulerSettings |
CloudSchedulerClient(CloudSchedulerStub stub)
protectedCloudSchedulerClient(CloudSchedulerStubstub)| Parameter | |
|---|---|
| Name | Description |
stub |
CloudSchedulerStub |
Methods
awaitTermination(long duration, TimeUnit unit)
publicbooleanawaitTermination(longduration,TimeUnitunit)| Parameters | |
|---|---|
| Name | Description |
duration |
long |
unit |
TimeUnit |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
| Exceptions | |
|---|---|
| Type | Description |
InterruptedException |
|
close()
publicfinalvoidclose()createJob(CreateJobRequest request)
publicfinalJobcreateJob(CreateJobRequestrequest)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
CreateJobRequestrequest=
CreateJobRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setJob(Job.newBuilder().build())
.build();
Jobresponse=cloudSchedulerClient.createJob(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
CreateJobRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Job |
|
createJob(LocationName parent, Job job)
publicfinalJobcreateJob(LocationNameparent,Jobjob)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
LocationNameparent=LocationName.of("[PROJECT]","[LOCATION]");
Jobjob=Job.newBuilder().build();
Jobresponse=cloudSchedulerClient.createJob(parent,job);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
LocationName Required. The location name. For example:
|
job |
Job Required. The job to add. The user can optionally specify a name for the job in name. name cannot be the same as an existing job. If a name is not specified then the system will generate a random unique name that will be returned (name) in the response. |
| Returns | |
|---|---|
| Type | Description |
Job |
|
createJob(String parent, Job job)
publicfinalJobcreateJob(Stringparent,Jobjob)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
Stringparent=LocationName.of("[PROJECT]","[LOCATION]").toString();
Jobjob=Job.newBuilder().build();
Jobresponse=cloudSchedulerClient.createJob(parent,job);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
String Required. The location name. For example:
|
job |
Job Required. The job to add. The user can optionally specify a name for the job in name. name cannot be the same as an existing job. If a name is not specified then the system will generate a random unique name that will be returned (name) in the response. |
| Returns | |
|---|---|
| Type | Description |
Job |
|
createJobCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
CreateJobRequestrequest=
CreateJobRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setJob(Job.newBuilder().build())
.build();
ApiFuture<Job>future=cloudSchedulerClient.createJobCallable().futureCall(request);
// Do something.
Jobresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<CreateJobRequest,Job> |
|
deleteJob(DeleteJobRequest request)
publicfinalvoiddeleteJob(DeleteJobRequestrequest)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
DeleteJobRequestrequest=
DeleteJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString())
.setLegacyAppEngineCron(true)
.build();
cloudSchedulerClient.deleteJob(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
DeleteJobRequest The request object containing all of the parameters for the API call. |
deleteJob(JobName name)
publicfinalvoiddeleteJob(JobNamename)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
JobNamename=JobName.of("[PROJECT]","[LOCATION]","[JOB]");
cloudSchedulerClient.deleteJob(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
JobName Required. The job name. For example:
|
deleteJob(String name)
publicfinalvoiddeleteJob(Stringname)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
Stringname=JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString();
cloudSchedulerClient.deleteJob(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The job name. For example:
|
deleteJobCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
DeleteJobRequestrequest=
DeleteJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString())
.setLegacyAppEngineCron(true)
.build();
ApiFuture<Empty>future=cloudSchedulerClient.deleteJobCallable().futureCall(request);
// Do something.
future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<DeleteJobRequest,Empty> |
|
getJob(GetJobRequest request)
publicfinalJobgetJob(GetJobRequestrequest)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
GetJobRequestrequest=
GetJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString())
.build();
Jobresponse=cloudSchedulerClient.getJob(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
GetJobRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Job |
|
getJob(JobName name)
publicfinalJobgetJob(JobNamename)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
JobNamename=JobName.of("[PROJECT]","[LOCATION]","[JOB]");
Jobresponse=cloudSchedulerClient.getJob(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
JobName Required. The job name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Job |
|
getJob(String name)
publicfinalJobgetJob(Stringname)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
Stringname=JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString();
Jobresponse=cloudSchedulerClient.getJob(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The job name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Job |
|
getJobCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
GetJobRequestrequest=
GetJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString())
.build();
ApiFuture<Job>future=cloudSchedulerClient.getJobCallable().futureCall(request);
// Do something.
Jobresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<GetJobRequest,Job> |
|
getLocation(GetLocationRequest request)
publicfinalLocationgetLocation(GetLocationRequestrequest)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
GetLocationRequestrequest=GetLocationRequest.newBuilder().setName("name3373707").build();
Locationresponse=cloudSchedulerClient.getLocation(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
com.google.cloud.location.GetLocationRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
com.google.cloud.location.Location |
|
getLocationCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
GetLocationRequestrequest=GetLocationRequest.newBuilder().setName("name3373707").build();
ApiFuture<Location>future=cloudSchedulerClient.getLocationCallable().futureCall(request);
// Do something.
Locationresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> |
|
getSettings()
publicfinalCloudSchedulerSettingsgetSettings()| Returns | |
|---|---|
| Type | Description |
CloudSchedulerSettings |
|
getStub()
publicCloudSchedulerStubgetStub()| Returns | |
|---|---|
| Type | Description |
CloudSchedulerStub |
|
isShutdown()
publicbooleanisShutdown()| Returns | |
|---|---|
| Type | Description |
boolean |
|
isTerminated()
publicbooleanisTerminated()| Returns | |
|---|---|
| Type | Description |
boolean |
|
listJobs(ListJobsRequest request)
publicfinalCloudSchedulerClient.ListJobsPagedResponselistJobs(ListJobsRequestrequest)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
ListJobsRequestrequest=
ListJobsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setLegacyAppEngineCron(true)
.build();
for(Jobelement:cloudSchedulerClient.listJobs(request).iterateAll()){
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
request |
ListJobsRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
CloudSchedulerClient.ListJobsPagedResponse |
|
listJobs(LocationName parent)
publicfinalCloudSchedulerClient.ListJobsPagedResponselistJobs(LocationNameparent)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
LocationNameparent=LocationName.of("[PROJECT]","[LOCATION]");
for(Jobelement:cloudSchedulerClient.listJobs(parent).iterateAll()){
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
LocationName Required. The location name. For example:
|
| Returns | |
|---|---|
| Type | Description |
CloudSchedulerClient.ListJobsPagedResponse |
|
listJobs(String parent)
publicfinalCloudSchedulerClient.ListJobsPagedResponselistJobs(Stringparent)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
Stringparent=LocationName.of("[PROJECT]","[LOCATION]").toString();
for(Jobelement:cloudSchedulerClient.listJobs(parent).iterateAll()){
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
String Required. The location name. For example:
|
| Returns | |
|---|---|
| Type | Description |
CloudSchedulerClient.ListJobsPagedResponse |
|
listJobsCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
ListJobsRequestrequest=
ListJobsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setLegacyAppEngineCron(true)
.build();
while(true){
ListJobsResponseresponse=cloudSchedulerClient.listJobsCallable().call(request);
for(Jobelement:response.getJobsList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListJobsRequest,ListJobsResponse> |
|
listJobsPagedCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
ListJobsRequestrequest=
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(Jobelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListJobsRequest,ListJobsPagedResponse> |
|
listLocations(ListLocationsRequest request)
publicfinalCloudSchedulerClient.ListLocationsPagedResponselistLocations(ListLocationsRequestrequest)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
ListLocationsRequestrequest=
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for(Locationelement:cloudSchedulerClient.listLocations(request).iterateAll()){
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
request |
com.google.cloud.location.ListLocationsRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
CloudSchedulerClient.ListLocationsPagedResponse |
|
listLocationsCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
ListLocationsRequestrequest=
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while(true){
ListLocationsResponseresponse=cloudSchedulerClient.listLocationsCallable().call(request);
for(Locationelement:response.getLocationsList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> |
|
listLocationsPagedCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
ListLocationsRequestrequest=
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location>future=
cloudSchedulerClient.listLocationsPagedCallable().futureCall(request);
// Do something.
for(Locationelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ListLocationsPagedResponse> |
|
pauseJob(JobName name)
publicfinalJobpauseJob(JobNamename)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
JobNamename=JobName.of("[PROJECT]","[LOCATION]","[JOB]");
Jobresponse=cloudSchedulerClient.pauseJob(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
JobName Required. The job name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Job |
|
pauseJob(PauseJobRequest request)
publicfinalJobpauseJob(PauseJobRequestrequest)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
PauseJobRequestrequest=
PauseJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString())
.build();
Jobresponse=cloudSchedulerClient.pauseJob(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
PauseJobRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Job |
|
pauseJob(String name)
publicfinalJobpauseJob(Stringname)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
Stringname=JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString();
Jobresponse=cloudSchedulerClient.pauseJob(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The job name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Job |
|
pauseJobCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
PauseJobRequestrequest=
PauseJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString())
.build();
ApiFuture<Job>future=cloudSchedulerClient.pauseJobCallable().futureCall(request);
// Do something.
Jobresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<PauseJobRequest,Job> |
|
resumeJob(JobName name)
publicfinalJobresumeJob(JobNamename)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
JobNamename=JobName.of("[PROJECT]","[LOCATION]","[JOB]");
Jobresponse=cloudSchedulerClient.resumeJob(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
JobName Required. The job name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Job |
|
resumeJob(ResumeJobRequest request)
publicfinalJobresumeJob(ResumeJobRequestrequest)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
ResumeJobRequestrequest=
ResumeJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString())
.build();
Jobresponse=cloudSchedulerClient.resumeJob(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
ResumeJobRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Job |
|
resumeJob(String name)
publicfinalJobresumeJob(Stringname)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
Stringname=JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString();
Jobresponse=cloudSchedulerClient.resumeJob(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The job name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Job |
|
resumeJobCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
ResumeJobRequestrequest=
ResumeJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString())
.build();
ApiFuture<Job>future=cloudSchedulerClient.resumeJobCallable().futureCall(request);
// Do something.
Jobresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ResumeJobRequest,Job> |
|
runJob(JobName name)
publicfinalJobrunJob(JobNamename)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
JobNamename=JobName.of("[PROJECT]","[LOCATION]","[JOB]");
Jobresponse=cloudSchedulerClient.runJob(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
JobName Required. The job name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Job |
|
runJob(RunJobRequest request)
publicfinalJobrunJob(RunJobRequestrequest)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
RunJobRequestrequest=
RunJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString())
.setLegacyAppEngineCron(true)
.build();
Jobresponse=cloudSchedulerClient.runJob(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
RunJobRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Job |
|
runJob(String name)
publicfinalJobrunJob(Stringname)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
Stringname=JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString();
Jobresponse=cloudSchedulerClient.runJob(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The job name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Job |
|
runJobCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
RunJobRequestrequest=
RunJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]","[LOCATION]","[JOB]").toString())
.setLegacyAppEngineCron(true)
.build();
ApiFuture<Job>future=cloudSchedulerClient.runJobCallable().futureCall(request);
// Do something.
Jobresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<RunJobRequest,Job> |
|
shutdown()
publicvoidshutdown()shutdownNow()
publicvoidshutdownNow()updateJob(Job job, FieldMask updateMask)
publicfinalJobupdateJob(Jobjob,FieldMaskupdateMask)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
Jobjob=Job.newBuilder().build();
FieldMaskupdateMask=FieldMask.newBuilder().build();
Jobresponse=cloudSchedulerClient.updateJob(job,updateMask);
}
| Parameters | |
|---|---|
| Name | Description |
job |
Job Required. The new job properties. name must be specified. Output only fields cannot be modified using UpdateJob. Any value specified for an output only field will be ignored. |
updateMask |
FieldMask A mask used to specify which fields of the job are being updated. |
| Returns | |
|---|---|
| Type | Description |
Job |
|
updateJob(UpdateJobRequest request)
publicfinalJobupdateJob(UpdateJobRequestrequest)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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
UpdateJobRequestrequest=
UpdateJobRequest.newBuilder()
.setJob(Job.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Jobresponse=cloudSchedulerClient.updateJob(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
UpdateJobRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Job |
|
updateJobCallable()
publicfinalUnaryCallable<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(CloudSchedulerClientcloudSchedulerClient=CloudSchedulerClient.create()){
UpdateJobRequestrequest=
UpdateJobRequest.newBuilder()
.setJob(Job.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Job>future=cloudSchedulerClient.updateJobCallable().futureCall(request);
// Do something.
Jobresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<UpdateJobRequest,Job> |
|