CloudSchedulerClient

CloudSchedulerClient

The Cloud Scheduler API allows external entities to reliably schedule asynchronous jobs.

Constructor

new CloudSchedulerClient(optionsopt)

Construct an instance of CloudSchedulerClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. See the subsequent parameters for more details.

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

Members

(static) apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

(static) port

The port for this API service.

(static) scopes

The scopes needed to make gRPC calls for every method defined in this service.

(static) servicePath

The DNS address for this API service.

Methods

close()

Terminate the GRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

createJob(request, optionsopt) → {Promise}

Creates a job.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

job google.cloud.scheduler.v1.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.

options object <optional>

Call options. See CallOptions for more details.

deleteJob(request, optionsopt) → {Promise}

Deletes a job.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

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

options object <optional>

Call options. See CallOptions for more details.

getJob(request, optionsopt) → {Promise}

Gets a job.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

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

options object <optional>

Call options. See CallOptions for more details.

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

jobPath(project, location, job) → {string}

Return a fully-qualified job resource name string.

Parameters:
Name Type Description
project string
location string
job string

listJobs(request, optionsopt) → {Promise}

Lists jobs.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

pageSize number

Requested page size.

The maximum page size is 500. If unspecified, the page size will be the maximum. Fewer jobs than requested might be returned, even if more jobs exist; use next_page_token to determine if more jobs exist.

pageToken string

A token identifying a page of results the server will return. To request the first page results, page_token must be empty. To request the next page of results, page_token must be the value of next_page_token returned from the previous call to ListJobs. It is an error to switch the value of filter or order_by while iterating through pages.

options object <optional>

Call options. See CallOptions for more details.

listJobsAsync(request, optionsopt) → {Object}

Equivalent to listJobs, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

pageSize number

Requested page size.

The maximum page size is 500. If unspecified, the page size will be the maximum. Fewer jobs than requested might be returned, even if more jobs exist; use next_page_token to determine if more jobs exist.

pageToken string

A token identifying a page of results the server will return. To request the first page results, page_token must be empty. To request the next page of results, page_token must be the value of next_page_token returned from the previous call to ListJobs. It is an error to switch the value of filter or order_by while iterating through pages.

options object <optional>

Call options. See CallOptions for more details.

listJobsStream(request, optionsopt) → {Stream}

Equivalent to listJobs, but returns a NodeJS Stream object.

This fetches the paged responses for listJobs continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

pageSize number

Requested page size.

The maximum page size is 500. If unspecified, the page size will be the maximum. Fewer jobs than requested might be returned, even if more jobs exist; use next_page_token to determine if more jobs exist.

pageToken string

A token identifying a page of results the server will return. To request the first page results, page_token must be empty. To request the next page of results, page_token must be the value of next_page_token returned from the previous call to ListJobs. It is an error to switch the value of filter or order_by while iterating through pages.

options object <optional>

Call options. See CallOptions for more details.

See:

locationPath(project, location) → {string}

Return a fully-qualified location resource name string.

Parameters:
Name Type Description
project string
location string

matchJobFromJobName(jobName) → {string}

Parse the job from Job resource.

Parameters:
Name Type Description
jobName string

A fully-qualified path representing Job resource.

matchLocationFromJobName(jobName) → {string}

Parse the location from Job resource.

Parameters:
Name Type Description
jobName string

A fully-qualified path representing Job resource.

matchLocationFromLocationName(locationName) → {string}

Parse the location from Location resource.

Parameters:
Name Type Description
locationName string

A fully-qualified path representing Location resource.

matchProjectFromJobName(jobName) → {string}

Parse the project from Job resource.

Parameters:
Name Type Description
jobName string

A fully-qualified path representing Job resource.

matchProjectFromLocationName(locationName) → {string}

Parse the project from Location resource.

Parameters:
Name Type Description
locationName string

A fully-qualified path representing Location resource.

matchProjectFromProjectName(projectName) → {string}

Parse the project from Project resource.

Parameters:
Name Type Description
projectName string

A fully-qualified path representing Project resource.

pauseJob(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

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

options object <optional>

Call options. See CallOptions for more details.

projectPath(project) → {string}

Return a fully-qualified project resource name string.

Parameters:
Name Type Description
project string

resumeJob(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

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

options object <optional>

Call options. See CallOptions for more details.

runJob(request, optionsopt) → {Promise}

Forces a job to run now.

When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

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

options object <optional>

Call options. See CallOptions for more details.

updateJob(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
job google.cloud.scheduler.v1.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 google.protobuf.FieldMask

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

options object <optional>

Call options. See CallOptions for more details.