Class v1beta1.CloudSchedulerClient (5.2.0)

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

Package

@google-cloud/scheduler

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of CloudSchedulerClient.

Parameters
Name Description
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new CloudSchedulerClient({fallback: true}, gax); ```

Properties

apiEndpoint

get apiEndpoint(): string;

The DNS address for this API service.

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath.

auth

auth: gax.GoogleAuth;

cloudSchedulerStub

cloudSchedulerStub?: Promise<{
        [name: string]: Function;
    }>;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

locationsClient

locationsClient: LocationsClient;

pathTemplates

pathTemplates: {
        [name: string]: gax.PathTemplate;
    };

port

static get port(): number;

The port for this API service.

scopes

static get scopes(): string[];

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

servicePath

static get servicePath(): string;

The DNS address for this API service.

universeDomain

get universeDomain(): string;

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

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

Returns
Type Description
Promise<void>

{Promise} A promise that resolves when the client is closed.

createJob(request, options)

createJob(request?: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, options?: CallOptions): Promise<[
        protos.google.cloud.scheduler.v1beta1.IJob,
        protos.google.cloud.scheduler.v1beta1.ICreateJobRequest | undefined,
        {} | undefined
    ]>;

Creates a job.

Parameters
Name Description
request ICreateJobRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.ICreateJobRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The location name. For example:
   *  `projects/PROJECT_ID/locations/LOCATION_ID`.
   */
  // const parent = 'abc123'
  /**
   *  Required. The job to add. The user can optionally specify a name for the
   *  job in name google.cloud.scheduler.v1beta1.Job.name.
   *  name google.cloud.scheduler.v1beta1.Job.name  cannot be the same as an
   *  existing job. If a name is not specified then the system will
   *  generate a random unique name that will be returned
   *  (name google.cloud.scheduler.v1beta1.Job.name) in the response.
   */
  // const job = {}

  // Imports the Scheduler library
  const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1;

  // Instantiates a client
  const schedulerClient = new CloudSchedulerClient();

  async function callCreateJob() {
    // Construct request
    const request = {
      parent,
      job,
    };

    // Run request
    const response = await schedulerClient.createJob(request);
    console.log(response);
  }

  callCreateJob();

createJob(request, options, callback)

createJob(request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, options: CallOptions, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.ICreateJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateJobRequest
options CallOptions
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.ICreateJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

createJob(request, callback)

createJob(request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.ICreateJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateJobRequest
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.ICreateJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteJob(request, options)

deleteJob(request?: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest | undefined,
        {} | undefined
    ]>;

Deletes a job.

Parameters
Name Description
request IDeleteJobRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.protobuf.IEmpty, protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The job name. For example:
   *  `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
   */
  // const name = 'abc123'
  /**
   *  This field is used to manage the legacy App Engine Cron jobs using the
   *  Cloud Scheduler API. If the field is set to true, the job in the __cron
   *  queue with the corresponding name will be deleted instead.
   */
  // const legacyAppEngineCron = true

  // Imports the Scheduler library
  const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1;

  // Instantiates a client
  const schedulerClient = new CloudSchedulerClient();

  async function callDeleteJob() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await schedulerClient.deleteJob(request);
    console.log(response);
  }

  callDeleteJob();

deleteJob(request, options, callback)

