CloudSchedulerClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
The Cloud Scheduler API allows external entities to reliably schedule asynchronous jobs.
Methods
CloudSchedulerClient
CloudSchedulerClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
Constructor.
Name | Description |
channel |
grpc.Channel
DEPRECATED. A |
credentials |
google.auth.credentials.Credentials
The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to |
client_config |
dict
DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used. |
client_info |
google.api_core.gapic_v1.client_info.ClientInfo
The client info used to send a user-agent string along with API requests. If |
client_options |
Union[dict, google.api_core.client_options.ClientOptions]
Client options used to set user options on the client. API Endpoint should be set through client_options. |
create_job
create_job(parent, job, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Creates a job.
.. rubric:: Example
from google.cloud import scheduler_v1beta1
client = scheduler_v1beta1.CloudSchedulerClient()
parent = client.location_path('[PROJECT]', '[LOCATION]')
TODO: Initialize
job
:job = {}
response = client.create_job(parent, job)
Name | Description |
parent |
str
Required. The location name. For example: |
job |
Union[dict, Job]
Required. The job to add. The user can optionally specify a name for the job in |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
delete_job
delete_job(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Deletes a job.
.. rubric:: Example
from google.cloud import scheduler_v1beta1
client = scheduler_v1beta1.CloudSchedulerClient()
name = client.job_path('[PROJECT]', '[LOCATION]', '[JOB]')
client.delete_job(name)
Name | Description |
name |
str
Required. The job name. For example: |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
from_service_account_file
from_service_account_file(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
CloudSchedulerClient | The constructed client. |
from_service_account_json
from_service_account_json(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
CloudSchedulerClient | The constructed client. |
get_job
get_job(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Gets a job.
.. rubric:: Example
from google.cloud import scheduler_v1beta1
client = scheduler_v1beta1.CloudSchedulerClient()
name = client.job_path('[PROJECT]', '[LOCATION]', '[JOB]')
response = client.get_job(name)
Name | Description |
name |
str
Required. The job name. For example: |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
job_path
job_path(project, location, job)
Return a fully-qualified job string.
list_jobs
list_jobs(parent, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Lists jobs.
.. rubric:: Example
from google.cloud import scheduler_v1beta1
client = scheduler_v1beta1.CloudSchedulerClient()
parent = client.location_path('[PROJECT]', '[LOCATION]')
Iterate over all results
for element in client.list_jobs(parent): ... # process element ... pass
Alternatively:
Iterate over results one page at a time
for page in client.list_jobs(parent).pages: ... for element in page: ... # process element ... pass
Name | Description |
parent |
str
Required. The location name. For example: |
page_size |
int
The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
location_path
location_path(project, location)
Return a fully-qualified location string.
pause_job
pause_job(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
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.
.. rubric:: Example
from google.cloud import scheduler_v1beta1
client = scheduler_v1beta1.CloudSchedulerClient()
name = client.job_path('[PROJECT]', '[LOCATION]', '[JOB]')
response = client.pause_job(name)
Name | Description |
name |
str
Required. The job name. For example: |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
resume_job
resume_job(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
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.
.. rubric:: Example
from google.cloud import scheduler_v1beta1
client = scheduler_v1beta1.CloudSchedulerClient()
name = client.job_path('[PROJECT]', '[LOCATION]', '[JOB]')
response = client.resume_job(name)
Name | Description |
name |
str
Required. The job name. For example: |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
run_job
run_job(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Forces a job to run now.
When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.
.. rubric:: Example
from google.cloud import scheduler_v1beta1
client = scheduler_v1beta1.CloudSchedulerClient()
name = client.job_path('[PROJECT]', '[LOCATION]', '[JOB]')
response = client.run_job(name)
Name | Description |
name |
str
Required. The job name. For example: |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
update_job
update_job(job, update_mask=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
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.
.. rubric:: Example
from google.cloud import scheduler_v1beta1
client = scheduler_v1beta1.CloudSchedulerClient()
TODO: Initialize
job
:job = {}
response = client.update_job(job)
Name | Description |
job |
Union[dict, Job]
Required. The new job properties. |
update_mask |
Union[dict, FieldMask]
A mask used to specify which fields of the job are being updated. If a dict is provided, it must be of the same form as the protobuf message FieldMask |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |