From 80f1b26dd78c376879cc97c082da51001eb98dc8 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 13 Apr 2020 10:02:06 -0700 Subject: [PATCH] refactor: reformat with latest linter and formatter (#240) --- .../src/v1/cloud_scheduler_client.ts | 1230 +++++---- .../src/v1beta1/cloud_scheduler_client.ts | 1276 +++++---- .../google-cloud-scheduler/synth.metadata | 19 +- .../system-test/fixtures/sample/src/index.js | 1 - .../system-test/install.ts | 28 +- .../test/gapic_cloud_scheduler_v1.ts | 2281 +++++++++------- .../test/gapic_cloud_scheduler_v1beta1.ts | 2291 ++++++++++------- .../google-cloud-scheduler/webpack.config.js | 12 +- 8 files changed, 4049 insertions(+), 3089 deletions(-) diff --git a/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts b/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts index cbe4a3d8661..6110c44e8fe 100644 --- a/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts +++ b/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts @@ -17,11 +17,18 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; import * as path from 'path'; -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; +import {Transform} from 'stream'; +import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './cloud_scheduler_client_config.json'; @@ -41,7 +48,12 @@ export class CloudSchedulerClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; cloudSchedulerStub?: Promise<{[name: string]: Function}>; @@ -75,10 +87,12 @@ export class CloudSchedulerClient { constructor(opts?: ClientOptions) { // Ensure that options include the service address and port. const staticMembers = this.constructor as typeof CloudSchedulerClient; - const servicePath = opts && opts.servicePath ? - opts.servicePath : - ((opts && opts.apiEndpoint) ? opts.apiEndpoint : - staticMembers.servicePath); + const servicePath = + opts && opts.servicePath + ? opts.servicePath + : opts && opts.apiEndpoint + ? opts.apiEndpoint + : staticMembers.servicePath; const port = opts && opts.port ? opts.port : staticMembers.port; if (!opts) { @@ -88,8 +102,8 @@ export class CloudSchedulerClient { opts.port = opts.port || port; opts.clientConfig = opts.clientConfig || {}; - const isBrowser = (typeof window !== 'undefined'); - if (isBrowser){ + const isBrowser = typeof window !== 'undefined'; + if (isBrowser) { opts.fallback = true; } // If we are in browser, we are already using fallback because of the @@ -106,13 +120,10 @@ export class CloudSchedulerClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -128,12 +139,18 @@ export class CloudSchedulerClient { // For Node.js, pass the path to JSON proto file. // For browsers, pass the JSON content. - const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? - // eslint-disable-next-line @typescript-eslint/no-var-requires - require("../../protos/protos.json") : - nodejsProtoPath + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + require('../../protos/protos.json') + : nodejsProtoPath ); // This API contains "path templates"; forward-slash-separated @@ -155,14 +172,20 @@ export class CloudSchedulerClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs') + listJobs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'jobs' + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.scheduler.v1.CloudScheduler', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.scheduler.v1.CloudScheduler', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -190,16 +213,27 @@ export class CloudSchedulerClient { // Put together the "service stub" for // google.cloud.scheduler.v1.CloudScheduler. this.cloudSchedulerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.scheduler.v1.CloudScheduler') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.scheduler.v1.CloudScheduler' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.scheduler.v1.CloudScheduler, - this._opts) as Promise<{[method: string]: Function}>; + this._opts + ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const cloudSchedulerStubMethods = - ['listJobs', 'getJob', 'createJob', 'updateJob', 'deleteJob', 'pauseJob', 'resumeJob', 'runJob']; + const cloudSchedulerStubMethods = [ + 'listJobs', + 'getJob', + 'createJob', + 'updateJob', + 'deleteJob', + 'pauseJob', + 'resumeJob', + 'runJob', + ]; for (const methodName of cloudSchedulerStubMethods) { const callPromise = this.cloudSchedulerStub.then( stub => (...args: Array<{}>) => { @@ -209,16 +243,17 @@ export class CloudSchedulerClient { const func = stub[methodName]; return func.apply(stub, args); }, - (err: Error|null|undefined) => () => { + (err: Error | null | undefined) => () => { throw err; - }); + } + ); const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); this.innerApiCalls[methodName] = apiCall; @@ -254,9 +289,7 @@ export class CloudSchedulerClient { * in this service. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -266,8 +299,9 @@ export class CloudSchedulerClient { * @param {function(Error, string)} callback - the callback to * be called with the current project Id. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -279,60 +313,73 @@ export class CloudSchedulerClient { // -- Service calls -- // ------------------- getJob( - request: protos.google.cloud.scheduler.v1.IGetJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1.IGetJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest | undefined, + {} | undefined + ] + >; getJob( - request: protos.google.cloud.scheduler.v1.IGetJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1.IGetJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest | null | undefined, + {} | null | undefined + > + ): void; getJob( - request: protos.google.cloud.scheduler.v1.IGetJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.scheduler.v1.IGetJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Gets a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getJob( - request: protos.google.cloud.scheduler.v1.IGetJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.scheduler.v1.IGetJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.scheduler.v1.IGetJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -341,72 +388,85 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.getJob(request, options, callback); } createJob( - request: protos.google.cloud.scheduler.v1.ICreateJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1.ICreateJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest | undefined, + {} | undefined + ] + >; createJob( - request: protos.google.cloud.scheduler.v1.ICreateJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1.ICreateJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest | null | undefined, + {} | null | undefined + > + ): void; createJob( - request: protos.google.cloud.scheduler.v1.ICreateJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {google.cloud.scheduler.v1.Job} request.job - * Required. The job to add. The user can optionally specify a name for the - * job in {@link google.cloud.scheduler.v1.Job.name|name}. {@link google.cloud.scheduler.v1.Job.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 - * ({@link google.cloud.scheduler.v1.Job.name|name}) in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.scheduler.v1.ICreateJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Creates a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {google.cloud.scheduler.v1.Job} request.job + * Required. The job to add. The user can optionally specify a name for the + * job in {@link google.cloud.scheduler.v1.Job.name|name}. {@link google.cloud.scheduler.v1.Job.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 + * ({@link google.cloud.scheduler.v1.Job.name|name}) in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ createJob( - request: protos.google.cloud.scheduler.v1.ICreateJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.scheduler.v1.ICreateJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.scheduler.v1.ICreateJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -415,78 +475,91 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); this.initialize(); return this.innerApiCalls.createJob(request, options, callback); } updateJob( - request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest | undefined, + {} | undefined + ] + >; updateJob( - request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest | null | undefined, + {} | null | undefined + > + ): void; updateJob( - request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; -/** - * Updates a job. - * - * If successful, the updated {@link google.cloud.scheduler.v1.Job|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 {@link google.cloud.scheduler.v1.Job.State.UPDATE_FAILED|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. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.scheduler.v1.Job} request.job - * Required. The new job properties. {@link google.cloud.scheduler.v1.Job.name|name} must be specified. - * - * Output only fields cannot be modified using UpdateJob. - * Any value specified for an output only field will be ignored. - * @param {google.protobuf.FieldMask} request.updateMask - * A mask used to specify which fields of the job are being updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Updates a job. + * + * If successful, the updated {@link google.cloud.scheduler.v1.Job|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 {@link google.cloud.scheduler.v1.Job.State.UPDATE_FAILED|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. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.scheduler.v1.Job} request.job + * Required. The new job properties. {@link google.cloud.scheduler.v1.Job.name|name} must be specified. + * + * Output only fields cannot be modified using UpdateJob. + * Any value specified for an output only field will be ignored. + * @param {google.protobuf.FieldMask} request.updateMask + * A mask used to specify which fields of the job are being updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ updateJob( - request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.scheduler.v1.IUpdateJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -501,60 +574,73 @@ export class CloudSchedulerClient { return this.innerApiCalls.updateJob(request, options, callback); } deleteJob( - request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest | undefined, + {} | undefined + ] + >; deleteJob( - request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest | null | undefined, + {} | null | undefined + > + ): void; deleteJob( - request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; -/** - * Deletes a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Deletes a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ deleteJob( - request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.scheduler.v1.IDeleteJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -563,72 +649,85 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.deleteJob(request, options, callback); } pauseJob( - request: protos.google.cloud.scheduler.v1.IPauseJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1.IPauseJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest | undefined, + {} | undefined + ] + >; pauseJob( - request: protos.google.cloud.scheduler.v1.IPauseJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1.IPauseJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest | null | undefined, + {} | null | undefined + > + ): void; pauseJob( - request: protos.google.cloud.scheduler.v1.IPauseJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>): void; -/** - * Pauses a job. - * - * If a job is paused then the system will stop executing the job - * until it is re-enabled via {@link google.cloud.scheduler.v1.CloudScheduler.ResumeJob|ResumeJob}. The - * state of the job is stored in {@link google.cloud.scheduler.v1.Job.state|state}; if paused it - * will be set to {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. A job must be in {@link google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED} - * to be paused. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.scheduler.v1.IPauseJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Pauses a job. + * + * If a job is paused then the system will stop executing the job + * until it is re-enabled via {@link google.cloud.scheduler.v1.CloudScheduler.ResumeJob|ResumeJob}. The + * state of the job is stored in {@link google.cloud.scheduler.v1.Job.state|state}; if paused it + * will be set to {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. A job must be in {@link google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED} + * to be paused. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ pauseJob( - request: protos.google.cloud.scheduler.v1.IPauseJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.scheduler.v1.IPauseJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.scheduler.v1.IPauseJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -637,71 +736,84 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.pauseJob(request, options, callback); } resumeJob( - request: protos.google.cloud.scheduler.v1.IResumeJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1.IResumeJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest | undefined, + {} | undefined + ] + >; resumeJob( - request: protos.google.cloud.scheduler.v1.IResumeJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1.IResumeJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest | null | undefined, + {} | null | undefined + > + ): void; resumeJob( - request: protos.google.cloud.scheduler.v1.IResumeJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>): void; -/** - * Resume a job. - * - * This method reenables a job after it has been {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. The - * state of a job is stored in {@link google.cloud.scheduler.v1.Job.state|Job.state}; after calling this method it - * will be set to {@link google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED}. A job must be in - * {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED} to be resumed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.scheduler.v1.IResumeJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Resume a job. + * + * This method reenables a job after it has been {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. The + * state of a job is stored in {@link google.cloud.scheduler.v1.Job.state|Job.state}; after calling this method it + * will be set to {@link google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED}. A job must be in + * {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED} to be resumed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ resumeJob( - request: protos.google.cloud.scheduler.v1.IResumeJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.scheduler.v1.IResumeJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.scheduler.v1.IResumeJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -710,69 +822,82 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.resumeJob(request, options, callback); } runJob( - request: protos.google.cloud.scheduler.v1.IRunJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1.IRunJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest | undefined, + {} | undefined + ] + >; runJob( - request: protos.google.cloud.scheduler.v1.IRunJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1.IRunJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest | null | undefined, + {} | null | undefined + > + ): void; runJob( - request: protos.google.cloud.scheduler.v1.IRunJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>): void; -/** - * Forces a job to run now. - * - * When this method is called, Cloud Scheduler will dispatch the job, even - * if the job is already running. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.scheduler.v1.IRunJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Forces a job to run now. + * + * When this method is called, Cloud Scheduler will dispatch the job, even + * if the job is already running. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ runJob( - request: protos.google.cloud.scheduler.v1.IRunJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.scheduler.v1.IRunJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.scheduler.v1.IRunJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -781,96 +906,107 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.runJob(request, options, callback); } listJobs( - request: protos.google.cloud.scheduler.v1.IListJobsRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob[], - protos.google.cloud.scheduler.v1.IListJobsRequest|null, - protos.google.cloud.scheduler.v1.IListJobsResponse - ]>; + request: protos.google.cloud.scheduler.v1.IListJobsRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob[], + protos.google.cloud.scheduler.v1.IListJobsRequest | null, + protos.google.cloud.scheduler.v1.IListJobsResponse + ] + >; listJobs( - request: protos.google.cloud.scheduler.v1.IListJobsRequest, - options: gax.CallOptions, - callback: PaginationCallback< - protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>): void; + request: protos.google.cloud.scheduler.v1.IListJobsRequest, + options: gax.CallOptions, + callback: PaginationCallback< + protos.google.cloud.scheduler.v1.IListJobsRequest, + protos.google.cloud.scheduler.v1.IListJobsResponse | null | undefined, + protos.google.cloud.scheduler.v1.IJob + > + ): void; listJobs( - request: protos.google.cloud.scheduler.v1.IListJobsRequest, - callback: PaginationCallback< - protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>): void; -/** - * Lists jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * 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. - * @param {string} request.pageToken - * 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 - * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Job]{@link google.cloud.scheduler.v1.Job}. - * The client library support 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. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Job]{@link google.cloud.scheduler.v1.Job} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListJobsRequest]{@link google.cloud.scheduler.v1.ListJobsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListJobsResponse]{@link google.cloud.scheduler.v1.ListJobsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.scheduler.v1.IListJobsRequest, + callback: PaginationCallback< + protos.google.cloud.scheduler.v1.IListJobsRequest, + protos.google.cloud.scheduler.v1.IListJobsResponse | null | undefined, + protos.google.cloud.scheduler.v1.IJob + > + ): void; + /** + * Lists jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * 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. + * @param {string} request.pageToken + * 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 + * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from + * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to + * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Job]{@link google.cloud.scheduler.v1.Job}. + * The client library support 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. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [Job]{@link google.cloud.scheduler.v1.Job} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListJobsRequest]{@link google.cloud.scheduler.v1.ListJobsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListJobsResponse]{@link google.cloud.scheduler.v1.ListJobsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ listJobs( - request: protos.google.cloud.scheduler.v1.IListJobsRequest, - optionsOrCallback?: gax.CallOptions|PaginationCallback< - protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>, - callback?: PaginationCallback< + request: protos.google.cloud.scheduler.v1.IListJobsRequest, + optionsOrCallback?: + | gax.CallOptions + | PaginationCallback< protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob[], - protos.google.cloud.scheduler.v1.IListJobsRequest|null, - protos.google.cloud.scheduler.v1.IListJobsResponse - ]>|void { + protos.google.cloud.scheduler.v1.IListJobsResponse | null | undefined, + protos.google.cloud.scheduler.v1.IJob + >, + callback?: PaginationCallback< + protos.google.cloud.scheduler.v1.IListJobsRequest, + protos.google.cloud.scheduler.v1.IListJobsResponse | null | undefined, + protos.google.cloud.scheduler.v1.IJob + > + ): Promise< + [ + protos.google.cloud.scheduler.v1.IJob[], + protos.google.cloud.scheduler.v1.IListJobsRequest | null, + protos.google.cloud.scheduler.v1.IListJobsResponse + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -879,54 +1015,54 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); this.initialize(); return this.innerApiCalls.listJobs(request, options, callback); } -/** - * Equivalent to {@link listJobs}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link 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. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * 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. - * @param {string} request.pageToken - * 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 - * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Job]{@link google.cloud.scheduler.v1.Job} on 'data' event. - */ + /** + * Equivalent to {@link listJobs}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link 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. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * 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. + * @param {string} request.pageToken + * 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 + * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from + * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to + * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Job]{@link google.cloud.scheduler.v1.Job} on 'data' event. + */ listJobsStream( - request?: protos.google.cloud.scheduler.v1.IListJobsRequest, - options?: gax.CallOptions): - Transform{ + request?: protos.google.cloud.scheduler.v1.IListJobsRequest, + options?: gax.CallOptions + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -934,7 +1070,7 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); this.initialize(); @@ -945,40 +1081,40 @@ export class CloudSchedulerClient { ); } -/** - * Equivalent to {@link listJobs}, but returns an iterable object. - * - * for-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * 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. - * @param {string} request.pageToken - * 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 - * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. - */ + /** + * Equivalent to {@link listJobs}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * 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. + * @param {string} request.pageToken + * 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 + * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from + * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to + * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ listJobsAsync( - request?: protos.google.cloud.scheduler.v1.IListJobsRequest, - options?: gax.CallOptions): - AsyncIterable{ + request?: protos.google.cloud.scheduler.v1.IListJobsRequest, + options?: gax.CallOptions + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -986,14 +1122,14 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); options = options || {}; const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listJobs.asyncIterate( this.innerApiCalls['listJobs'] as GaxCall, - request as unknown as RequestType, + (request as unknown) as RequestType, callSettings ) as AsyncIterable; } @@ -1009,7 +1145,7 @@ export class CloudSchedulerClient { * @param {string} job * @returns {string} Resource name string. */ - jobPath(project:string,location:string,job:string) { + jobPath(project: string, location: string, job: string) { return this.pathTemplates.jobPathTemplate.render({ project: project, location: location, @@ -1057,7 +1193,7 @@ export class CloudSchedulerClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1092,7 +1228,7 @@ export class CloudSchedulerClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); diff --git a/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts b/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts index 335389d5065..ba53f65a70d 100644 --- a/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts +++ b/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts @@ -17,11 +17,18 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; import * as path from 'path'; -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; +import {Transform} from 'stream'; +import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './cloud_scheduler_client_config.json'; @@ -41,7 +48,12 @@ export class CloudSchedulerClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; cloudSchedulerStub?: Promise<{[name: string]: Function}>; @@ -75,10 +87,12 @@ export class CloudSchedulerClient { constructor(opts?: ClientOptions) { // Ensure that options include the service address and port. const staticMembers = this.constructor as typeof CloudSchedulerClient; - const servicePath = opts && opts.servicePath ? - opts.servicePath : - ((opts && opts.apiEndpoint) ? opts.apiEndpoint : - staticMembers.servicePath); + const servicePath = + opts && opts.servicePath + ? opts.servicePath + : opts && opts.apiEndpoint + ? opts.apiEndpoint + : staticMembers.servicePath; const port = opts && opts.port ? opts.port : staticMembers.port; if (!opts) { @@ -88,8 +102,8 @@ export class CloudSchedulerClient { opts.port = opts.port || port; opts.clientConfig = opts.clientConfig || {}; - const isBrowser = (typeof window !== 'undefined'); - if (isBrowser){ + const isBrowser = typeof window !== 'undefined'; + if (isBrowser) { opts.fallback = true; } // If we are in browser, we are already using fallback because of the @@ -106,13 +120,10 @@ export class CloudSchedulerClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -128,12 +139,18 @@ export class CloudSchedulerClient { // For Node.js, pass the path to JSON proto file. // For browsers, pass the JSON content. - const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? - // eslint-disable-next-line @typescript-eslint/no-var-requires - require("../../protos/protos.json") : - nodejsProtoPath + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + require('../../protos/protos.json') + : nodejsProtoPath ); // This API contains "path templates"; forward-slash-separated @@ -155,14 +172,20 @@ export class CloudSchedulerClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs') + listJobs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'jobs' + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.scheduler.v1beta1.CloudScheduler', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.scheduler.v1beta1.CloudScheduler', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -190,16 +213,27 @@ export class CloudSchedulerClient { // Put together the "service stub" for // google.cloud.scheduler.v1beta1.CloudScheduler. this.cloudSchedulerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.scheduler.v1beta1.CloudScheduler') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.scheduler.v1beta1.CloudScheduler' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.scheduler.v1beta1.CloudScheduler, - this._opts) as Promise<{[method: string]: Function}>; + this._opts + ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const cloudSchedulerStubMethods = - ['listJobs', 'getJob', 'createJob', 'updateJob', 'deleteJob', 'pauseJob', 'resumeJob', 'runJob']; + const cloudSchedulerStubMethods = [ + 'listJobs', + 'getJob', + 'createJob', + 'updateJob', + 'deleteJob', + 'pauseJob', + 'resumeJob', + 'runJob', + ]; for (const methodName of cloudSchedulerStubMethods) { const callPromise = this.cloudSchedulerStub.then( stub => (...args: Array<{}>) => { @@ -209,16 +243,17 @@ export class CloudSchedulerClient { const func = stub[methodName]; return func.apply(stub, args); }, - (err: Error|null|undefined) => () => { + (err: Error | null | undefined) => () => { throw err; - }); + } + ); const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); this.innerApiCalls[methodName] = apiCall; @@ -254,9 +289,7 @@ export class CloudSchedulerClient { * in this service. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -266,8 +299,9 @@ export class CloudSchedulerClient { * @param {function(Error, string)} callback - the callback to * be called with the current project Id. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -279,60 +313,75 @@ export class CloudSchedulerClient { // -- Service calls -- // ------------------- getJob( - request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest | undefined, + {} | undefined + ] + >; getJob( - request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest | null | undefined, + {} | null | undefined + > + ): void; 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; -/** - * Gets a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + 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; + /** + * Gets a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getJob( - request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.scheduler.v1beta1.IGetJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -341,72 +390,93 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.getJob(request, options, callback); } createJob( - request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest | undefined, + {} | undefined + ] + >; createJob( - request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + | protos.google.cloud.scheduler.v1beta1.ICreateJobRequest + | null + | undefined, + {} | null | undefined + > + ): void; 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; -/** - * Creates a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {google.cloud.scheduler.v1beta1.Job} request.job - * Required. The job to add. The user can optionally specify a name for the - * job in {@link google.cloud.scheduler.v1beta1.Job.name|name}. {@link google.cloud.scheduler.v1beta1.Job.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 - * ({@link google.cloud.scheduler.v1beta1.Job.name|name}) in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + 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; + /** + * Creates a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {google.cloud.scheduler.v1beta1.Job} request.job + * Required. The job to add. The user can optionally specify a name for the + * job in {@link google.cloud.scheduler.v1beta1.Job.name|name}. {@link google.cloud.scheduler.v1beta1.Job.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 + * ({@link google.cloud.scheduler.v1beta1.Job.name|name}) in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ createJob( - request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.scheduler.v1beta1.ICreateJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + | protos.google.cloud.scheduler.v1beta1.ICreateJobRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -415,78 +485,99 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); this.initialize(); return this.innerApiCalls.createJob(request, options, callback); } updateJob( - request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest | undefined, + {} | undefined + ] + >; updateJob( - request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + | protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest + | null + | undefined, + {} | null | undefined + > + ): void; 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; -/** - * Updates a job. - * - * If successful, the updated {@link google.cloud.scheduler.v1beta1.Job|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 {@link google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED|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. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.scheduler.v1beta1.Job} request.job - * Required. The new job properties. {@link google.cloud.scheduler.v1beta1.Job.name|name} must be specified. - * - * Output only fields cannot be modified using UpdateJob. - * Any value specified for an output only field will be ignored. - * @param {google.protobuf.FieldMask} request.updateMask - * A mask used to specify which fields of the job are being updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + 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; + /** + * Updates a job. + * + * If successful, the updated {@link google.cloud.scheduler.v1beta1.Job|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 {@link google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED|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. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.scheduler.v1beta1.Job} request.job + * Required. The new job properties. {@link google.cloud.scheduler.v1beta1.Job.name|name} must be specified. + * + * Output only fields cannot be modified using UpdateJob. + * Any value specified for an output only field will be ignored. + * @param {google.protobuf.FieldMask} request.updateMask + * A mask used to specify which fields of the job are being updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ updateJob( - request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + | protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -501,60 +592,81 @@ export class CloudSchedulerClient { return this.innerApiCalls.updateJob(request, options, callback); } deleteJob( - request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest | undefined, + {} | undefined + ] + >; deleteJob( - request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest + | null + | undefined, + {} | null | undefined + > + ): void; 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; -/** - * Deletes a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Deletes a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ deleteJob( - request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -563,72 +675,87 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.deleteJob(request, options, callback); } pauseJob( - request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest | undefined, + {} | undefined + ] + >; pauseJob( - request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest | null | undefined, + {} | null | undefined + > + ): void; 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; -/** - * Pauses a job. - * - * If a job is paused then the system will stop executing the job - * until it is re-enabled via {@link google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob|ResumeJob}. The - * state of the job is stored in {@link google.cloud.scheduler.v1beta1.Job.state|state}; if paused it - * will be set to {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. A job must be in {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED} - * to be paused. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + 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; + /** + * Pauses a job. + * + * If a job is paused then the system will stop executing the job + * until it is re-enabled via {@link google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob|ResumeJob}. The + * state of the job is stored in {@link google.cloud.scheduler.v1beta1.Job.state|state}; if paused it + * will be set to {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. A job must be in {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED} + * to be paused. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ pauseJob( - request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.scheduler.v1beta1.IPauseJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -637,71 +764,92 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.pauseJob(request, options, callback); } resumeJob( - request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest | undefined, + {} | undefined + ] + >; resumeJob( - request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + | protos.google.cloud.scheduler.v1beta1.IResumeJobRequest + | null + | undefined, + {} | null | undefined + > + ): void; 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; -/** - * Resume a job. - * - * This method reenables a job after it has been {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. The - * state of a job is stored in {@link google.cloud.scheduler.v1beta1.Job.state|Job.state}; after calling this method it - * will be set to {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED}. A job must be in - * {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED} to be resumed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + 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; + /** + * Resume a job. + * + * This method reenables a job after it has been {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. The + * state of a job is stored in {@link google.cloud.scheduler.v1beta1.Job.state|Job.state}; after calling this method it + * will be set to {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED}. A job must be in + * {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED} to be resumed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ resumeJob( - request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.scheduler.v1beta1.IResumeJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + | protos.google.cloud.scheduler.v1beta1.IResumeJobRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -710,69 +858,84 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.resumeJob(request, options, callback); } runJob( - request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest | undefined, + {} | undefined + ] + >; runJob( - request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest | null | undefined, + {} | null | undefined + > + ): void; 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; -/** - * Forces a job to run now. - * - * When this method is called, Cloud Scheduler will dispatch the job, even - * if the job is already running. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + 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; + /** + * Forces a job to run now. + * + * When this method is called, Cloud Scheduler will dispatch the job, even + * if the job is already running. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ runJob( - request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.scheduler.v1beta1.IRunJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -781,96 +944,115 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.runJob(request, options, callback); } listJobs( - request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob[], - protos.google.cloud.scheduler.v1beta1.IListJobsRequest|null, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse - ]>; + request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob[], + protos.google.cloud.scheduler.v1beta1.IListJobsRequest | null, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse + ] + >; listJobs( - request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - options: gax.CallOptions, - callback: PaginationCallback< - protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1beta1.IJob>): void; + request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + options: gax.CallOptions, + callback: PaginationCallback< + protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + | protos.google.cloud.scheduler.v1beta1.IListJobsResponse + | null + | undefined, + protos.google.cloud.scheduler.v1beta1.IJob + > + ): void; 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; -/** - * Lists jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * 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. - * @param {string} request.pageToken - * 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 - * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while iterating through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Job]{@link google.cloud.scheduler.v1beta1.Job}. - * The client library support 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. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Job]{@link google.cloud.scheduler.v1beta1.Job} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListJobsRequest]{@link google.cloud.scheduler.v1beta1.ListJobsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListJobsResponse]{@link google.cloud.scheduler.v1beta1.ListJobsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + 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; + /** + * Lists jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * 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. + * @param {string} request.pageToken + * 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 + * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} returned from + * the previous call to {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is an error to + * switch the value of {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while iterating through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Job]{@link google.cloud.scheduler.v1beta1.Job}. + * The client library support 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. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [Job]{@link google.cloud.scheduler.v1beta1.Job} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListJobsRequest]{@link google.cloud.scheduler.v1beta1.ListJobsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListJobsResponse]{@link google.cloud.scheduler.v1beta1.ListJobsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ listJobs( - request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - optionsOrCallback?: gax.CallOptions|PaginationCallback< - protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1beta1.IJob>, - callback?: PaginationCallback< + request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + optionsOrCallback?: + | gax.CallOptions + | PaginationCallback< protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1beta1.IJob>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob[], - protos.google.cloud.scheduler.v1beta1.IListJobsRequest|null, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse - ]>|void { + | protos.google.cloud.scheduler.v1beta1.IListJobsResponse + | null + | undefined, + protos.google.cloud.scheduler.v1beta1.IJob + >, + callback?: PaginationCallback< + protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + | protos.google.cloud.scheduler.v1beta1.IListJobsResponse + | null + | undefined, + protos.google.cloud.scheduler.v1beta1.IJob + > + ): Promise< + [ + protos.google.cloud.scheduler.v1beta1.IJob[], + protos.google.cloud.scheduler.v1beta1.IListJobsRequest | null, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -879,54 +1061,54 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); this.initialize(); return this.innerApiCalls.listJobs(request, options, callback); } -/** - * Equivalent to {@link listJobs}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link 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. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * 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. - * @param {string} request.pageToken - * 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 - * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while iterating through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job} on 'data' event. - */ + /** + * Equivalent to {@link listJobs}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link 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. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * 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. + * @param {string} request.pageToken + * 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 + * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} returned from + * the previous call to {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is an error to + * switch the value of {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while iterating through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Job]{@link google.cloud.scheduler.v1beta1.Job} on 'data' event. + */ listJobsStream( - request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - options?: gax.CallOptions): - Transform{ + request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + options?: gax.CallOptions + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -934,7 +1116,7 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); this.initialize(); @@ -945,40 +1127,40 @@ export class CloudSchedulerClient { ); } -/** - * Equivalent to {@link listJobs}, but returns an iterable object. - * - * for-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * 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. - * @param {string} request.pageToken - * 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 - * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while iterating through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. - */ + /** + * Equivalent to {@link listJobs}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * 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. + * @param {string} request.pageToken + * 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 + * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} returned from + * the previous call to {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is an error to + * switch the value of {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while iterating through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ listJobsAsync( - request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - options?: gax.CallOptions): - AsyncIterable{ + request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + options?: gax.CallOptions + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -986,14 +1168,14 @@ export class CloudSchedulerClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); options = options || {}; const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listJobs.asyncIterate( this.innerApiCalls['listJobs'] as GaxCall, - request as unknown as RequestType, + (request as unknown) as RequestType, callSettings ) as AsyncIterable; } @@ -1009,7 +1191,7 @@ export class CloudSchedulerClient { * @param {string} job * @returns {string} Resource name string. */ - jobPath(project:string,location:string,job:string) { + jobPath(project: string, location: string, job: string) { return this.pathTemplates.jobPathTemplate.render({ project: project, location: location, @@ -1057,7 +1239,7 @@ export class CloudSchedulerClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1092,7 +1274,7 @@ export class CloudSchedulerClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); diff --git a/packages/google-cloud-scheduler/synth.metadata b/packages/google-cloud-scheduler/synth.metadata index c7ecac53cf1..6dbe457776e 100644 --- a/packages/google-cloud-scheduler/synth.metadata +++ b/packages/google-cloud-scheduler/synth.metadata @@ -1,12 +1,25 @@ { - "updateTime": "2020-04-11T00:47:31.019817Z", "sources": [ + { + "git": { + "name": ".", + "remote": "https://github.com/googleapis/nodejs-scheduler.git", + "sha": "ecda16434c53cda59f87e2919eab64efb1ad8375" + } + }, + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "1bd77e8ce6f953ac641af7966d0c52646afc16a8", + "internalRef": "305974465" + } + }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "6f32150677c9784f3c3a7e1949472bd29c9d72c5", - "log": "6f32150677c9784f3c3a7e1949472bd29c9d72c5\nfix: installs test_utils from its common repo (#480)\n\n\n74ce986d3b5431eb66985e9a00c4eb45295a4020\nfix: stop recording update_time in synth.metadata (#478)\n\n\n7f8e62aa3edd225f76347a16f92e400661fdfb52\nchore(java): release-please only updates non maven versions in README (#476)\n\nPrevent release-please and synthtool from fighting over the released library version. Synthtool updates the install snippets from the samples pom.xml files so the bots fight if they are temporarily out of sync after a release.\nc7e0e517d7f46f77bebd27da2e5afcaa6eee7e25\nbuild(java): fix nightly integration test config to run integrations (#465)\n\nThis was only running the units.\nbd69a2aa7b70875f3c988e269706b22fefbef40e\nbuild(java): fix retry_with_backoff when -e option set (#475)\n\n\nd9b173c427bfa0c6cca818233562e7e8841a357c\nfix: record version of working repo in synth.metadata (#473)\n\nPartial revert of b37cf74d12e9a42b9de9e61a4f26133d7cd9c168.\nf73a541770d95a609e5be6bf6b3b220d17cefcbe\nfeat(discogapic): allow local discovery-artifact-manager (#474)\n\n\n8cf0f5d93a70c3dcb0b4999d3152c46d4d9264bf\ndoc: describe the Autosynth & Synthtool protocol (#472)\n\n* doc: describe the Autosynth & Synthtool protocol\n\n* Accommodate review comments.\n980baaa738a1ad8fa02b4fdbd56be075ee77ece5\nfix: pin sphinx to <3.0.0 as new version causes new error (#471)\n\nThe error `toctree contains reference to document changlelog that doesn't have a title: no link will be generated` occurs as of 3.0.0. Pinning to 2.x until we address the docs build issue.\n\nTowards #470\n\nI did this manually for python-datastore https://github.com/googleapis/python-datastore/pull/22\n928b2998ac5023e7c7e254ab935f9ef022455aad\nchore(deps): update dependency com.google.cloud.samples:shared-configuration to v1.0.15 (#466)\n\nCo-authored-by: Jeffrey Rennie \n188f1b1d53181f739b98f8aa5d40cfe99eb90c47\nfix: allow local and external deps to be specified (#469)\n\nModify noxfile.py to allow local and external dependencies for\nsystem tests to be specified.\n" + "sha": "6f32150677c9784f3c3a7e1949472bd29c9d72c5" } } ], diff --git a/packages/google-cloud-scheduler/system-test/fixtures/sample/src/index.js b/packages/google-cloud-scheduler/system-test/fixtures/sample/src/index.js index fda94a11679..b0d306f935e 100644 --- a/packages/google-cloud-scheduler/system-test/fixtures/sample/src/index.js +++ b/packages/google-cloud-scheduler/system-test/fixtures/sample/src/index.js @@ -16,7 +16,6 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** - /* eslint-disable node/no-missing-require, no-unused-vars */ const scheduler = require('@google-cloud/scheduler'); diff --git a/packages/google-cloud-scheduler/system-test/install.ts b/packages/google-cloud-scheduler/system-test/install.ts index 5e4ed636481..c4d80e9c0c8 100644 --- a/packages/google-cloud-scheduler/system-test/install.ts +++ b/packages/google-cloud-scheduler/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; describe('typescript consumer tests', () => { - it('should have correct type signature for typescript users', async function() { this.timeout(300000); const options = { - packageDir: process.cwd(), // path to your module. + packageDir: process.cwd(), // path to your module. sample: { description: 'typescript based user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts' + ).toString(), + }, }; - await packNTest(options); // will throw upon error. + await packNTest(options); // will throw upon error. }); it('should have correct type signature for javascript users', async function() { this.timeout(300000); const options = { - packageDir: process.cwd(), // path to your module. + packageDir: process.cwd(), // path to your module. sample: { description: 'typescript based user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.js' + ).toString(), + }, }; - await packNTest(options); // will throw upon error. + await packNTest(options); // will throw upon error. }); - }); diff --git a/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1.ts b/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1.ts index b2b2448ca16..f721e2e7920 100644 --- a/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1.ts +++ b/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1.ts @@ -20,7 +20,7 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; +import {describe, it} from 'mocha'; import * as cloudschedulerModule from '../src'; import {PassThrough} from 'stream'; @@ -28,1070 +28,1381 @@ import {PassThrough} from 'stream'; import {protobuf} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = (instance.constructor as typeof protobuf.Message).toObject( + instance as protobuf.Message, + {defaults: true} + ); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.CloudSchedulerClient', () => { - it('has servicePath', () => { - const servicePath = cloudschedulerModule.v1.CloudSchedulerClient.servicePath; - assert(servicePath); - }); + it('has servicePath', () => { + const servicePath = + cloudschedulerModule.v1.CloudSchedulerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + cloudschedulerModule.v1.CloudSchedulerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = cloudschedulerModule.v1.CloudSchedulerClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has apiEndpoint', () => { - const apiEndpoint = cloudschedulerModule.v1.CloudSchedulerClient.apiEndpoint; - assert(apiEndpoint); + it('should create a client with no option', () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + fallback: true, }); + assert(client); + }); - it('has port', () => { - const port = cloudschedulerModule.v1.CloudSchedulerClient.port; - assert(port); - assert(typeof port === 'number'); + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); + assert.strictEqual(client.cloudSchedulerStub, undefined); + await client.initialize(); + assert(client.cloudSchedulerStub); + }); - it('should create a client with no option', () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient(); - assert(client); + it('has close method', () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); + client.close(); + }); - it('should create a client with gRPC fallback', () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - fallback: true, - }); - assert(client); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudSchedulerStub, undefined); - await client.initialize(); - assert(client.cloudSchedulerStub); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); - it('has close method', () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); + describe('getJob', () => { + it('invokes getJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.GetJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); + const [response] = await client.getJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('invokes getJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.GetJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('invokes getJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.GetJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.getJob(request); + }, expectedError); + assert( + (client.innerApiCalls.getJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); - describe('getJob', () => { - it('invokes getJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.GetJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); - const [response] = await client.getJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('createJob', () => { + it('invokes createJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.CreateJobRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); + const [response] = await client.createJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes getJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.GetJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes createJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.CreateJobRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes getJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.GetJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.getJob(request); }, expectedError); - assert((client.innerApiCalls.getJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes createJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.CreateJobRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.createJob(request); + }, expectedError); + assert( + (client.innerApiCalls.createJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); - describe('createJob', () => { - it('invokes createJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.CreateJobRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); - const [response] = await client.createJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('updateJob', () => { + it('invokes updateJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.UpdateJobRequest() + ); + request.job = {}; + request.job.name = ''; + const expectedHeaderRequestParams = 'job.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); + const [response] = await client.updateJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes createJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.CreateJobRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes updateJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.UpdateJobRequest() + ); + request.job = {}; + request.job.name = ''; + const expectedHeaderRequestParams = 'job.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes createJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.CreateJobRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.createJob(request); }, expectedError); - assert((client.innerApiCalls.createJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes updateJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.UpdateJobRequest() + ); + request.job = {}; + request.job.name = ''; + const expectedHeaderRequestParams = 'job.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.updateJob(request); + }, expectedError); + assert( + (client.innerApiCalls.updateJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); - describe('updateJob', () => { - it('invokes updateJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.UpdateJobRequest()); - request.job = {}; - request.job.name = ''; - const expectedHeaderRequestParams = "job.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); - const [response] = await client.updateJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.DeleteJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); + const [response] = await client.deleteJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes updateJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.UpdateJobRequest()); - request.job = {}; - request.job.name = ''; - const expectedHeaderRequestParams = "job.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes deleteJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.DeleteJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes updateJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.UpdateJobRequest()); - request.job = {}; - request.job.name = ''; - const expectedHeaderRequestParams = "job.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.updateJob(request); }, expectedError); - assert((client.innerApiCalls.updateJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes deleteJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.DeleteJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.deleteJob(request); + }, expectedError); + assert( + (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.DeleteJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); - const [response] = await client.deleteJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('pauseJob', () => { + it('invokes pauseJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.PauseJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); + const [response] = await client.pauseJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes deleteJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.DeleteJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes pauseJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.PauseJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.pauseJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes deleteJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.DeleteJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.deleteJob(request); }, expectedError); - assert((client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes pauseJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.PauseJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.pauseJob(request); + }, expectedError); + assert( + (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); - describe('pauseJob', () => { - it('invokes pauseJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.PauseJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); - const [response] = await client.pauseJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('resumeJob', () => { + it('invokes resumeJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ResumeJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); + const [response] = await client.resumeJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes pauseJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.PauseJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.pauseJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes resumeJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ResumeJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.resumeJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes pauseJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.PauseJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.pauseJob(request); }, expectedError); - assert((client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes resumeJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ResumeJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.resumeJob(request); + }, expectedError); + assert( + (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); - describe('resumeJob', () => { - it('invokes resumeJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.ResumeJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); - const [response] = await client.resumeJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('runJob', () => { + it('invokes runJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.RunJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); + const [response] = await client.runJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.runJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes resumeJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.ResumeJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.resumeJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes runJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.RunJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.runJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.runJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes resumeJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.ResumeJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.resumeJob(request); }, expectedError); - assert((client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes runJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.RunJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.runJob(request); + }, expectedError); + assert( + (client.innerApiCalls.runJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); - describe('runJob', () => { - it('invokes runJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.RunJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); - const [response] = await client.runJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.runJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listJobs(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listJobs as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes runJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.RunJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()); - client.innerApiCalls.runJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.runJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes listJobs without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1.IJob[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listJobs as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes runJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.RunJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.runJob(request); }, expectedError); - assert((client.innerApiCalls.runJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes listJobs with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.listJobs(request); + }, expectedError); + assert( + (client.innerApiCalls.listJobs as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listJobs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listJobs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); + it('invokes listJobsStream without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + ]; + client.descriptors.page.listJobs.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.scheduler.v1.Job[] = []; + stream.on('data', (response: protos.google.cloud.scheduler.v1.Job) => { + responses.push(response); }); - - it('invokes listJobs without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listJobs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listJobs with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.listJobs(request); }, expectedError); - assert((client.innerApiCalls.listJobs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listJobs, request) + ); + assert.strictEqual( + (client.descriptors.page.listJobs.createStream as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes listJobsStream without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - ]; - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.scheduler.v1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.v1.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert.strictEqual( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); + it('invokes listJobsStream with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.scheduler.v1.Job[] = []; + stream.on('data', (response: protos.google.cloud.scheduler.v1.Job) => { + responses.push(response); }); - - it('invokes listJobsStream with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.scheduler.v1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.v1.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(async () => { await promise; }, expectedError); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert.strictEqual( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listJobs without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.scheduler.v1.IJob[] = []; - const iterable = client.listJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listJobs, request) + ); + assert.strictEqual( + (client.descriptors.page.listJobs.createStream as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('uses async iteration with listJobs with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.scheduler.v1.IJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('uses async iteration with listJobs without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + ]; + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.cloud.scheduler.v1.IJob[] = []; + const iterable = client.listJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); }); - describe('Path templates', () => { + it('uses async iteration with listJobs with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.scheduler.v1.IJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); - describe('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); + describe('Path templates', () => { + describe('job', () => { + const fakePath = '/rendered/path/job'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + job: 'jobValue', + }; + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.jobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.jobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('jobPath', () => { + const result = client.jobPath( + 'projectValue', + 'locationValue', + 'jobValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); + describe('location', () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); }); + }); }); diff --git a/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1beta1.ts b/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1beta1.ts index b5457d1b39e..3d20a7c23fd 100644 --- a/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1beta1.ts +++ b/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1beta1.ts @@ -20,7 +20,7 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; +import {describe, it} from 'mocha'; import * as cloudschedulerModule from '../src'; import {PassThrough} from 'stream'; @@ -28,1070 +28,1387 @@ import {PassThrough} from 'stream'; import {protobuf} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = (instance.constructor as typeof protobuf.Message).toObject( + instance as protobuf.Message, + {defaults: true} + ); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta1.CloudSchedulerClient', () => { - it('has servicePath', () => { - const servicePath = cloudschedulerModule.v1beta1.CloudSchedulerClient.servicePath; - assert(servicePath); - }); + it('has servicePath', () => { + const servicePath = + cloudschedulerModule.v1beta1.CloudSchedulerClient.servicePath; + assert(servicePath); + }); - it('has apiEndpoint', () => { - const apiEndpoint = cloudschedulerModule.v1beta1.CloudSchedulerClient.apiEndpoint; - assert(apiEndpoint); - }); + it('has apiEndpoint', () => { + const apiEndpoint = + cloudschedulerModule.v1beta1.CloudSchedulerClient.apiEndpoint; + assert(apiEndpoint); + }); - it('has port', () => { - const port = cloudschedulerModule.v1beta1.CloudSchedulerClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has port', () => { + const port = cloudschedulerModule.v1beta1.CloudSchedulerClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with no option', () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient(); - assert(client); + it('should create a client with no option', () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + fallback: true, }); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - fallback: true, - }); - assert(client); + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); + assert.strictEqual(client.cloudSchedulerStub, undefined); + await client.initialize(); + assert(client.cloudSchedulerStub); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudSchedulerStub, undefined); - await client.initialize(); - assert(client.cloudSchedulerStub); + it('has close method', () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); + client.close(); + }); - it('has close method', () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + describe('getJob', () => { + it('invokes getJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.GetJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); + const [response] = await client.getJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('getJob', () => { - it('invokes getJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.GetJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); - const [response] = await client.getJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.GetJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1beta1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes getJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.GetJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes getJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.GetJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.getJob(request); + }, expectedError); + assert( + (client.innerApiCalls.getJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes getJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.GetJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.getJob(request); }, expectedError); - assert((client.innerApiCalls.getJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('createJob', () => { + it('invokes createJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); + const [response] = await client.createJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('createJob', () => { - it('invokes createJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.CreateJobRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); - const [response] = await client.createJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes createJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1beta1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes createJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.CreateJobRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes createJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.createJob(request); + }, expectedError); + assert( + (client.innerApiCalls.createJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes createJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.CreateJobRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.createJob(request); }, expectedError); - assert((client.innerApiCalls.createJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('updateJob', () => { + it('invokes updateJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() + ); + request.job = {}; + request.job.name = ''; + const expectedHeaderRequestParams = 'job.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); + const [response] = await client.updateJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('updateJob', () => { - it('invokes updateJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest()); - request.job = {}; - request.job.name = ''; - const expectedHeaderRequestParams = "job.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); - const [response] = await client.updateJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes updateJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() + ); + request.job = {}; + request.job.name = ''; + const expectedHeaderRequestParams = 'job.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1beta1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes updateJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest()); - request.job = {}; - request.job.name = ''; - const expectedHeaderRequestParams = "job.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes updateJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() + ); + request.job = {}; + request.job.name = ''; + const expectedHeaderRequestParams = 'job.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.updateJob(request); + }, expectedError); + assert( + (client.innerApiCalls.updateJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes updateJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest()); - request.job = {}; - request.job.name = ''; - const expectedHeaderRequestParams = "job.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.updateJob(request); }, expectedError); - assert((client.innerApiCalls.updateJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); + const [response] = await client.deleteJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); - const [response] = await client.deleteJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes deleteJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes deleteJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes deleteJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.deleteJob(request); + }, expectedError); + assert( + (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes deleteJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.deleteJob(request); }, expectedError); - assert((client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('pauseJob', () => { + it('invokes pauseJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); + const [response] = await client.pauseJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('pauseJob', () => { - it('invokes pauseJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.PauseJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); - const [response] = await client.pauseJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes pauseJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.pauseJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1beta1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes pauseJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.PauseJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.pauseJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes pauseJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.pauseJob(request); + }, expectedError); + assert( + (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes pauseJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.PauseJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.pauseJob(request); }, expectedError); - assert((client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('resumeJob', () => { + it('invokes resumeJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); + const [response] = await client.resumeJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('resumeJob', () => { - it('invokes resumeJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); - const [response] = await client.resumeJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes resumeJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.resumeJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1beta1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes resumeJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.resumeJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes resumeJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.resumeJob(request); + }, expectedError); + assert( + (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes resumeJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.resumeJob(request); }, expectedError); - assert((client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('runJob', () => { + it('invokes runJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.RunJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); + const [response] = await client.runJob(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.runJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('runJob', () => { - it('invokes runJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.RunJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); - const [response] = await client.runJob(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.runJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes runJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.RunJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.runJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1beta1.IJob | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.runJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes runJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.RunJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()); - client.innerApiCalls.runJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.runJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes runJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.RunJobRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.runJob(request); + }, expectedError); + assert( + (client.innerApiCalls.runJob as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes runJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.RunJobRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.runJob(request); }, expectedError); - assert((client.innerApiCalls.runJob as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listJobs(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listJobs as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listJobs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listJobs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes listJobs without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.scheduler.v1beta1.IJob[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listJobs as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes listJobs without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listJobs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes listJobs with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.listJobs(request); + }, expectedError); + assert( + (client.innerApiCalls.listJobs as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes listJobs with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.listJobs(request); }, expectedError); - assert((client.innerApiCalls.listJobs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); + it('invokes listJobsStream without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + ]; + client.descriptors.page.listJobs.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.scheduler.v1beta1.Job[] = []; + stream.on( + 'data', + (response: protos.google.cloud.scheduler.v1beta1.Job) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listJobsStream without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - ]; - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.scheduler.v1beta1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.v1beta1.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert.strictEqual( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listJobs, request) + ); + assert.strictEqual( + (client.descriptors.page.listJobs.createStream as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes listJobsStream with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.scheduler.v1beta1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.v1beta1.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(async () => { await promise; }, expectedError); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert.strictEqual( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); + it('invokes listJobsStream with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.scheduler.v1beta1.Job[] = []; + stream.on( + 'data', + (response: protos.google.cloud.scheduler.v1beta1.Job) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listJobs without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.scheduler.v1beta1.IJob[] = []; - const iterable = client.listJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listJobs, request) + ); + assert.strictEqual( + (client.descriptors.page.listJobs.createStream as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('uses async iteration with listJobs with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.ListJobsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.scheduler.v1beta1.IJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('uses async iteration with listJobs without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + ]; + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.cloud.scheduler.v1beta1.IJob[] = []; + const iterable = client.listJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); }); - describe('Path templates', () => { + it('uses async iteration with listJobs with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.scheduler.v1beta1.IJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); - describe('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); + describe('Path templates', () => { + describe('job', () => { + const fakePath = '/rendered/path/job'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + job: 'jobValue', + }; + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.jobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.jobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('jobPath', () => { + const result = client.jobPath( + 'projectValue', + 'locationValue', + 'jobValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); + describe('location', () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); }); + }); }); diff --git a/packages/google-cloud-scheduler/webpack.config.js b/packages/google-cloud-scheduler/webpack.config.js index 35d45e25f74..c4e99ab2d0b 100644 --- a/packages/google-cloud-scheduler/webpack.config.js +++ b/packages/google-cloud-scheduler/webpack.config.js @@ -36,27 +36,27 @@ module.exports = { { test: /\.tsx?$/, use: 'ts-loader', - exclude: /node_modules/ + exclude: /node_modules/, }, { test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]grpc/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]retry-request/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]gtoken/, - use: 'null-loader' + use: 'null-loader', }, ], },