deleteJob(request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteJobRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteJob(request, callback)

deleteJob(request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteJobRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getJob(request, options)

getJob(request?: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, options?: CallOptions): Promise<[
        protos.google.cloud.scheduler.v1beta1.IJob,
        protos.google.cloud.scheduler.v1beta1.IGetJobRequest | undefined,
        {} | undefined
    ]>;

Gets a job.

Parameters
Name Description
request IGetJobRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IGetJobRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The job name. For example:
   *  `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
   */
  // const name = 'abc123'

  // Imports the Scheduler library
  const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1;

  // Instantiates a client
  const schedulerClient = new CloudSchedulerClient();

  async function callGetJob() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await schedulerClient.getJob(request);
    console.log(response);
  }

  callGetJob();

getJob(request, options, callback)

getJob(request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, options: CallOptions, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IGetJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetJobRequest
options CallOptions
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IGetJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getJob(request, callback)

getJob(request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IGetJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetJobRequest
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IGetJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getLocation(request, options, callback)

getLocation(request: LocationProtos.google.cloud.location.IGetLocationRequest, options?: gax.CallOptions | Callback<LocationProtos.google.cloud.location.ILocation, LocationProtos.google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>, callback?: Callback<LocationProtos.google.cloud.location.ILocation, LocationProtos.google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>): Promise<LocationProtos.google.cloud.location.ILocation>;

Gets information about a location.

Parameters
Name Description
request LocationProtos.google.cloud.location.IGetLocationRequest

The request object that will be sent.

options CallOptions | Callback<google.cloud.location.ILocation, google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>

Call options. See CallOptions for more details.

callback Callback<google.cloud.location.ILocation, google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>
Returns
Type Description
Promise<google.cloud.location.ILocation>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

const [response] = await client.getLocation(request);

getProjectId()

getProjectId(): Promise<string>;
Returns
Type Description
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
Name Description
callback Callback<string, undefined, undefined>
Returns
Type Description
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

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.

Returns
Type Description
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

jobPath(project, location, job)

jobPath(project: string, location: string, job: string): string;

Return a fully-qualified job resource name string.

Parameters
Name Description
project string
location string
job string
Returns
Type Description
string

{string} Resource name string.

listJobs(request, options)

listJobs(request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, options?: CallOptions): Promise<[
        protos.google.cloud.scheduler.v1beta1.IJob[],
        protos.google.cloud.scheduler.v1beta1.IListJobsRequest | null,
        protos.google.cloud.scheduler.v1beta1.IListJobsResponse
    ]>;

Lists jobs.

Parameters
Name Description
request IListJobsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.cloud.scheduler.v1beta1.IJob[], protos.google.cloud.scheduler.v1beta1.IListJobsRequest | null, protos.google.cloud.scheduler.v1beta1.IListJobsResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listJobsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listJobs(request, options, callback)

listJobs(request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.scheduler.v1beta1.IListJobsRequest, protos.google.cloud.scheduler.v1beta1.IListJobsResponse | null | undefined, protos.google.cloud.scheduler.v1beta1.IJob>): void;
Parameters
Name Description
request IListJobsRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.scheduler.v1beta1.IListJobsRequest, protos.google.cloud.scheduler.v1beta1.IListJobsResponse | null | undefined, protos.google.cloud.scheduler.v1beta1.IJob>
Returns
Type Description
void

listJobs(request, callback)

listJobs(request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, callback: PaginationCallback<protos.google.cloud.scheduler.v1beta1.IListJobsRequest, protos.google.cloud.scheduler.v1beta1.IListJobsResponse | null | undefined, protos.google.cloud.scheduler.v1beta1.IJob>): void;
Parameters
Name Description
request IListJobsRequest
callback PaginationCallback<protos.google.cloud.scheduler.v1beta1.IListJobsRequest, protos.google.cloud.scheduler.v1beta1.IListJobsResponse | null | undefined, protos.google.cloud.scheduler.v1beta1.IJob>
Returns
Type Description
void

listJobsAsync(request, options)

listJobsAsync(request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.scheduler.v1beta1.IJob>;

Equivalent to listJobs, but returns an iterable object.

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

Parameters
Name Description
request IListJobsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.cloud.scheduler.v1beta1.IJob>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The location name. For example:
   *  `projects/PROJECT_ID/locations/LOCATION_ID`.
   */
  // const parent = 'abc123'
  /**
   *  `filter` can be used to specify a subset of jobs.
   *  If `filter` equals `target_config="HttpConfig"`, then the http
   *  target jobs are retrieved. If `filter` equals
   *  `target_config="PubSubConfig"`, then the Pub/Sub target jobs are
   *  retrieved. If `filter` equals `labels.foo=value1
   *  labels.foo=value2` then only jobs which are labeled with
   *  foo=value1 AND foo=value2 will be returned.
   */
  // const filter = 'abc123'
  /**
   *  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.
   */
  // const pageSize = 1234
  /**
   *  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 google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token 
   *  returned from the previous call to
   *  ListJobs google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs. It is
   *  an error to switch the value of
   *  filter google.cloud.scheduler.v1beta1.ListJobsRequest.filter  or
   *  order_by google.cloud.scheduler.v1beta1.ListJobsRequest.order_by  while
   *  iterating through pages.
   */
  // const pageToken = 'abc123'
  /**
   *  This field is used to manage the legacy App Engine Cron jobs using the
   *  Cloud Scheduler API. If the field is set to true, the jobs in the __cron
   *  queue will be listed instead.
   */
  // const legacyAppEngineCron = true

  // Imports the Scheduler library
  const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1;

  // Instantiates a client
  const schedulerClient = new CloudSchedulerClient();

  async function callListJobs() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = schedulerClient.listJobsAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListJobs();

listJobsStream(request, options)

listJobsStream(request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, options?: CallOptions): Transform;

Equivalent to listJobs, but returns a NodeJS Stream object.

Parameters
Name Description
request IListJobsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Transform

{Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listJobsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listLocationsAsync(request, options)

listLocationsAsync(request: LocationProtos.google.cloud.location.IListLocationsRequest, options?: CallOptions): AsyncIterable<LocationProtos.google.cloud.location.ILocation>;

Lists information about the supported locations for this service. Returns an iterable object.

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

Parameters
Name Description
request LocationProtos.google.cloud.location.IListLocationsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<google.cloud.location.ILocation>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

const iterable = client.listLocationsAsync(request);
for await (const response of iterable) {
  // process response
}

locationPath(project, location)

locationPath(project: string, location: string): string;

Return a fully-qualified location resource name string.

Parameters
Name Description
project string
location string
Returns
Type Description
string

{string} Resource name string.

matchJobFromJobName(jobName)

matchJobFromJobName(jobName: string): string | number;

Parse the job from Job resource.

Parameter
Name Description
jobName string

A fully-qualified path representing Job resource.

Returns
Type Description
string | number

{string} A string representing the job.

matchLocationFromJobName(jobName)

matchLocationFromJobName(jobName: string): string | number;

Parse the location from Job resource.

Parameter
Name Description
jobName string

A fully-qualified path representing Job resource.

Returns
Type Description
string | number

{string} A string representing the location.

matchLocationFromLocationName(locationName)

matchLocationFromLocationName(locationName: string): string | number;

Parse the location from Location resource.

Parameter
Name Description
locationName string

A fully-qualified path representing Location resource.

Returns
Type Description
string | number

{string} A string representing the location.

matchProjectFromJobName(jobName)

matchProjectFromJobName(jobName: string): string | number;

Parse the project from Job resource.

Parameter
Name Description
jobName string

A fully-qualified path representing Job resource.

Returns
Type Description
string | number

{string} A string representing the project.

matchProjectFromLocationName(locationName)

matchProjectFromLocationName(locationName: string): string | number;

Parse the project from Location resource.

Parameter
Name Description
locationName string

A fully-qualified path representing Location resource.

Returns
Type Description
string | number

{string} A string representing the project.

matchProjectFromProjectName(projectName)

matchProjectFromProjectName(projectName: string): string | number;

Parse the project from Project resource.

Parameter
Name Description
projectName string

A fully-qualified path representing Project resource.

Returns
Type Description
string | number

{string} A string representing the project.

pauseJob(request, options)

pauseJob(request?: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, options?: CallOptions): Promise<[
        protos.google.cloud.scheduler.v1beta1.IJob,
        protos.google.cloud.scheduler.v1beta1.IPauseJobRequest | undefined,
        {} | undefined
    ]>;

Pauses a job.

If a job is paused then the system will stop executing the job until it is re-enabled via . The state of the job is stored in ; if paused it will be set to . A job must be in to be paused.

Parameters
Name Description
request IPauseJobRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IPauseJobRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The job name. For example:
   *  `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
   */
  // const name = 'abc123'

  // Imports the Scheduler library
  const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1;

  // Instantiates a client
  const schedulerClient = new CloudSchedulerClient();

  async function callPauseJob() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await schedulerClient.pauseJob(request);
    console.log(response);
  }

  callPauseJob();

pauseJob(request, options, callback)

pauseJob(request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, options: CallOptions, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IPauseJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IPauseJobRequest
options CallOptions
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IPauseJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

pauseJob(request, callback)

pauseJob(request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IPauseJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IPauseJobRequest
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IPauseJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

projectPath(project)

projectPath(project: string): string;

Return a fully-qualified project resource name string.

Parameter
Name Description
project string
Returns
Type Description
string

{string} Resource name string.

resumeJob(request, options)

resumeJob(request?: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, options?: CallOptions): Promise<[
        protos.google.cloud.scheduler.v1beta1.IJob,
        protos.google.cloud.scheduler.v1beta1.IResumeJobRequest | undefined,
        {} | undefined
    ]>;

Resume a job.

This method reenables a job after it has been . The state of a job is stored in ; after calling this method it will be set to . A job must be in to be resumed.

Parameters
Name Description
request IResumeJobRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IResumeJobRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The job name. For example:
   *  `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
   */
  // const name = 'abc123'

  // Imports the Scheduler library
  const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1;

  // Instantiates a client
  const schedulerClient = new CloudSchedulerClient();

  async function callResumeJob() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await schedulerClient.resumeJob(request);
    console.log(response);
  }

  callResumeJob();

resumeJob(request, options, callback)

resumeJob(request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, options: CallOptions, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IResumeJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IResumeJobRequest
options CallOptions
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IResumeJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

resumeJob(request, callback)

resumeJob(request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IResumeJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IResumeJobRequest
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IResumeJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

runJob(request, options)

runJob(request?: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, options?: CallOptions): Promise<[
        protos.google.cloud.scheduler.v1beta1.IJob,
        protos.google.cloud.scheduler.v1beta1.IRunJobRequest | undefined,
        {} | undefined
    ]>;

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 Description
request IRunJobRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IRunJobRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The job name. For example:
   *  `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
   */
  // const name = 'abc123'
  /**
   *  This field is used to manage the legacy App Engine Cron jobs using the
   *  Cloud Scheduler API. If the field is set to true, the job in the __cron
   *  queue with the corresponding name will be forced to run instead.
   */
  // const legacyAppEngineCron = true

  // Imports the Scheduler library
  const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1;

  // Instantiates a client
  const schedulerClient = new CloudSchedulerClient();

  async function callRunJob() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await schedulerClient.runJob(request);
    console.log(response);
  }

  callRunJob();

runJob(request, options, callback)

runJob(request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, options: CallOptions, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IRunJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IRunJobRequest
options CallOptions
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IRunJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

runJob(request, callback)

runJob(request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IRunJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IRunJobRequest
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IRunJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

updateJob(request, options)

updateJob(request?: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, options?: CallOptions): Promise<[
        protos.google.cloud.scheduler.v1beta1.IJob,
        protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest | undefined,
        {} | undefined
    ]>;

Updates a job.

If successful, the updated 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 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 Description
request IUpdateJobRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The new job properties.
   *  name google.cloud.scheduler.v1beta1.Job.name  must be specified.
   *  Output only fields cannot be modified using UpdateJob.
   *  Any value specified for an output only field will be ignored.
   */
  // const job = {}
  /**
   *  A  mask used to specify which fields of the job are being updated.
   */
  // const updateMask = {}

  // Imports the Scheduler library
  const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1;

  // Instantiates a client
  const schedulerClient = new CloudSchedulerClient();

  async function callUpdateJob() {
    // Construct request
    const request = {
      job,
    };

    // Run request
    const response = await schedulerClient.updateJob(request);
    console.log(response);
  }

  callUpdateJob();

updateJob(request, options, callback)

updateJob(request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, options: CallOptions, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateJobRequest
options CallOptions
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

updateJob(request, callback)

updateJob(request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, callback: Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateJobRequest
callback Callback<protos.google.cloud.scheduler.v1beta1.IJob, protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void